* elf32-ppc.c (ppc_elf_check_relocs): Set pointer_equality_needed
[binutils.git] / gold / strtab.h
blobab22b8fc286f2fec8f85d613e856fad8fca093c7
1 // strtab.h -- manage an ELF string table for gold -*- C++ -*-
3 #ifndef GOLD_STRTAB_H
4 #define GOLD_STRTAB_H
6 #include <cstring>
7 #include <string>
9 namespace gold
12 // This class holds an ELF string table. We keep a reference count
13 // for each string, which we use to determine which strings are
14 // actually required at the end. When all operations are done, the
15 // string table is finalized, which sets the offsets to use for each
16 // string.
18 class Strtab
20 public:
21 Strtab();
23 ~Strtab();
25 Strtab_ref* add(const char*);
27 Strtab_ref* add(const std::string& s)
28 { return this->add(s.c_str()); }
30 private:
31 Strtab(const Strtab&);
32 Strtab& operator=(const Strtab&);
34 struct strtab_hash
36 std::size_t
37 operator()(const char*p);
40 struct strtab_eq
42 bool
43 operator()(const char* p1, const char* p2)
44 { return strcmp(p1, p2) == 0; }
47 Unordered_map<const char*, Strtab_ref*, strtab_hash, strtab_eq,
48 std::allocator<std::pair<const char* const, Strtab_ref*> >,
49 true> strings_;
52 // Users of Strtab work with pointers to Strtab_ref structures. These
53 // are allocated via new and should be deleted if the string is no
54 // longer needed.
56 class Strtab_ref
58 public:
59 ~Strtab_ref();
61 const char*
62 str() const;
64 private:
65 Strtab_ref(const Strtab_ref&);
66 Strtab_ref& operator=(const Strtab_ref&);
68 int refs_;
71 } // End namespace gold.
73 #endif // !defined(GOLD_STRTAB_H)