aboutsummaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
authorDoug Kwan <dougkwan@google.com>2010-01-20 17:29:52 +0000
committerDoug Kwan <dougkwan@google.com>2010-01-20 17:29:52 +0000
commit5ac169d4b6e2d88c670298a3246fc2a5d8a94aa4 (patch)
tree02c188debc6532be6476d7de9cb86cc6309ea963 /gold
parenta21620630edb456511a2467466814ecffa158b2f (diff)
downloadgdb-5ac169d4b6e2d88c670298a3246fc2a5d8a94aa4.zip
gdb-5ac169d4b6e2d88c670298a3246fc2a5d8a94aa4.tar.gz
gdb-5ac169d4b6e2d88c670298a3246fc2a5d8a94aa4.tar.bz2
2010-01-20 Doug Kwan <dougkwan@google.com>
* arm.cc (Target_arm::Arm_input_section_map): Change key type from Input_section_specifier to Section_id. (Target_arm::new_arm_input_section: Adjust code for change of key type. (Target_arm::find_arm_input_section): Ditto. * gc.h (object.h): Include for Section_id nand Section_id_hash. (Section_id): Remove. (Garbage_collection::Section_id_hash): Remove. * icf.h (object.h): Include for Section_id nand Section_id_hash. (Section_id): Remove. (Icf::Section_id_hash): Remove. * object.h (Section_id, Const_section_id, Section_id_hash, Const_section_id_hash): New type definitions. * output.cc (Output_section::add_relaxed_input_section): Change to use Const_section_id instead of Input_section_specifier as key type. (Output_section::add_merge_input_section): Ditto. (Output_section::build_relaxation_map): Change to use Section_id instead of Input_section_specifier as key type. (Output_section::convert_input_sections_in_list_to_relaxed_sections): Ditto. (Output_section::convert_input_sections_to_relaxed_sections): Change to use Const_section_id instead of Input_section_specifier as key type. (Output_section::find_merge_section): Ditto. (Output_section::find_relaxed_input_section): Ditto. * output.h (Input_section_specifier): Remove class. (Output_section::Output_section_data_by_input_section_map): Change key type to Const_section_id. (Output_section::Output_relaxed_input_section_by_input_section_map): Ditto. (Output_section::Relaxation_map): Change key type to Section_id.
Diffstat (limited to 'gold')
-rw-r--r--gold/ChangeLog33
-rw-r--r--gold/arm.cc13
-rw-r--r--gold/gc.h9
-rw-r--r--gold/icf.h9
-rw-r--r--gold/object.h25
-rw-r--r--gold/output.cc40
-rw-r--r--gold/output.h79
7 files changed, 95 insertions, 113 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 0752d08..af6718a 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,36 @@
+2010-01-20 Doug Kwan <dougkwan@google.com>
+
+ * arm.cc (Target_arm::Arm_input_section_map): Change key type from
+ Input_section_specifier to Section_id.
+ (Target_arm::new_arm_input_section: Adjust code for change of key
+ type.
+ (Target_arm::find_arm_input_section): Ditto.
+ * gc.h (object.h): Include for Section_id nand Section_id_hash.
+ (Section_id): Remove.
+ (Garbage_collection::Section_id_hash): Remove.
+ * icf.h (object.h): Include for Section_id nand Section_id_hash.
+ (Section_id): Remove.
+ (Icf::Section_id_hash): Remove.
+ * object.h (Section_id, Const_section_id, Section_id_hash,
+ Const_section_id_hash): New type definitions.
+ * output.cc (Output_section::add_relaxed_input_section): Change to
+ use Const_section_id instead of Input_section_specifier as key type.
+ (Output_section::add_merge_input_section): Ditto.
+ (Output_section::build_relaxation_map): Change to use Section_id
+ instead of Input_section_specifier as key type.
+ (Output_section::convert_input_sections_in_list_to_relaxed_sections):
+ Ditto.
+ (Output_section::convert_input_sections_to_relaxed_sections): Change
+ to use Const_section_id instead of Input_section_specifier as key type.
+ (Output_section::find_merge_section): Ditto.
+ (Output_section::find_relaxed_input_section): Ditto.
+ * output.h (Input_section_specifier): Remove class.
+ (Output_section::Output_section_data_by_input_section_map): Change
+ key type to Const_section_id.
+ (Output_section::Output_relaxed_input_section_by_input_section_map):
+ Ditto.
+ (Output_section::Relaxation_map): Change key type to Section_id.
+
2010-01-20 Viktor Kutuzov <vkutuzov@accesssoftek.com>
* gold/arm.cc: Added support for R_ARM_V4BX relocation
diff --git a/gold/arm.cc b/gold/arm.cc
index 87459a5..8e3573f 100644
--- a/gold/arm.cc
+++ b/gold/arm.cc
@@ -2114,10 +2114,9 @@ class Target_arm : public Sized_target<32, big_endian>
typedef typename std::vector<Stub_table<big_endian>*> Stub_table_list;
// Map input section to Arm_input_section.
- typedef Unordered_map<Input_section_specifier,
+ typedef Unordered_map<Section_id,
Arm_input_section<big_endian>*,
- Input_section_specifier::hash,
- Input_section_specifier::equal_to>
+ Section_id_hash>
Arm_input_section_map;
// Map output addresses to relocs for Cortex-A8 erratum.
@@ -7543,7 +7542,7 @@ Target_arm<big_endian>::new_arm_input_section(
Relobj* relobj,
unsigned int shndx)
{
- Input_section_specifier iss(relobj, shndx);
+ Section_id sid(relobj, shndx);
Arm_input_section<big_endian>* arm_input_section =
new Arm_input_section<big_endian>(relobj, shndx);
@@ -7551,7 +7550,7 @@ Target_arm<big_endian>::new_arm_input_section(
// Register new Arm_input_section in map for look-up.
std::pair<typename Arm_input_section_map::iterator, bool> ins =
- this->arm_input_section_map_.insert(std::make_pair(iss, arm_input_section));
+ this->arm_input_section_map_.insert(std::make_pair(sid, arm_input_section));
// Make sure that it we have not created another Arm_input_section
// for this input section already.
@@ -7569,9 +7568,9 @@ Target_arm<big_endian>::find_arm_input_section(
Relobj* relobj,
unsigned int shndx) const
{
- Input_section_specifier iss(relobj, shndx);
+ Section_id sid(relobj, shndx);
typename Arm_input_section_map::const_iterator p =
- this->arm_input_section_map_.find(iss);
+ this->arm_input_section_map_.find(sid);
return (p != this->arm_input_section_map_.end()) ? p->second : NULL;
}
diff --git a/gold/gc.h b/gold/gc.h
index 3885d1a..1ffb590 100644
--- a/gold/gc.h
+++ b/gold/gc.h
@@ -28,6 +28,7 @@
#include "elfcpp.h"
#include "symtab.h"
+#include "object.h"
#include "icf.h"
namespace gold
@@ -45,16 +46,8 @@ class Output_section;
class General_options;
class Layout;
-typedef std::pair<Object *, unsigned int> Section_id;
-
class Garbage_collection
{
- struct Section_id_hash
- {
- size_t operator()(const Section_id& loc) const
- { return reinterpret_cast<uintptr_t>(loc.first) ^ loc.second; }
- };
-
public:
typedef Unordered_set<Section_id, Section_id_hash> Sections_reachable;
diff --git a/gold/icf.h b/gold/icf.h
index de0fbe0..e336572 100644
--- a/gold/icf.h
+++ b/gold/icf.h
@@ -27,6 +27,7 @@
#include "elfcpp.h"
#include "symtab.h"
+#include "object.h"
namespace gold
{
@@ -35,17 +36,9 @@ class Object;
class Input_objects;
class Symbol_table;
-typedef std::pair<Object*, unsigned int> Section_id;
-
class Icf
{
public:
- struct Section_id_hash
- {
- size_t operator()(const Section_id& loc) const
- { return reinterpret_cast<uintptr_t>(loc.first) ^ loc.second; }
- };
-
typedef std::vector<Section_id> Sections_reachable_list;
typedef std::vector<Symbol*> Symbol_info;
typedef std::vector<std::pair<long long, long long> > Addend_info;
diff --git a/gold/object.h b/gold/object.h
index 26e85f5..d006856 100644
--- a/gold/object.h
+++ b/gold/object.h
@@ -2050,6 +2050,31 @@ struct Relocate_info
location(size_t relnum, off_t reloffset) const;
};
+// This is used to represent a section in an object and is used as the
+// key type for various section maps.
+typedef std::pair<Object*, unsigned int> Section_id;
+
+// This is similar to Section_id but is used when the section
+// pointers are const.
+typedef std::pair<const Object*, unsigned int> Const_section_id;
+
+// The hash value is based on the address of an object in memory during
+// linking. It is okay to use this for looking up sections but never use
+// this in an unordered container that we want to traverse in a repeatable
+// manner.
+
+struct Section_id_hash
+{
+ size_t operator()(const Section_id& loc) const
+ { return reinterpret_cast<uintptr_t>(loc.first) ^ loc.second; }
+};
+
+struct Const_section_id_hash
+{
+ size_t operator()(const Const_section_id& loc) const
+ { return reinterpret_cast<uintptr_t>(loc.first) ^ loc.second; }
+};
+
// Return whether INPUT_FILE contains an ELF object start at file
// offset OFFSET. This sets *START to point to a view of the start of
// the file. It sets *READ_SIZE to the number of bytes in the view.
diff --git a/gold/output.cc b/gold/output.cc
index 2a97078..6374895 100644
--- a/gold/output.cc
+++ b/gold/output.cc
@@ -2072,8 +2072,8 @@ Output_section::add_relaxed_input_section(Output_relaxed_input_section* poris)
this->add_output_section_data(&inp);
if (this->is_relaxed_input_section_map_valid_)
{
- Input_section_specifier iss(poris->relobj(), poris->shndx());
- this->relaxed_input_section_map_[iss] = poris;
+ Const_section_id csid(poris->relobj(), poris->shndx());
+ this->relaxed_input_section_map_[csid] = poris;
}
// For a relaxed section, we use the current data size. Linker scripts
@@ -2145,8 +2145,8 @@ Output_section::add_merge_input_section(Relobj* object, unsigned int shndx,
&& merge_section->addralign() == addralign);
// Link input section to found merge section.
- Input_section_specifier iss(object, shndx);
- this->merge_section_map_[iss] = merge_section;
+ Const_section_id csid(object, shndx);
+ this->merge_section_map_[csid] = merge_section;
return true;
}
@@ -2181,8 +2181,8 @@ Output_section::add_merge_input_section(Relobj* object, unsigned int shndx,
// Add input section to new merge section and link input section to new
// merge section in map.
pomb->add_input_section(object, shndx);
- Input_section_specifier iss(object, shndx);
- this->merge_section_map_[iss] = pomb;
+ Const_section_id csid(object, shndx);
+ this->merge_section_map_[csid] = pomb;
return true;
}
@@ -2201,15 +2201,15 @@ Output_section::build_relaxation_map(
const Input_section& is(input_sections[i]);
if (is.is_input_section() || is.is_relaxed_input_section())
{
- Input_section_specifier iss(is.relobj(), is.shndx());
- (*relaxation_map)[iss] = i;
+ Section_id sid(is.relobj(), is.shndx());
+ (*relaxation_map)[sid] = i;
}
}
}
// Convert regular input sections in INPUT_SECTIONS into relaxed input
-// sections in RELAXED_SECTIONS. MAP is a prebuilt map from input section
-// specifier to indices of INPUT_SECTIONS.
+// sections in RELAXED_SECTIONS. MAP is a prebuilt map from section id
+// indices of INPUT_SECTIONS.
void
Output_section::convert_input_sections_in_list_to_relaxed_sections(
@@ -2220,8 +2220,8 @@ Output_section::convert_input_sections_in_list_to_relaxed_sections(
for (size_t i = 0; i < relaxed_sections.size(); ++i)
{
Output_relaxed_input_section* poris = relaxed_sections[i];
- Input_section_specifier iss(poris->relobj(), poris->shndx());
- Relaxation_map::const_iterator p = map.find(iss);
+ Section_id sid(poris->relobj(), poris->shndx());
+ Relaxation_map::const_iterator p = map.find(sid);
gold_assert(p != map.end());
gold_assert((*input_sections)[p->second].is_input_section());
(*input_sections)[p->second] = Input_section(poris);
@@ -2283,8 +2283,8 @@ Output_section::convert_input_sections_to_relaxed_sections(
for (size_t i = 0; i < relaxed_sections.size(); ++i)
{
Output_relaxed_input_section* poris = relaxed_sections[i];
- Input_section_specifier iss(poris->relobj(), poris->shndx());
- this->relaxed_input_section_map_[iss] = poris;
+ Const_section_id csid(poris->relobj(), poris->shndx());
+ this->relaxed_input_section_map_[csid] = poris;
}
}
@@ -2329,9 +2329,9 @@ Output_section_data*
Output_section::find_merge_section(const Relobj* object,
unsigned int shndx) const
{
- Input_section_specifier iss(object, shndx);
+ Const_section_id csid(object, shndx);
Output_section_data_by_input_section_map::const_iterator p =
- this->merge_section_map_.find(iss);
+ this->merge_section_map_.find(csid);
if (p != this->merge_section_map_.end())
{
Output_section_data* posd = p->second;
@@ -2360,16 +2360,16 @@ Output_section::find_relaxed_input_section(const Relobj* object,
++p)
if (p->is_relaxed_input_section())
{
- Input_section_specifier iss(p->relobj(), p->shndx());
- this->relaxed_input_section_map_[iss] =
+ Const_section_id csid(p->relobj(), p->shndx());
+ this->relaxed_input_section_map_[csid] =
p->relaxed_input_section();
}
this->is_relaxed_input_section_map_valid_ = true;
}
- Input_section_specifier iss(object, shndx);
+ Const_section_id csid(object, shndx);
Output_relaxed_input_section_by_input_section_map::const_iterator p =
- this->relaxed_input_section_map_.find(iss);
+ this->relaxed_input_section_map_.find(csid);
if (p != this->relaxed_input_section_map_.end())
return p->second;
else
diff --git a/gold/output.h b/gold/output.h
index 7a35652..ec16ca3 100644
--- a/gold/output.h
+++ b/gold/output.h
@@ -47,62 +47,6 @@ class Sized_target;
template<int size, bool big_endian>
class Sized_relobj;
-// This class specifies an input section. It is used as a key type
-// for maps.
-
-class Input_section_specifier
-{
- public:
- Input_section_specifier(const Relobj* relobj, unsigned int shndx)
- : relobj_(relobj), shndx_(shndx)
- { }
-
- // Return Relobj of this.
- const Relobj*
- relobj() const
- { return this->relobj_; }
-
- // Return section index of this.
- unsigned int
- shndx() const
- { return this->shndx_; }
-
- // Whether this equals to another specifier ISS.
- bool
- eq(const Input_section_specifier& iss) const
- { return this->relobj_ == iss.relobj_ && this->shndx_ == iss.shndx_; }
-
- // Compute a hash value of this.
- size_t
- hash_value() const
- {
- return (gold::string_hash<char>(this->relobj_->name().c_str())
- ^ this->shndx_);
- }
-
- // Functors for containers.
- struct equal_to
- {
- bool
- operator()(const Input_section_specifier& iss1,
- const Input_section_specifier& iss2) const
- { return iss1.eq(iss2); }
- };
-
- struct hash
- {
- size_t
- operator()(const Input_section_specifier& iss) const
- { return iss.hash_value(); }
- };
-
- private:
- // An object.
- const Relobj* relobj_;
- // A section index.
- unsigned int shndx_;
-};
-
// An abtract class for data which has to go into the output file.
class Output_data
@@ -3396,25 +3340,20 @@ class Output_section : public Output_data
Merge_section_properties::equal_to>
Merge_section_by_properties_map;
- // Map that link Input_section_specifier to Output_section_data.
- typedef Unordered_map<Input_section_specifier, Output_section_data*,
- Input_section_specifier::hash,
- Input_section_specifier::equal_to>
+ // Map that link Const_section_id to Output_section_data.
+ typedef Unordered_map<Const_section_id, Output_section_data*,
+ Const_section_id_hash>
Output_section_data_by_input_section_map;
- // Map that link Input_section_specifier to Output_relaxed_input_section.
- typedef Unordered_map<Input_section_specifier, Output_relaxed_input_section*,
- Input_section_specifier::hash,
- Input_section_specifier::equal_to>
+ // Map that link Const_section_id to Output_relaxed_input_section.
+ typedef Unordered_map<Const_section_id, Output_relaxed_input_section*,
+ Const_section_id_hash>
Output_relaxed_input_section_by_input_section_map;
// Map used during relaxation of existing sections. This map
- // an input section specifier to an input section list index.
- // We assume that Input_section_list is a vector.
- typedef Unordered_map<Input_section_specifier, size_t,
- Input_section_specifier::hash,
- Input_section_specifier::equal_to>
- Relaxation_map;
+ // a section id an input section list index. We assume that
+ // Input_section_list is a vector.
+ typedef Unordered_map<Section_id, size_t, Section_id_hash> Relaxation_map;
// Add a new output section by Input_section.
void