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>
Sun, 8 Apr 2018 20:55:34 +0000 (21:55 +0100)
commit9c0a12e2d34c9f8c318fa8cb41105f89b487dd35
tree13d12b813aecb19b8b6ab9b2535d37b008397c96
parent9d2fb8c96eb74bb593c8696cd2d76cbe16bbc8b7
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