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_relro, bool is_reloc)
{
// We should not see any input sections after we have attached
// sections to segments.
flags = this->get_output_section_flags(flags);
- if (this->script_options_->saw_sections_clause())
+ if (this->script_options_->saw_sections_clause() && !is_reloc)
{
// We are using a SECTIONS clause, so the output section is
// chosen based only on the name.
{
os = this->choose_output_section(object, name, sh_type,
shdr.get_sh_flags(), true,
- ORDER_INVALID, false);
+ ORDER_INVALID, false, false);
}
else
{
|| (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);
+ ORDER_INVALID, false, true);
else
{
const char* n = this->namepool_.add(name.c_str(), true, NULL);
Output_section* os = this->choose_output_section(object, ".eh_frame",
elfcpp::SHT_PROGBITS,
elfcpp::SHF_ALLOC, false,
- ORDER_EHFRAME, false);
+ ORDER_EHFRAME, false, false);
if (os == NULL)
return NULL;
this->choose_output_section(NULL, ".eh_frame_hdr",
elfcpp::SHT_PROGBITS,
elfcpp::SHF_ALLOC, false,
- ORDER_EHFRAME, false);
+ ORDER_EHFRAME, false, false);
if (hdr_os != NULL)
{
Output_section* os = this->choose_output_section(NULL, ".gdb_index",
elfcpp::SHT_PROGBITS, 0,
false, ORDER_INVALID,
- false);
+ false, false);
if (os == NULL)
return;
Output_section_order order, bool is_relro)
{
Output_section* os = this->choose_output_section(NULL, name, type, flags,
- false, order, is_relro);
+ false, order, is_relro,
+ false);
if (os != NULL)
os->add_output_section_data(posd);
return os;
(elfcpp::SHF_ALLOC
| elfcpp::SHF_WRITE),
false, ORDER_RELRO,
- true);
+ true, false);
// A linker script may discard .dynamic, so check for NULL.
if (this->dynamic_section_ != NULL)
}
Output_section* os = this->choose_output_section(NULL, section_name,
elfcpp::SHT_NOTE,
- flags, false, order, false);
+ flags, false, order, false,
+ false);
if (os == NULL)
return NULL;
elfcpp::SHF_ALLOC,
false,
ORDER_DYNAMIC_LINKER,
- false);
+ false, false);
// Check for NULL as a linker script may discard .dynsym.
if (dynsym != NULL)
this->choose_output_section(NULL, ".dynsym_shndx",
elfcpp::SHT_SYMTAB_SHNDX,
elfcpp::SHF_ALLOC,
- false, ORDER_DYNAMIC_LINKER, false);
+ false, ORDER_DYNAMIC_LINKER, false, false);
if (dynsym_xindex != NULL)
{
elfcpp::SHF_ALLOC,
false,
ORDER_DYNAMIC_LINKER,
- false);
+ false, false);
*pdynstr = dynstr;
if (dynstr != NULL)
{
Output_section* hashsec =
this->choose_output_section(NULL, ".gnu.hash", elfcpp::SHT_GNU_HASH,
elfcpp::SHF_ALLOC, false,
- ORDER_DYNAMIC_LINKER, false);
+ ORDER_DYNAMIC_LINKER, false, false);
Output_section_data* hashdata = new Output_data_const_buffer(phash,
hashlen,
Output_section* hashsec =
this->choose_output_section(NULL, ".hash", elfcpp::SHT_HASH,
elfcpp::SHF_ALLOC, false,
- ORDER_DYNAMIC_LINKER, false);
+ ORDER_DYNAMIC_LINKER, false, false);
Output_section_data* hashdata = new Output_data_const_buffer(phash,
hashlen,
elfcpp::SHF_ALLOC,
false,
ORDER_DYNAMIC_LINKER,
- false);
+ false, false);
// Check for NULL since a linker script may discard this section.
if (vsec != NULL)
vdsec = this->choose_output_section(NULL, ".gnu.version_d",
elfcpp::SHT_GNU_verdef,
elfcpp::SHF_ALLOC,
- false, ORDER_DYNAMIC_LINKER, false);
+ false, ORDER_DYNAMIC_LINKER, false,
+ false);
if (vdsec != NULL)
{
vnsec = this->choose_output_section(NULL, ".gnu.version_r",
elfcpp::SHT_GNU_verneed,
elfcpp::SHF_ALLOC,
- false, ORDER_DYNAMIC_LINKER, false);
+ false, ORDER_DYNAMIC_LINKER, false,
+ false);
if (vnsec != NULL)
{
elfcpp::SHT_PROGBITS,
elfcpp::SHF_ALLOC,
false, ORDER_INTERP,
- false);
+ false, false);
if (osec != NULL)
osec->add_output_section_data(odata);
}