2009-10-21 Doug Kwan <dougkwan@google.com>
* arm.cc: Update copyright comments. (Target_arm): New forward class template declaration. (Arm_address): New type. (ARM_MAX_FWD_BRANCH_OFFSET, ARM_MAX_BWD_BRANCH_OFFSET, THM_MAX_FWD_BRANCH_OFFSET, THM_MAX_BWD_BRANCH_OFFSET, THM2_MAX_FWD_BRANCH_OFFSET, THM2_MAX_BWD_BRANCH_OFFSET): New constants. (Insn_template): Same. (DEF_STUBS): New macro. (Stub_type): New enum type. (Stub_template): New class definition. (Stub): Same. (Reloc_stub): Same. (Stub_factory): Same. (Target_arm::Target_arm): Initialize may_use_blx_ and should_force_pic_veneer_. (Target_arm::may_use_blx, Target_arm::set_may_use_blx, Target_arm::should_force_pic_veneer, Target_arm::set_should_force_pic_veneer, Target_arm::using_thumb2, Target_arm::using_thumb_only, Target_arm:;default_target): New method defintions. (Target_arm::may_use_blx_, Target_arm::should_force_pic_veneer_): New data member declarations. (Insn_template::size, Insn_template::alignment): New method defintions. (Stub_template::Stub_template): New method definition. (Reloc_stub::Key::name, Reloc_stub::stub_type_for_reloc, Reloc_stub::do_fixed_endian_write, Reloc_stub::do_write): Same. (Stub_factory::Stub_factory): New method definition. * gold.h (string_hash): New template. * output.h (Input_section_specifier::hash_value): Use gold::string_hash. (Input_section_specifier::string_hash): Remove. * stringpool.cc (Stringpool_template::string_hash): Use gold::string_hash.
This commit is contained in:
parent
550e3caf22
commit
b569affa94
5 changed files with 1222 additions and 24 deletions
|
@ -1,3 +1,40 @@
|
|||
2009-10-21 Doug Kwan <dougkwan@google.com>
|
||||
|
||||
* arm.cc: Update copyright comments.
|
||||
(Target_arm): New forward class template declaration.
|
||||
(Arm_address): New type.
|
||||
(ARM_MAX_FWD_BRANCH_OFFSET, ARM_MAX_BWD_BRANCH_OFFSET,
|
||||
THM_MAX_FWD_BRANCH_OFFSET, THM_MAX_BWD_BRANCH_OFFSET,
|
||||
THM2_MAX_FWD_BRANCH_OFFSET, THM2_MAX_BWD_BRANCH_OFFSET): New
|
||||
constants.
|
||||
(Insn_template): Same.
|
||||
(DEF_STUBS): New macro.
|
||||
(Stub_type): New enum type.
|
||||
(Stub_template): New class definition.
|
||||
(Stub): Same.
|
||||
(Reloc_stub): Same.
|
||||
(Stub_factory): Same.
|
||||
(Target_arm::Target_arm): Initialize may_use_blx_ and
|
||||
should_force_pic_veneer_.
|
||||
(Target_arm::may_use_blx, Target_arm::set_may_use_blx,
|
||||
Target_arm::should_force_pic_veneer,
|
||||
Target_arm::set_should_force_pic_veneer, Target_arm::using_thumb2,
|
||||
Target_arm::using_thumb_only, Target_arm:;default_target): New
|
||||
method defintions.
|
||||
(Target_arm::may_use_blx_, Target_arm::should_force_pic_veneer_):
|
||||
New data member declarations.
|
||||
(Insn_template::size, Insn_template::alignment): New method defintions.
|
||||
(Stub_template::Stub_template): New method definition.
|
||||
(Reloc_stub::Key::name, Reloc_stub::stub_type_for_reloc,
|
||||
Reloc_stub::do_fixed_endian_write, Reloc_stub::do_write): Same.
|
||||
(Stub_factory::Stub_factory): New method definition.
|
||||
* gold.h (string_hash): New template.
|
||||
* output.h (Input_section_specifier::hash_value): Use
|
||||
gold::string_hash.
|
||||
(Input_section_specifier::string_hash): Remove.
|
||||
* stringpool.cc (Stringpool_template::string_hash): Use
|
||||
gold::string_hash.
|
||||
|
||||
2009-10-20 Doug Kwan <dougkwan@google.com>
|
||||
|
||||
* object.cc (Sized_relobj::do_finalize_local_symbols): Handle section
|
||||
|
|
1144
gold/arm.cc
1144
gold/arm.cc
File diff suppressed because it is too large
Load diff
37
gold/gold.h
37
gold/gold.h
|
@ -349,6 +349,43 @@ is_prefix_of(const char* prefix, const char* str)
|
|||
return strncmp(prefix, str, strlen(prefix)) == 0;
|
||||
}
|
||||
|
||||
// We sometimes need to hash strings. Ideally we should use std::tr1::hash or
|
||||
// __gnu_cxx::hash on some systems but there is no guarantee that either
|
||||
// one is available. For portability, we define simple string hash functions.
|
||||
|
||||
template<typename Char_type>
|
||||
inline size_t
|
||||
string_hash(const Char_type* s, size_t length)
|
||||
{
|
||||
// This is the hash function used by the dynamic linker for
|
||||
// DT_GNU_HASH entries. I compared this to a Fowler/Noll/Vo hash
|
||||
// for a C++ program with 385,775 global symbols. This hash
|
||||
// function was very slightly worse. However, it is much faster to
|
||||
// compute. Overall wall clock time was a win.
|
||||
const unsigned char* p = reinterpret_cast<const unsigned char*>(s);
|
||||
size_t h = 5381;
|
||||
for (size_t i = 0; i < length * sizeof(Char_type); ++i)
|
||||
h = h * 33 + *p++;
|
||||
return h;
|
||||
}
|
||||
|
||||
// Same as above except we expect the string to be zero terminated.
|
||||
|
||||
template<typename Char_type>
|
||||
inline size_t
|
||||
string_hash(const Char_type* s)
|
||||
{
|
||||
const unsigned char* p = reinterpret_cast<const unsigned char*>(s);
|
||||
size_t h = 5381;
|
||||
for (size_t i = 0; s[i] != 0; ++i)
|
||||
{
|
||||
for (size_t j = 0; j < sizeof(Char_type); j++)
|
||||
h = h * 33 + *p++;
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
} // End namespace gold.
|
||||
|
||||
#endif // !defined(GOLD_GOLD_H)
|
||||
|
|
|
@ -75,7 +75,10 @@ class Input_section_specifier
|
|||
// Compute a hash value of this.
|
||||
size_t
|
||||
hash_value() const
|
||||
{ return this->string_hash(this->relobj_->name().c_str()) ^ this->shndx_; }
|
||||
{
|
||||
return (gold::string_hash<char>(this->relobj_->name().c_str())
|
||||
^ this->shndx_);
|
||||
}
|
||||
|
||||
// Functors for containers.
|
||||
struct equal_to
|
||||
|
@ -94,18 +97,6 @@ class Input_section_specifier
|
|||
};
|
||||
|
||||
private:
|
||||
// For portability, we use our own string hash function instead of assuming
|
||||
// __gnu_cxx::hash or std::tr1::hash is available. This is the same hash
|
||||
// function used in Stringpool_template::string_hash.
|
||||
static size_t
|
||||
string_hash(const char* s)
|
||||
{
|
||||
size_t h = 5381;
|
||||
while (*s != '\0')
|
||||
h = h * 33 + *s++;
|
||||
return h;
|
||||
}
|
||||
|
||||
// An object.
|
||||
const Relobj* relobj_;
|
||||
// A section index.
|
||||
|
|
|
@ -153,16 +153,7 @@ size_t
|
|||
Stringpool_template<Stringpool_char>::string_hash(const Stringpool_char* s,
|
||||
size_t length)
|
||||
{
|
||||
// This is the hash function used by the dynamic linker for
|
||||
// DT_GNU_HASH entries. I compared this to a Fowler/Noll/Vo hash
|
||||
// for a C++ program with 385,775 global symbols. This hash
|
||||
// function was very slightly worse. However, it is much faster to
|
||||
// compute. Overall wall clock time was a win.
|
||||
const unsigned char* p = reinterpret_cast<const unsigned char*>(s);
|
||||
size_t h = 5381;
|
||||
for (size_t i = 0; i < length * sizeof(Stringpool_char); ++i)
|
||||
h = h * 33 + *p++;
|
||||
return h;
|
||||
return gold::string_hash<Stringpool_char>(s, length);
|
||||
}
|
||||
|
||||
// Add the string S to the list of canonical strings. Return a
|
||||
|
|
Loading…
Reference in a new issue