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>
Tue, 29 May 2018 13:46:35 +0000 (14:46 +0100)
commitc9b872368f8723870e8d36e9a740297dab071a55
treeb89399c76af5868d568c9dadaf7a6f2edbd0ff6c
parent3776030cb070db586c48b9ccd40347cfd5d002d3
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