* 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.
This commit is contained in:
Ian Lance Taylor 2008-05-05 19:16:43 +00:00
parent b3dc826bc7
commit 8825ac63ef
7 changed files with 73 additions and 25 deletions

View File

@ -1,3 +1,21 @@
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.

View File

@ -503,7 +503,8 @@ Layout::layout_group(Symbol_table* symtab,
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);
@ -531,7 +532,8 @@ Layout::layout_group(Symbol_table* symtab,
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);
}
@ -3258,7 +3260,8 @@ Layout::layout_group<32, false>(Symbol_table* symtab,
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
@ -3270,7 +3273,8 @@ Layout::layout_group<32, true>(Symbol_table* symtab,
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
@ -3282,7 +3286,8 @@ Layout::layout_group<64, false>(Symbol_table* symtab,
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
@ -3294,7 +3299,8 @@ Layout::layout_group<64, true>(Symbol_table* symtab,
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

View File

@ -125,7 +125,8 @@ class Layout
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

View File

@ -604,10 +604,6 @@ Sized_relobj<size, big_endian>::include_section_group(
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;
@ -629,10 +625,20 @@ Sized_relobj<size, big_endian>::include_section_group(
}
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"),
@ -681,6 +687,10 @@ Sized_relobj<size, big_endian>::include_section_group(
}
}
if (relocate_group)
layout->layout_group(symtab, this, index, name, signature.c_str(),
shdr, flags, &shndxes);
return include_group;
}

View File

@ -997,16 +997,13 @@ template<int size, bool big_endian>
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
@ -1026,8 +1023,8 @@ Output_data_group<size, big_endian>::do_write(Output_file* of)
++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;
@ -1052,7 +1049,7 @@ Output_data_group<size, big_endian>::do_write(Output_file* of)
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.

View File

@ -1346,9 +1346,11 @@ template<int size, bool big_endian>
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*);
@ -1359,7 +1361,7 @@ class Output_data_group : public Output_section_data
// 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

View File

@ -29,9 +29,23 @@
#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;
}