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>
Fri, 22 Jun 2018 06:11:21 +0000 (07:11 +0100)
commit5ba0c285f95b129f9aa04ef4d846694aaa24c02d
treefb3ceb3b33a69dc1e91c2b1514341409d6a452a7
parentad9532872c7934bed5188a18a0f7cd60a74b1a2b
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