aboutsummaryrefslogtreecommitdiff
path: root/gold/layout.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2009-07-17 01:07:33 +0000
committerIan Lance Taylor <ian@airs.com>2009-07-17 01:07:33 +0000
commit1ef4d87fe8cce2596a7d1d1c458db1b11c2c5d0e (patch)
treeedd1a6b59a6e7c8e7b3595d860859e4b28ec002a /gold/layout.cc
parent98472ae205bbd9266bfe49d112275ede7ea8fe78 (diff)
downloadgdb-1ef4d87fe8cce2596a7d1d1c458db1b11c2c5d0e.zip
gdb-1ef4d87fe8cce2596a7d1d1c458db1b11c2c5d0e.tar.gz
gdb-1ef4d87fe8cce2596a7d1d1c458db1b11c2c5d0e.tar.bz2
PR 10400
* 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.
Diffstat (limited to 'gold/layout.cc')
-rw-r--r--gold/layout.cc61
1 files changed, 29 insertions, 32 deletions
diff --git a/gold/layout.cc b/gold/layout.cc
index e8625d2..0093c29 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -3045,16 +3045,18 @@ Layout::output_section_name(const char* name, size_t* plen)
// Check if a comdat group or .gnu.linkonce section with the given
// NAME is selected for the link. If there is already a section,
-// *KEPT_SECTION is set to point to the signature and the function
-// returns false. Otherwise, the CANDIDATE signature is recorded for
-// this NAME in the layout object, *KEPT_SECTION is set to the
-// internal copy and the function return false. In some cases, with
-// CANDIDATE->GROUP_ being false, KEPT_SECTION can point back to
-// CANDIDATE.
+// *KEPT_SECTION is set to point to the existing section and the
+// function returns false. Otherwise, OBJECT, SHNDX, IS_COMDAT, and
+// IS_GROUP_NAME are recorded for this NAME in the layout object,
+// *KEPT_SECTION is set to the internal copy and the function returns
+// true.
bool
Layout::find_or_add_kept_section(const std::string& name,
- Kept_section* candidate,
+ Relobj* object,
+ unsigned int shndx,
+ bool is_comdat,
+ bool is_group_name,
Kept_section** kept_section)
{
// It's normal to see a couple of entries here, for the x86 thunk
@@ -3068,36 +3070,46 @@ Layout::find_or_add_kept_section(const std::string& name,
this->resized_signatures_ = true;
}
- std::pair<Signatures::iterator, bool> ins(
- this->signatures_.insert(std::make_pair(name, *candidate)));
+ Kept_section candidate;
+ std::pair<Signatures::iterator, bool> ins =
+ this->signatures_.insert(std::make_pair(name, candidate));
- if (kept_section)
+ if (kept_section != NULL)
*kept_section = &ins.first->second;
if (ins.second)
{
// This is the first time we've seen this signature.
+ ins.first->second.set_object(object);
+ ins.first->second.set_shndx(shndx);
+ if (is_comdat)
+ ins.first->second.set_is_comdat();
+ if (is_group_name)
+ ins.first->second.set_is_group_name();
return true;
}
- if (ins.first->second.is_group)
+ // We have already seen this signature.
+
+ if (ins.first->second.is_group_name())
{
// We've already seen a real section group with this signature.
- // If the kept group is from a plugin object, and we're in
- // the replacement phase, accept the new one as a replacement.
- if (ins.first->second.object == NULL
+ // If the kept group is from a plugin object, and we're in the
+ // replacement phase, accept the new one as a replacement.
+ if (ins.first->second.object() == NULL
&& parameters->options().plugins()->in_replacement_phase())
{
- ins.first->second = *candidate;
+ ins.first->second.set_object(object);
+ ins.first->second.set_shndx(shndx);
return true;
}
return false;
}
- else if (candidate->is_group)
+ else if (is_group_name)
{
// This is a real section group, and we've already seen a
// linkonce section with this signature. Record that we've seen
// a section group, and don't include this section group.
- ins.first->second.is_group = true;
+ ins.first->second.set_is_group_name();
return false;
}
else
@@ -3105,25 +3117,10 @@ Layout::find_or_add_kept_section(const std::string& name,
// We've already seen a linkonce section and this is a linkonce
// section. These don't block each other--this may be the same
// symbol name with different section types.
- *kept_section = candidate;
return true;
}
}
-// Find the given comdat signature, and return the object and section
-// index of the kept group.
-Relobj*
-Layout::find_kept_object(const std::string& signature,
- unsigned int* pshndx) const
-{
- Signatures::const_iterator p = this->signatures_.find(signature);
- if (p == this->signatures_.end())
- return NULL;
- if (pshndx != NULL)
- *pshndx = p->second.shndx;
- return p->second.object;
-}
-
// Store the allocated sections into the section list.
void