gold patch committed: Put .interp first

Ian Lance Taylor iant@google.com
Wed Nov 4 16:02:00 GMT 2009


I got a report that on FreeBSD the .interp section must be in the
first page of the executable.  That is a good idea anyhow, since it
tends to reduce the reading required by the kernel.  This patch moves
.interp first, followed by allocated non-writable note sections,
followed by other sections used by the dynamic linker.  This is what
the GNU linker does.

While implementing this, I discovered that if the first sections in
the text segment are dynamic relocation sections, that objcopy and
strip fail.  The problem is in copy_elf_program_header: it ignores the
relocation sections when setting first_section, and thus gets the
wrong value for the program header size, and then later fails when it
finds that it can't put the relocation sections at the offset they
need.  I didn't debug it further than that, since this is kind of an
unusual case.

This patch looks large but is almost entirely the mechanical addition
of new parameters.

Committed to mainline and 2.20 branch.

Ian


2009-11-04  Ian Lance Taylor  <iant@google.com>

	* layout.cc (Layout::get_output_section): Add is_interp and
	is_dynamic_linker_section parameters.  Change all callers.
	(Layout::choose_output_section): Likewise.
	(Layout::make_output_section): Likewise.
	(Layout::add_output_section_data): Add is_dynamic_linker_section
	parameter.  Change all callers.
	* layout.h (class Layout): Update declarations.
	* output.h (class Output_section): Add is_interp, set_is_interp,
	is_dynamic_linker_section, set_is_dynamic_linker_section methods.
	Add is_interp_, is_dynamic_linker_section_ fields.  Change
	generate_code_fills_at_write_ to a bitfield.
	* output.cc (Output_section::Output_sections): Initialize new
	fields.
	(Output_segment::add_output_section): Add do_sort parameter.
	Change all callers.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch
Type: text/x-diff
Size: 41103 bytes
Desc: interp first
URL: <https://sourceware.org/pipermail/binutils/attachments/20091104/3401f9b8/attachment.bin>


More information about the Binutils mailing list