aboutsummaryrefslogtreecommitdiff
path: root/gold/layout.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gold/layout.cc')
-rw-r--r--gold/layout.cc52
1 files changed, 31 insertions, 21 deletions
diff --git a/gold/layout.cc b/gold/layout.cc
index 0852270..de0384b 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -903,7 +903,7 @@ Layout::keep_input_section(const Relobj* relobj, const char* name)
bool keep;
name = ss->output_section_name(file_name, name, &output_section_slot,
- &script_section_type, &keep);
+ &script_section_type, &keep, true);
return name != NULL && keep;
}
@@ -935,13 +935,16 @@ Layout::get_output_section_flags(elfcpp::Elf_Xword input_section_flags)
// choosing an output section for an input section found in a input
// file. ORDER is where this section should appear in the output
// sections. IS_RELRO is true for a relro section. This will return
-// NULL if the input section should be discarded.
+// NULL if the input section should be discarded. MATCH_INPUT_SPEC
+// is true if the section name should be matched against input specs
+// in a linker script.
Output_section*
Layout::choose_output_section(const Relobj* relobj, const char* name,
elfcpp::Elf_Word type, elfcpp::Elf_Xword flags,
bool is_input_section, Output_section_order order,
- bool is_relro, bool is_reloc)
+ bool is_relro, bool is_reloc,
+ bool match_input_spec)
{
// We should not see any input sections after we have attached
// sections to segments.
@@ -961,7 +964,8 @@ Layout::choose_output_section(const Relobj* relobj, const char* name,
const char* orig_name = name;
bool keep;
name = ss->output_section_name(file_name, name, &output_section_slot,
- &script_section_type, &keep);
+ &script_section_type, &keep,
+ match_input_spec);
if (name == NULL)
{
@@ -1184,7 +1188,8 @@ Layout::layout(Sized_relobj_file<size, big_endian>* object, unsigned int shndx,
{
os = this->choose_output_section(object, name, sh_type,
shdr.get_sh_flags(), true,
- ORDER_INVALID, false, false);
+ ORDER_INVALID, false, false,
+ true);
}
else
{
@@ -1313,7 +1318,7 @@ Layout::layout_reloc(Sized_relobj_file<size, big_endian>* object,
|| (data_section->flags() & elfcpp::SHF_GROUP) == 0)
os = this->choose_output_section(object, name.c_str(), sh_type,
shdr.get_sh_flags(), false,
- ORDER_INVALID, false, true);
+ ORDER_INVALID, false, true, false);
else
{
const char* n = this->namepool_.add(name.c_str(), true, NULL);
@@ -1506,7 +1511,8 @@ Layout::make_eh_frame_section(const Relobj* object)
Output_section* os = this->choose_output_section(object, ".eh_frame",
elfcpp::SHT_PROGBITS,
elfcpp::SHF_ALLOC, false,
- ORDER_EHFRAME, false, false);
+ ORDER_EHFRAME, false, false,
+ false);
if (os == NULL)
return NULL;
@@ -1523,7 +1529,8 @@ Layout::make_eh_frame_section(const Relobj* object)
this->choose_output_section(NULL, ".eh_frame_hdr",
elfcpp::SHT_PROGBITS,
elfcpp::SHF_ALLOC, false,
- ORDER_EHFRAME, false, false);
+ ORDER_EHFRAME, false, false,
+ false);
if (hdr_os != NULL)
{
@@ -1592,7 +1599,7 @@ Layout::add_to_gdb_index(bool is_type_unit,
Output_section* os = this->choose_output_section(NULL, ".gdb_index",
elfcpp::SHT_PROGBITS, 0,
false, ORDER_INVALID,
- false, false);
+ false, false, false);
if (os == NULL)
return;
@@ -1617,7 +1624,7 @@ Layout::add_output_section_data(const char* name, elfcpp::Elf_Word type,
{
Output_section* os = this->choose_output_section(NULL, name, type, flags,
false, order, is_relro,
- false);
+ false, false);
if (os != NULL)
os->add_output_section_data(posd);
return os;
@@ -2158,7 +2165,7 @@ Layout::create_initial_dynamic_sections(Symbol_table* symtab)
(elfcpp::SHF_ALLOC
| elfcpp::SHF_WRITE),
false, ORDER_RELRO,
- true, false);
+ true, false, false);
// A linker script may discard .dynamic, so check for NULL.
if (this->dynamic_section_ != NULL)
@@ -2941,7 +2948,7 @@ Layout::create_note(const char* name, int note_type,
Output_section* os = this->choose_output_section(NULL, section_name,
elfcpp::SHT_NOTE,
flags, false, order, false,
- false);
+ false, true);
if (os == NULL)
return NULL;
@@ -4299,7 +4306,7 @@ Layout::create_dynamic_symtab(const Input_objects* input_objects,
elfcpp::SHF_ALLOC,
false,
ORDER_DYNAMIC_LINKER,
- false, false);
+ false, false, false);
// Check for NULL as a linker script may discard .dynsym.
if (dynsym != NULL)
@@ -4336,7 +4343,8 @@ Layout::create_dynamic_symtab(const Input_objects* input_objects,
this->choose_output_section(NULL, ".dynsym_shndx",
elfcpp::SHT_SYMTAB_SHNDX,
elfcpp::SHF_ALLOC,
- false, ORDER_DYNAMIC_LINKER, false, false);
+ false, ORDER_DYNAMIC_LINKER, false, false,
+ false);
if (dynsym_xindex != NULL)
{
@@ -4364,7 +4372,7 @@ Layout::create_dynamic_symtab(const Input_objects* input_objects,
elfcpp::SHF_ALLOC,
false,
ORDER_DYNAMIC_LINKER,
- false, false);
+ false, false, false);
*pdynstr = dynstr;
if (dynstr != NULL)
{
@@ -4398,7 +4406,8 @@ Layout::create_dynamic_symtab(const Input_objects* input_objects,
Output_section* hashsec =
this->choose_output_section(NULL, ".gnu.hash", elfcpp::SHT_GNU_HASH,
elfcpp::SHF_ALLOC, false,
- ORDER_DYNAMIC_LINKER, false, false);
+ ORDER_DYNAMIC_LINKER, false, false,
+ false);
Output_section_data* hashdata = new Output_data_const_buffer(phash,
hashlen,
@@ -4434,7 +4443,8 @@ Layout::create_dynamic_symtab(const Input_objects* input_objects,
Output_section* hashsec =
this->choose_output_section(NULL, ".hash", elfcpp::SHT_HASH,
elfcpp::SHF_ALLOC, false,
- ORDER_DYNAMIC_LINKER, false, false);
+ ORDER_DYNAMIC_LINKER, false, false,
+ false);
Output_section_data* hashdata = new Output_data_const_buffer(phash,
hashlen,
@@ -4541,7 +4551,7 @@ Layout::sized_create_version_sections(
elfcpp::SHF_ALLOC,
false,
ORDER_DYNAMIC_LINKER,
- false, false);
+ false, false, false);
// Check for NULL since a linker script may discard this section.
if (vsec != NULL)
@@ -4573,7 +4583,7 @@ Layout::sized_create_version_sections(
elfcpp::SHT_GNU_verdef,
elfcpp::SHF_ALLOC,
false, ORDER_DYNAMIC_LINKER, false,
- false);
+ false, false);
if (vdsec != NULL)
{
@@ -4606,7 +4616,7 @@ Layout::sized_create_version_sections(
elfcpp::SHT_GNU_verneed,
elfcpp::SHF_ALLOC,
false, ORDER_DYNAMIC_LINKER, false,
- false);
+ false, false);
if (vnsec != NULL)
{
@@ -4655,7 +4665,7 @@ Layout::create_interp(const Target* target)
elfcpp::SHT_PROGBITS,
elfcpp::SHF_ALLOC,
false, ORDER_INTERP,
- false, false);
+ false, false, false);
if (osec != NULL)
osec->add_output_section_data(odata);
}