PR22770: MIPS: Fix GOT page counter in multi-got links
authorJames Cowgill <james.cowgill@mips.com>
Thu, 1 Mar 2018 11:55:18 +0000 (11:55 +0000)
committerMatthias Klose <doko@debian.org>
Wed, 16 May 2018 14:21:19 +0000 (15:21 +0100)
commit595a7ec83504c6a7319c69f3fd844bc0ca704247
tree67ec3fa637107c1258e33897872ee71e82889aca
parente2bb07e53eb455cfb85f310a3b00db5b20916d18
PR22770: 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 the master 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 not inserting Got_page_entrys into the object's GOT at all and
later on adding the total number of page entries recorded for the
object's GOT into the new merged GOT. This is safe because
got_page_entries_ is used for no other purpose in the object's GOT, and
page_gotno_ for the object's GOT should already be incremented by the correct
amount in record_got_page_entry. Remove Got_page_entry::num_pages which
is now unused.

gold/
2018-03-01  James Cowgill  <james.cowgill@mips.com>

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.

Gbp-Pq: Name pr22770-v3.patch
gold/mips.cc