From 10b4f10252b11483486df1be14037c1dd4c554bb Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 17 Jun 2011 13:00:01 +0000 Subject: PR gold/12880 * layout.h (class Layout): Add interp_segment_ field. * layout.cc (Layout::Layout): Initialize interp_segment_ field. (Layout::attach_allocated_section_to_segment): If making shared library, put .interp section in PT_INTERP segment. (Layout::finalize): Also call create_interp if -dynamic-linker option was used. (Layout::create_interp): Assert that there is no PT_INTERP segment. If not using a SECTIONS clause, use make_output_section. (Layout::make_output_segment): Set interp_segment_ if PT_INTERP. * script-sections.cc (Script_sections::create_note_and_tls_segments): If making shared library, put .interp section in PT_INTERP segment. --- gold/script-sections.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gold/script-sections.cc') diff --git a/gold/script-sections.cc b/gold/script-sections.cc index 3bcc9e6ada..67e3d65db7 100644 --- a/gold/script-sections.cc +++ b/gold/script-sections.cc @@ -3936,6 +3936,21 @@ Script_sections::create_note_and_tls_segments( saw_tls = true; } + + // If we are making a shared library, and we see a section named + // .interp, and the -dynamic-linker option was not used, then + // put the .interp section in a PT_INTERP segment. This is for + // GNU ld compatibility. + if (strcmp((*p)->name(), ".interp") == 0 + && parameters->options().shared() + && parameters->options().dynamic_linker() == NULL) + { + elfcpp::Elf_Word seg_flags = + Layout::section_flags_to_segment((*p)->flags()); + Output_segment* oseg = layout->make_output_segment(elfcpp::PT_INTERP, + seg_flags); + oseg->add_output_section_to_nonload(*p, seg_flags); + } } } -- cgit v1.2.3