Created attachment 10767 [details] objects.tar.xz From: https://bugs.debian.org/886222 The GOLD linker fails to link GHC on the 3 mips Debian architectures. Using the BFD linker works. It seems to fail in previous binutils versions as well so I don't think this is a regression. The original link command is very large, but I have at least managed to get the input objects down to around 24MB worth of objects (attached). Ignore all the undefined references which come from missing objects I have removed. Simply linking the objects together: ld objects/* Gives: > [...] > Syntax.p_o:ghc_3.p_hc:function s1oJN_entry: error: undefined reference to 'base_GHCziShow_zdfShowZLz2cUz2cUZRzuzdsgo2_entry' > Syntax.p_o:ghc_3.p_hc:function s1oMG_entry: error: undefined reference to 'base_GHCziShow_zdfShowZLz2cUz2cUZRzuzdsgo2_entry' > Syntax.p_o:ghc_3.p_hc:function s1oMT_entry: error: undefined reference to 'base_GHCziShow_zdfShowZLz2cUz2cUZRzuzdsgo2_entry' > ../../build-mips/gold/ld-new: internal error in get_got_page_offset, at ../../binutils-gdb/gold/mips.cc:6271
Created attachment 10936 [details] patch from James Cowgill
The master branch has been updated by Cary Coutant <ccoutant@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=67faf1f4c206516837fa44f6b7d131966be6bf0f commit 67faf1f4c206516837fa44f6b7d131966be6bf0f Author: James Cowgill <james.cowgill@mips.com> Date: Thu Apr 5 08:47:53 2018 -0700 MIPS: Fix GOT page counter in multi-got links The record_got_page_entry function records and updates the maximum number of GOT page entries which may be required by an object. In the case where an existing GOT page entry was expanded, only the entry belonging to output GOT would have its page count updated. This leaves the entry belonging to the object GOT with the num_pages count of 1 it was originally initialized with. Later on when GOTs are being merged in a multi-got link, this causes the value of entry->num_pages in add_got_page_entries to always be 1 and underestimates the number of pages required for the new entry. This in turn leads to an assertion failure in get_got_page_offset where we run out of pages. Fix by obtaining the object's GOT entry unconditionally and not just the first time it gets created. Now that entry2 is always valid, remove the useless NULL checks. gold/ PR gold/22770 * mips.cc (Mips_got_info::record_got_page_entry): Fetch existing page entries for the object's GOT.
Fixed on master.
The master branch has been updated by Cary Coutant <ccoutant@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=494e49c9855c75e5cf95a2c031401d2d4f5e21fe commit 494e49c9855c75e5cf95a2c031401d2d4f5e21fe Author: Cary Coutant <ccoutant@gmail.com> Date: Thu Apr 5 09:41:42 2018 -0700 Revert previous patch and apply revised patch. Revert: 2018-04-05 James Cowgill <james.cowgill@mips.com> PR gold/22770 * mips.cc (Mips_got_info::record_got_page_entry): Fetch existing page entries for the object's GOT. Apply: PR gold/22770 * mips.cc (Mips_got_info::record_got_page_entry): Don't insert Got_page_entry for object's GOT. (Mips_got_info::add_got_page_entries): Add all pages from from's GOT. Rename to add_got_page_count. (Got_page_entry): Remove num_pages.