mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-18 00:32:30 +08:00
PR gold/12880
* layout.cc (Layout::attach_allocated_section_to_segment): Add a .interp section to a PT_INTERP segment even if we have seen a --dynamic-linker option. Don't do it if we have seen a PHDRS clause in a linker script. (Layout::finalize): Don't create a .interp section if we've already create a PT_INTERP segment. (Layout::create_interp): Always call choose_output_section (revert patch of 2011-06-17). Don't create PT_INTERP segment. * script-sections.cc (Script_sections::create_note_and_tls_segments): Add a .interp section to a PT_INTERP segment even if we have seen a --dynamic-linker option.
This commit is contained in:
@ -1,3 +1,19 @@
|
|||||||
|
2011-06-19 Ian Lance Taylor <iant@google.com>
|
||||||
|
|
||||||
|
PR gold/12880
|
||||||
|
* layout.cc (Layout::attach_allocated_section_to_segment): Add a
|
||||||
|
.interp section to a PT_INTERP segment even if we have seen a
|
||||||
|
--dynamic-linker option. Don't do it if we have seen a PHDRS
|
||||||
|
clause in a linker script.
|
||||||
|
(Layout::finalize): Don't create a .interp section if we've
|
||||||
|
already create a PT_INTERP segment.
|
||||||
|
(Layout::create_interp): Always call choose_output_section (revert
|
||||||
|
patch of 2011-06-17). Don't create PT_INTERP segment.
|
||||||
|
* script-sections.cc
|
||||||
|
(Script_sections::create_note_and_tls_segments): Add a .interp
|
||||||
|
section to a PT_INTERP segment even if we have seen a
|
||||||
|
--dynamic-linker option.
|
||||||
|
|
||||||
2011-06-18 Ian Lance Taylor <iant@google.com>
|
2011-06-18 Ian Lance Taylor <iant@google.com>
|
||||||
|
|
||||||
* layout.cc (Layout::finish_dynamic_section): Don't set DT_TEXTREL
|
* layout.cc (Layout::finish_dynamic_section): Don't set DT_TEXTREL
|
||||||
|
@ -1547,18 +1547,17 @@ Layout::attach_allocated_section_to_segment(Output_section* os)
|
|||||||
this->relro_segment_->add_output_section_to_nonload(os, seg_flags);
|
this->relro_segment_->add_output_section_to_nonload(os, seg_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are making a shared library, and we see a section named
|
// If we see a section named .interp, put it into a PT_INTERP
|
||||||
// .interp, and the -dynamic-linker option was not used, then put
|
// segment. This seems broken to me, but this is what GNU ld does,
|
||||||
// the .interp section into a PT_INTERP segment. This is for GNU ld
|
// and glibc expects it.
|
||||||
// compatibility. If making an executable, or if the
|
|
||||||
// -dynamic-linker option was used, we will create the section and
|
|
||||||
// segment in Layout::create_interp.
|
|
||||||
if (strcmp(os->name(), ".interp") == 0
|
if (strcmp(os->name(), ".interp") == 0
|
||||||
&& parameters->options().shared()
|
&& !this->script_options_->saw_phdrs_clause())
|
||||||
&& parameters->options().dynamic_linker() == NULL)
|
|
||||||
{
|
{
|
||||||
if (this->interp_segment_ == NULL)
|
if (this->interp_segment_ == NULL)
|
||||||
this->make_output_segment(elfcpp::PT_INTERP, seg_flags);
|
this->make_output_segment(elfcpp::PT_INTERP, seg_flags);
|
||||||
|
else
|
||||||
|
gold_warning(_("multiple '.interp' sections in input files "
|
||||||
|
"may cause confusing PT_INTERP segment"));
|
||||||
this->interp_segment_->add_output_section_to_nonload(os, seg_flags);
|
this->interp_segment_->add_output_section_to_nonload(os, seg_flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2183,9 +2182,11 @@ Layout::finalize(const Input_objects* input_objects, Symbol_table* symtab,
|
|||||||
&versions);
|
&versions);
|
||||||
|
|
||||||
// Create the .interp section to hold the name of the
|
// Create the .interp section to hold the name of the
|
||||||
// interpreter, and put it in a PT_INTERP segment.
|
// interpreter, and put it in a PT_INTERP segment. Don't do it
|
||||||
if (!parameters->options().shared()
|
// if we saw a .interp section in an input file.
|
||||||
|
if ((!parameters->options().shared()
|
||||||
|| parameters->options().dynamic_linker() != NULL)
|
|| parameters->options().dynamic_linker() != NULL)
|
||||||
|
&& this->interp_segment_ == NULL)
|
||||||
this->create_interp(target);
|
this->create_interp(target);
|
||||||
|
|
||||||
// Finish the .dynamic section to hold the dynamic data, and put
|
// Finish the .dynamic section to hold the dynamic data, and put
|
||||||
@ -3879,31 +3880,12 @@ Layout::create_interp(const Target* target)
|
|||||||
|
|
||||||
Output_section_data* odata = new Output_data_const(interp, len, 1);
|
Output_section_data* odata = new Output_data_const(interp, len, 1);
|
||||||
|
|
||||||
Output_section* osec;
|
Output_section* osec = this->choose_output_section(NULL, ".interp",
|
||||||
|
elfcpp::SHT_PROGBITS,
|
||||||
// If we are using a SECTIONS clause, let it decide where the
|
elfcpp::SHF_ALLOC,
|
||||||
// .interp section should go. Otherwise always create a new section
|
false, ORDER_INTERP,
|
||||||
// so that this .interp section does not get confused with any
|
|
||||||
// section of the same name in the program.
|
|
||||||
if (this->script_options_->saw_sections_clause())
|
|
||||||
osec = this->choose_output_section(NULL, ".interp", elfcpp::SHT_PROGBITS,
|
|
||||||
elfcpp::SHF_ALLOC, false, ORDER_INTERP,
|
|
||||||
false);
|
false);
|
||||||
else
|
|
||||||
{
|
|
||||||
const char* n = this->namepool_.add("interp", false, NULL);
|
|
||||||
osec = this->make_output_section(n, elfcpp::SHT_PROGBITS,
|
|
||||||
elfcpp::SHF_ALLOC, ORDER_INTERP, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
osec->add_output_section_data(odata);
|
osec->add_output_section_data(odata);
|
||||||
|
|
||||||
if (!this->script_options_->saw_phdrs_clause())
|
|
||||||
{
|
|
||||||
Output_segment* oseg = this->make_output_segment(elfcpp::PT_INTERP,
|
|
||||||
elfcpp::PF_R);
|
|
||||||
oseg->add_output_section_to_nonload(osec, elfcpp::PF_R);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add dynamic tags for the PLT and the dynamic relocs. This is
|
// Add dynamic tags for the PLT and the dynamic relocs. This is
|
||||||
|
@ -3938,12 +3938,9 @@ Script_sections::create_note_and_tls_segments(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we are making a shared library, and we see a section named
|
// If we are making a shared library, and we see a section named
|
||||||
// .interp, and the -dynamic-linker option was not used, then
|
// .interp then put the .interp section in a PT_INTERP segment.
|
||||||
// put the .interp section in a PT_INTERP segment. This is for
|
// This is for GNU ld compatibility.
|
||||||
// GNU ld compatibility.
|
if (strcmp((*p)->name(), ".interp") == 0)
|
||||||
if (strcmp((*p)->name(), ".interp") == 0
|
|
||||||
&& parameters->options().shared()
|
|
||||||
&& parameters->options().dynamic_linker() == NULL)
|
|
||||||
{
|
{
|
||||||
elfcpp::Elf_Word seg_flags =
|
elfcpp::Elf_Word seg_flags =
|
||||||
Layout::section_flags_to_segment((*p)->flags());
|
Layout::section_flags_to_segment((*p)->flags());
|
||||||
|
Reference in New Issue
Block a user