* output.h (class Output_section): Add is_entsize_zero_ field.
	* output.cc (Output_section::Output_section): Initialize
	is_entsize_zero_.
	(Output_section::set_entsize): If two different entsizes are
	requested, force it to zero.
	(Output_section::add_input_section): Set flags for .debug_str
	before updating section flags.  Set entsize.
	(Output_section::update_flags_for_input_section): Set SHF_MERGE
	and SHF_STRING if all input sections have those flags.
This commit is contained in:
Ian Lance Taylor 2009-12-30 04:00:21 +00:00
parent 9037e078d4
commit e8cd95c71e
3 changed files with 45 additions and 6 deletions

View File

@ -1,7 +1,21 @@
2009-12-29 Ian Lance Taylor <iant@google.com>
PR 10450
* output.h (class Output_section): Add is_entsize_zero_ field.
* output.cc (Output_section::Output_section): Initialize
is_entsize_zero_.
(Output_section::set_entsize): If two different entsizes are
requested, force it to zero.
(Output_section::add_input_section): Set flags for .debug_str
before updating section flags. Set entsize.
(Output_section::update_flags_for_input_section): Set SHF_MERGE
and SHF_STRING if all input sections have those flags.
2009-12-29 Rafael Espindola <espindola@google.com> 2009-12-29 Rafael Espindola <espindola@google.com>
* main.cc (main): Fix the sys time reporting. * main.cc (main): Fix the sys time reporting.
* workqueue.cc (Workqueue::find_and_run_task): Fix the sys time reporting. * workqueue.cc (Workqueue::find_and_run_task): Fix the sys time
reporting.
2009-12-29 Sriraman Tallam <tmsriram@google.com> 2009-12-29 Sriraman Tallam <tmsriram@google.com>

View File

@ -1800,6 +1800,7 @@ Output_section::Output_section(const char* name, elfcpp::Elf_Word type,
is_interp_(false), is_interp_(false),
is_dynamic_linker_section_(false), is_dynamic_linker_section_(false),
generate_code_fills_at_write_(false), generate_code_fills_at_write_(false),
is_entsize_zero_(false),
tls_offset_(0), tls_offset_(0),
checkpoint_(NULL), checkpoint_(NULL),
merge_section_map_(), merge_section_map_(),
@ -1824,10 +1825,15 @@ Output_section::~Output_section()
void void
Output_section::set_entsize(uint64_t v) Output_section::set_entsize(uint64_t v)
{ {
if (this->entsize_ == 0) if (this->is_entsize_zero_)
;
else if (this->entsize_ == 0)
this->entsize_ = v; this->entsize_ = v;
else else if (this->entsize_ != v)
gold_assert(this->entsize_ == v); {
this->entsize_ = 0;
this->is_entsize_zero_ = 1;
}
} }
// Add the input section SHNDX, with header SHDR, named SECNAME, in // Add the input section SHNDX, with header SHDR, named SECNAME, in
@ -1863,8 +1869,6 @@ Output_section::add_input_section(Sized_relobj<size, big_endian>* object,
this->addralign_ = addralign; this->addralign_ = addralign;
typename elfcpp::Elf_types<size>::Elf_WXword sh_flags = shdr.get_sh_flags(); typename elfcpp::Elf_types<size>::Elf_WXword sh_flags = shdr.get_sh_flags();
this->update_flags_for_input_section(sh_flags);
uint64_t entsize = shdr.get_sh_entsize(); uint64_t entsize = shdr.get_sh_entsize();
// .debug_str is a mergeable string section, but is not always so // .debug_str is a mergeable string section, but is not always so
@ -1875,6 +1879,9 @@ Output_section::add_input_section(Sized_relobj<size, big_endian>* object,
entsize = 1; entsize = 1;
} }
this->update_flags_for_input_section(sh_flags);
this->set_entsize(entsize);
// If this is a SHF_MERGE section, we pass all the input sections to // If this is a SHF_MERGE section, we pass all the input sections to
// a Output_data_merge. We don't try to handle relocations for such // a Output_data_merge. We don't try to handle relocations for such
// a section. We don't try to handle empty merge sections--they // a section. We don't try to handle empty merge sections--they
@ -2199,6 +2206,22 @@ Output_section::update_flags_for_input_section(elfcpp::Elf_Xword flags)
& (elfcpp::SHF_WRITE & (elfcpp::SHF_WRITE
| elfcpp::SHF_ALLOC | elfcpp::SHF_ALLOC
| elfcpp::SHF_EXECINSTR)); | elfcpp::SHF_EXECINSTR));
if ((flags & elfcpp::SHF_MERGE) == 0)
this->flags_ &=~ elfcpp::SHF_MERGE;
else
{
if (this->current_data_size_for_child() == 0)
this->flags_ |= elfcpp::SHF_MERGE;
}
if ((flags & elfcpp::SHF_STRINGS) == 0)
this->flags_ &=~ elfcpp::SHF_STRINGS;
else
{
if (this->current_data_size_for_child() == 0)
this->flags_ |= elfcpp::SHF_STRINGS;
}
} }
// Find the merge section into which an input section with index SHNDX in // Find the merge section into which an input section with index SHNDX in

View File

@ -3352,6 +3352,8 @@ class Output_section : public Output_data
bool is_dynamic_linker_section_ : 1; bool is_dynamic_linker_section_ : 1;
// Whether code-fills are generated at write. // Whether code-fills are generated at write.
bool generate_code_fills_at_write_ : 1; bool generate_code_fills_at_write_ : 1;
// Whether the entry size field should be zero.
bool is_entsize_zero_ : 1;
// For SHT_TLS sections, the offset of this section relative to the base // For SHT_TLS sections, the offset of this section relative to the base
// of the TLS segment. // of the TLS segment.
uint64_t tls_offset_; uint64_t tls_offset_;