+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
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.
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);
// 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.
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;
}
#include "elfcpp.h"
#include "symtab.h"
+#include "object.h"
#include "icf.h"
namespace gold
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;
#include "elfcpp.h"
#include "symtab.h"
+#include "object.h"
namespace gold
{
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;
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.
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
&& 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;
}
// 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;
}
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(
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);
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;
}
}
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;
++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
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
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