* layout.h: #include <map>.
	(class Kept_section): Change from struct to class.  Add accessors
	and setters.  Add section size to Comdat_group mapping.  Change
	Comdat_group to std::map.  Add is_comdat_ field.  Add
	linkonce_size field in union.
	(class Layout): Update declaration of find_or_add_kept_section.
	Don't declare find_kept_object.
	* layout.cc (Layout::find_or_add_kept_section): Remove candidate
	parameter.  Add object, shndx, is_comdat, and is_group_name
	parameters.  Change all callers.  Adjust for new Kept_section.
	(Layout::find_kept_object): Remove.
	* object.cc (Sized_relobj::include_section_group): Update use of
	Kept_section.  Rename secnum to shndx.  Only record
	Kept_comdat_section if sections are the same size.
	(Sized_relobj::include_linkonce_section): Update use of
	Kept_section.  Only record Kept_comdat_section if sections are the
	same size.  Set size of linkonce section.
	(Sized_relobj::map_to_kept_section): Update call to
	get_kept_comdat_section.
	* object.h (class Sized_relobj): Rename fields in
	Kept_comdat_section to drop trailing underscores; change object
	field to Relobj*.  Change Kept_comdat_section_table to store
	struct rather than pointer.
	(Sized_relobj::set_kept_comdat_section): Remove kept parameter.
	Add kept_object and kept_shndx parameters.  Change all callers.
	(Sized_relobj::get_kept_comdat_section): Change return type to
	bool.  Add kept_object and kept_shndx parameters.  Change all
	callers.
	* plugin.cc (Pluginobj::include_comdat_group): Update call to
	Layout::find_or_add_kept_section.
This commit is contained in:
Ian Lance Taylor
2009-07-17 01:07:33 +00:00
parent 98472ae205
commit 1ef4d87fe8
6 changed files with 365 additions and 164 deletions

View File

@@ -1590,14 +1590,13 @@ class Sized_relobj : public Relobj
// kept section.
struct Kept_comdat_section
{
Kept_comdat_section(Sized_relobj<size, big_endian>* object,
unsigned int shndx)
: object_(object), shndx_(shndx)
Kept_comdat_section(Relobj* a_object, unsigned int a_shndx)
: object(a_object), shndx(a_shndx)
{ }
Sized_relobj<size, big_endian>* object_;
unsigned int shndx_;
Relobj* object;
unsigned int shndx;
};
typedef std::map<unsigned int, Kept_comdat_section*>
typedef std::map<unsigned int, Kept_comdat_section>
Kept_comdat_section_table;
// Adjust a section index if necessary.
@@ -1729,20 +1728,26 @@ class Sized_relobj : public Relobj
// Record a mapping from discarded section SHNDX to the corresponding
// kept section.
void
set_kept_comdat_section(unsigned int shndx, Kept_comdat_section* kept)
set_kept_comdat_section(unsigned int shndx, Relobj* kept_object,
unsigned int kept_shndx)
{
this->kept_comdat_sections_[shndx] = kept;
Kept_comdat_section kept(kept_object, kept_shndx);
this->kept_comdat_sections_.insert(std::make_pair(shndx, kept));
}
// Find the kept section corresponding to the discarded section SHNDX.
Kept_comdat_section*
get_kept_comdat_section(unsigned int shndx) const
// Find the kept section corresponding to the discarded section
// SHNDX. Return true if found.
bool
get_kept_comdat_section(unsigned int shndx, Relobj** kept_object,
unsigned int* kept_shndx) const
{
typename Kept_comdat_section_table::const_iterator p =
this->kept_comdat_sections_.find(shndx);
if (p == this->kept_comdat_sections_.end())
return NULL;
return p->second;
return false;
*kept_object = p->second.object;
*kept_shndx = p->second.shndx;
return true;
}
// The GOT offsets of local symbols. This map also stores GOT offsets