[PATCH][gold] gold/PR16711 Linker script causes gold to include .bss in output file.

Igor Kudrin ikudrin@accesssoftek.com
Fri Oct 21 11:26:00 GMT 2016


If a linker script is used, all output sections of a segment are stored
in the first item of output_lists_. On the other hand, when calculating
the file size of segments, gold adds sections from all chunks of
output_lists_ up to index ORDER_SMALL_BSS. As a result, if a linker
script with SECTIONS clause is used, all the sections contribute to the
file size of the segment, even though some of them might be BSS.

This patch addresses the issue by analyzing section types, excluding
BSS sections at the end of the sequence from contributing to the file
offset, regardless of their index in output_lists_.

Best regards,
Igor Kudrin


	* output.cc (Output_segment::set_section_addresses):
	Handle file and memory offsets separatelly.
	(Output_segment::set_section_list_addresses): Ignore BSS
	segments at the end of the list for file offsets.
	* output.h (Output_segment::set_section_list_addresses):
	New argument poff_file; rename argument poff to poff_mem.
	* testsuite/Makefile.am (pr16711): New test.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/pr16711.s: New test source file.
	* testsuite/pr16711.sh: New test script.
	* testsuite/pr16711.t: New test linker script.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: gold-pr16711-segment-with-bss.patch.txt
URL: <https://sourceware.org/pipermail/binutils/attachments/20161021/662ffa46/attachment.txt>

More information about the Binutils mailing list