Fix SIZEOF_HEADERS in gold.

Gold undercounts the number of program headers it's going to add when
initially evaluating the SIZEOF_HEADERS expression. As a result, scripts
that use it end up skipping a page unnecessarily when the starting address
is too low. The undercounting is because it doesn't count the PT_INTERP
segment.

Then, when finalizing symbols, gold overcounts the program headers: all
segments have already been created, but we still count the headers we
expected to add from the script.

This patch fixes both problems.

gold/
	* script-sections.cc (Script_sections::Script_sections): Initialize
	segments_created_.
	(Script_sections::create_note_and_tls_segments): Set flag when
	segments are created.
	(Script_sections::expected_segment_count): Count PT_INTERP.
	(Script_sections::attach_sections_using_phdrs_clause): Set flag when
	segments are created.
	* script-sections.h (Script_sections::segments_created_): New data
	member.
This commit is contained in:
Cary Coutant 2015-06-03 20:30:11 -07:00
parent 374082dfab
commit 8086551f52
3 changed files with 35 additions and 3 deletions

View file

@ -319,6 +319,8 @@ class Script_sections
bool saw_relro_end_;
// Whether we have seen SEGMENT_START.
bool saw_segment_start_expression_;
// Whether we have created all necessary segments.
bool segments_created_;
};
// Attributes for memory regions.