+2008-05-05 Ian Lance Taylor <iant@google.com>
+
+ * object.cc (Sized_relobj::include_section_group): Adjust section
+ indexes read from group data. Build vector to pass to
+ layout_group.
+ * layout.cc (Layout::layout_group): Add flags and shndxes
+ parameters. Remove contents parameter. Change caller. Update
+ explicit instantiations.
+ * layout.h (class Layout): Update layout_group declaration.
+ * output.cc (Output_data_group::Output_data_group): Add flags and
+ input_shndxes parameters. Remove contents parameter. Change
+ caller.
+ (Output_data_group::do_write): Change input_sections_ to
+ input_shndxes_.
+ * output.h (class Output_data_group): Update constructor
+ declaration. Rename input_sections_ to input_shndxes_.
+ * testsuite/many_sections_test.cc: Add template.
+
2008-04-30 Cary Coutant <ccoutant@google.com>
* target-reloc.h (relocate_section): Fix dead-pointer bug.
const char* group_section_name,
const char* signature,
const elfcpp::Shdr<size, big_endian>& shdr,
- const elfcpp::Elf_Word* contents)
+ elfcpp::Elf_Word flags,
+ std::vector<unsigned int>* shndxes)
{
gold_assert(parameters->options().relocatable());
gold_assert(shdr.get_sh_type() == elfcpp::SHT_GROUP);
section_size_type entry_count =
convert_to_section_size_type(shdr.get_sh_size() / 4);
Output_section_data* posd =
- new Output_data_group<size, big_endian>(object, entry_count, contents);
+ new Output_data_group<size, big_endian>(object, entry_count, flags,
+ shndxes);
os->add_output_section_data(posd);
}
const char* group_section_name,
const char* signature,
const elfcpp::Shdr<32, false>& shdr,
- const elfcpp::Elf_Word* contents);
+ elfcpp::Elf_Word flags,
+ std::vector<unsigned int>* shndxes);
#endif
#ifdef HAVE_TARGET_32_BIG
const char* group_section_name,
const char* signature,
const elfcpp::Shdr<32, true>& shdr,
- const elfcpp::Elf_Word* contents);
+ elfcpp::Elf_Word flags,
+ std::vector<unsigned int>* shndxes);
#endif
#ifdef HAVE_TARGET_64_LITTLE
const char* group_section_name,
const char* signature,
const elfcpp::Shdr<64, false>& shdr,
- const elfcpp::Elf_Word* contents);
+ elfcpp::Elf_Word flags,
+ std::vector<unsigned int>* shndxes);
#endif
#ifdef HAVE_TARGET_64_BIG
const char* group_section_name,
const char* signature,
const elfcpp::Shdr<64, true>& shdr,
- const elfcpp::Elf_Word* contents);
+ elfcpp::Elf_Word flags,
+ std::vector<unsigned int>* shndxes);
#endif
#ifdef HAVE_TARGET_32_LITTLE
const char* group_section_name,
const char* signature,
const elfcpp::Shdr<size, big_endian>& shdr,
- const elfcpp::Elf_Word* contents);
+ elfcpp::Elf_Word flags,
+ std::vector<unsigned int>* shndxes);
// Like layout, only for exception frame sections. OBJECT is an
// object file. SYMBOLS is the contents of the symbol table
bool include_group = ((flags & elfcpp::GRP_COMDAT) == 0
|| layout->add_comdat(this, index, signature, true));
- if (include_group && parameters->options().relocatable())
- layout->layout_group(symtab, this, index, name, signature.c_str(),
- shdr, pword);
-
Relobj* kept_object = NULL;
Comdat_group* kept_group = NULL;
}
size_t count = shdr.get_sh_size() / sizeof(elfcpp::Elf_Word);
+
+ std::vector<unsigned int> shndxes;
+ bool relocate_group = include_group && parameters->options().relocatable();
+ if (relocate_group)
+ shndxes.reserve(count - 1);
+
for (size_t i = 1; i < count; ++i)
{
elfcpp::Elf_Word secnum =
- elfcpp::Swap<32, big_endian>::readval(pword + i);
+ this->adjust_shndx(elfcpp::Swap<32, big_endian>::readval(pword + i));
+
+ if (relocate_group)
+ shndxes.push_back(secnum);
+
if (secnum >= this->shnum())
{
this->error(_("section %u in section group %u out of range"),
}
}
+ if (relocate_group)
+ layout->layout_group(symtab, this, index, name, signature.c_str(),
+ shdr, flags, &shndxes);
+
return include_group;
}
Output_data_group<size, big_endian>::Output_data_group(
Sized_relobj<size, big_endian>* relobj,
section_size_type entry_count,
- const elfcpp::Elf_Word* contents)
+ elfcpp::Elf_Word flags,
+ std::vector<unsigned int>* input_shndxes)
: Output_section_data(entry_count * 4, 4),
- relobj_(relobj)
+ relobj_(relobj),
+ flags_(flags)
{
- this->flags_ = elfcpp::Swap<32, big_endian>::readval(contents);
- for (section_size_type i = 1; i < entry_count; ++i)
- {
- unsigned int shndx = elfcpp::Swap<32, big_endian>::readval(contents + i);
- this->input_sections_.push_back(shndx);
- }
+ this->input_shndxes_.swap(*input_shndxes);
}
// Write out the section group, which means translating the section
++contents;
for (std::vector<unsigned int>::const_iterator p =
- this->input_sections_.begin();
- p != this->input_sections_.end();
+ this->input_shndxes_.begin();
+ p != this->input_shndxes_.end();
++p, ++contents)
{
section_offset_type dummy;
of->write_output_view(off, oview_size, oview);
// We no longer need this information.
- this->input_sections_.clear();
+ this->input_shndxes_.clear();
}
// Output_data_got::Got_entry methods.
class Output_data_group : public Output_section_data
{
public:
+ // The constructor clears *INPUT_SHNDXES.
Output_data_group(Sized_relobj<size, big_endian>* relobj,
section_size_type entry_count,
- const elfcpp::Elf_Word* contents);
+ elfcpp::Elf_Word flags,
+ std::vector<unsigned int>* input_shndxes);
void
do_write(Output_file*);
// The group flag word.
elfcpp::Elf_Word flags_;
// The section indexes of the input sections in this group.
- std::vector<unsigned int> input_sections_;
+ std::vector<unsigned int> input_shndxes_;
};
// Output_data_got is used to manage a GOT. Each entry in the GOT is
#include "many_sections_define.h"
+// This tests a section group.
+template<typename T>
+class C
+{
+ public:
+ static T val() { return C::val_; }
+ private:
+ static T val_;
+};
+
+template<typename T>
+T C<T>::val_;
+
int
main(int, char**)
{
#include "many_sections_check.h"
+ assert(C<int>::val() == 0);
return 0;
}