gold patch committed: Fix some linker script issues with -n

Ian Lance Taylor iant@google.com
Fri Oct 16 05:04:00 GMT 2009


While experimenting with linker scripts, I found some issues when
using a linker script which starts at address 0 when using -n.

The first is that emitting the file headers may cause the file to be
misaligned with regard to what the first segment expects.  This is a
problem because the linker script assumes that the segment starts at
address zero, so it's possible for the alignment of the sections to
not match the alignment of the file offsets.  I fixed this by aligning
the file offset in this case.

The second is that gold simply crashes with a gold_unreachable if dot
moves backward when using a linker script.  I fixed this by producing
a more useful error message when using a linker script.

The third is that SHF_TLS/SHT_NOBITS sections do not take up any
address space, but the linker script calculations were not taking that
into account.

Committed.

Ian


2009-10-15  Ian Lance Taylor  <iant@google.com>

	* layout.cc (Layout::set_segment_offsets): Align the file offset
	to the segment aligment for -N or -n with no load segment.
	* output.cc (Output_segment::add_output_section): Don't crash if
	the first section is a TLS section.
	(Output_segment::set_section_list_addresses): Print an error
	message if the address moves backward in a linker script.
	* script-sections.cc
	(Output_section_element_input::set_section_addresses): Don't
	increase *dot_value for a SHF_TLS/SHT_NOBITS section.
	(Orphan_output_section::set_section_addresses): Likewise.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch
Type: text/x-diff
Size: 6872 bytes
Desc: script with -n
URL: <https://sourceware.org/pipermail/binutils/attachments/20091016/ec078c00/attachment.bin>


More information about the Binutils mailing list