#include <ext/hash_map>
#include <ext/hash_set>
+#include <string>
#define Unordered_set __gnu_cxx::hash_set
#define Unordered_map __gnu_cxx::hash_map
+namespace __gnu_cxx
+{
+
+template<>
+struct hash<std::string>
+{
+ size_t
+ operator()(std::string s) const
+ { return __stl_hash_string(s.c_str()); }
+};
+
+template<typename T>
+struct hash<T*>
+{
+ size_t
+ operator()(T* p) const
+ { return reinterpret_cast<size_t>(p); }
+};
+
+}
+
#else
// The fallback is to just use set and map.
template<int size, bool big_endian>
Sized_target<size, big_endian>*
sized_target();
-#else
- virtual Target* sized_target() = 0;
#endif
// Read the symbol and relocation information.
// Return the appropriate Sized_target structure.
Sized_target<size, big_endian>*
sized_target()
- { return this->Object::sized_target<size, big_endian>(); }
+ {
+#ifdef HAVE_MEMBER_TEMPLATE_SPECIFICATIONS
+ return this->Object::sized_target<size, big_endian>();
+#else
+ return static_cast<Sized_target<size, big_endian>*>(this->target());
+#endif
+ }
private:
// This object may not be copied.
{
public:
Input_objects()
- : object_list_()
+ : object_list_(), any_dynamic_(false)
{ }
// The type of the list of input objects.
{
if (object->target()->has_resolve())
{
- object->sized_target<size, big_endian>()->resolve(to, sym, object);
+ Sized_target<size, big_endian>* sized_target;
+#ifdef HAVE_MEMBER_TEMPLATE_SPECIFICATIONS
+ sized_target = object->sized_target<size, big_endian>();
+#else
+ Target* target = object->target();
+ assert(target->get_size() == size);
+ assert(target->is_big_endian() ? big_endian : !big_endian);
+ sized_target = static_cast<Sized_target<size, big_endian>*>(target);
+#endif
+ sized_target->resolve(to, sym, object);
return;
}
{ return strcmp(p1, p2) == 0; }
};
+#ifdef HAVE_TR1_UNORDERED_SET
typedef Unordered_set<const char*, Stringpool_hash, Stringpool_eq,
std::allocator<const char*>,
true> String_set_type;
+#else
+ typedef Unordered_set<const char*, Stringpool_hash, Stringpool_eq,
+ std::allocator<const char*> > String_set_type;
+#endif
+
String_set_type string_set_;
std::list<stringdata*> strings_;
};
// version is the default version. Because this is unusual, we do
// this the slow way, by converting back to an ELF symbol.
+#ifdef HAVE_MEMBER_TEMPLATE_SPECIFICATIONS
+
template<int size, bool big_endian>
void
Symbol_table::resolve(Sized_symbol<size>* to, const Sized_symbol<size>* from)
Symbol_table::resolve(to, esym.sym(), from->object());
}
+#else
+
+template<int size>
+void
+Symbol_table::resolve(Sized_symbol<size>* to, const Sized_symbol<size>* from,
+ bool big_endian)
+{
+ unsigned char buf[elfcpp::Elf_sizes<size>::sym_size];
+ if (big_endian)
+ {
+ elfcpp::Sym_write<size, true> esym(buf);
+ // We don't bother to set the st_name field.
+ esym.put_st_value(from->value());
+ esym.put_st_size(from->symsize());
+ esym.put_st_info(from->binding(), from->type());
+ esym.put_st_other(from->visibility(), from->other());
+ esym.put_st_shndx(from->shnum());
+ Symbol_table::resolve(to, esym.sym(), from->object());
+ }
+ else
+ {
+ elfcpp::Sym_write<size, false> esym(buf);
+ // We don't bother to set the st_name field.
+ esym.put_st_value(from->value());
+ esym.put_st_size(from->symsize());
+ esym.put_st_info(from->binding(), from->type());
+ esym.put_st_other(from->visibility(), from->other());
+ esym.put_st_shndx(from->shnum());
+ Symbol_table::resolve(to, esym.sym(), from->object());
+ }
+}
+
+#endif
+
// Add one symbol from OBJECT to the symbol table. NAME is symbol
// name and VERSION is the version; both are canonicalized. DEF is
// whether this is the default version.
if (!ins.second)
{
// We already have an entry for NAME/VERSION.
+#ifdef HAVE_MEMBER_TEMPLATE_SPECIFICATIONS
ret = this->get_sized_symbol<size>(ins.first->second);
+#else
+ assert(size == this->get_size());
+ ret = static_cast<Sized_symbol<size>*>(ins.first->second);
+#endif
assert(ret != NULL);
Symbol_table::resolve(ret, sym, object);
{
// This is the unfortunate case where we already have
// entries for both NAME/VERSION and NAME/NULL.
- const Sized_symbol<size>* sym2 =
- this->get_sized_symbol<size>(insdef.first->second);
+ const Sized_symbol<size>* sym2;
+#ifdef HAVE_MEMBER_TEMPLATE_SPECIFICATIONS
+ sym2 = this->get_sized_symbol<size>(insdef.first->second);
Symbol_table::resolve<size, big_endian>(ret, sym2);
+#else
+ sym2 = static_cast<Sized_symbol<size>*>(insdef.first->second);
+ Symbol_table::resolve(ret, sym2, big_endian);
+#endif
this->make_forwarder(insdef.first->second, ret);
insdef.first->second = ret;
}
{
// We already have an entry for NAME/NULL. Make
// NAME/VERSION point to it.
+#ifdef HAVE_MEMBER_TEMPLATE_SPECIFICATIONS
ret = this->get_sized_symbol<size>(insdef.first->second);
+#else
+ ret = static_cast<Sized_symbol<size>*>(insdef.first->second);
+#endif
Symbol_table::resolve(ret, sym, object);
ins.first->second = ret;
}
const elfcpp::Sym<size, big_endian>& sym,
Object*);
+#ifdef HAVE_MEMBER_TEMPLATE_SPECIFICATIONS
template<int size, bool big_endian>
static void
resolve(Sized_symbol<size>* to, const Sized_symbol<size>* from);
+#else
+ template<int size>
+ static void
+ resolve(Sized_symbol<size>* to, const Sized_symbol<size>* from,
+ bool big_endian);
+#endif
// The type of the symbol hash table.
has_resolve() const
{ return this->has_resolve_; }
- // Resolve a symbol. This is called when we see a symbol with a
- // target specific binding (STB_LOOS through STB_HIOS or STB_LOPROC
- // through STB_HIPROC). TO is a pre-existing symbol. SYM is the
- // new symbol, seen in OBJECT. This returns true on success, false
- // if the symbol can not be resolved.
- template<int size, bool big_endian>
- bool
- resolve(Sized_symbol<size>* to, const elfcpp::Sym<size, big_endian>& sym,
- Object* object);
-
protected:
Target(int size, bool is_big_endian, bool has_make_symbol, bool has_resolve)
: size_(size),