blob: 5c6c8e6389711bcdc20c8920dc5f95901ae38e5f [file] [log] [blame]
Michael J. Spencer84487f12015-07-24 21:03:07 +00001//===- SymbolTable.cpp ----------------------------------------------------===//
2//
3// The LLVM Linker
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
Rui Ueyama34f29242015-10-13 19:51:57 +00009//
10// Symbol table is a bag of all known symbols. We put all symbols of
Rui Ueyamac9559d92016-01-05 20:47:37 +000011// all input files to the symbol table. The symbol table is basically
Rui Ueyama34f29242015-10-13 19:51:57 +000012// a hash table with the logic to resolve symbol name conflicts using
13// the symbol types.
14//
15//===----------------------------------------------------------------------===//
Michael J. Spencer84487f12015-07-24 21:03:07 +000016
17#include "SymbolTable.h"
Rafael Espindola4340aad2015-09-11 22:42:45 +000018#include "Config.h"
Rafael Espindola192e1fa2015-08-06 15:08:23 +000019#include "Error.h"
Davide Italiano8e1131d2016-06-29 02:46:51 +000020#include "LinkerScript.h"
Rui Ueyama55518e72016-10-28 20:57:25 +000021#include "Memory.h"
George Rimar7899d482016-07-12 07:44:40 +000022#include "SymbolListFile.h"
Michael J. Spencer84487f12015-07-24 21:03:07 +000023#include "Symbols.h"
Rafael Espindola9f77ef02016-02-12 20:54:57 +000024#include "llvm/Bitcode/ReaderWriter.h"
Michael J. Spencer84487f12015-07-24 21:03:07 +000025
26using namespace llvm;
Rafael Espindoladaa92a62015-08-31 01:16:19 +000027using namespace llvm::object;
Rafael Espindola01205f72015-09-22 18:19:46 +000028using namespace llvm::ELF;
Michael J. Spencer84487f12015-07-24 21:03:07 +000029
30using namespace lld;
Rafael Espindolae0df00b2016-02-28 00:25:54 +000031using namespace lld::elf;
Michael J. Spencer84487f12015-07-24 21:03:07 +000032
Rui Ueyamac9559d92016-01-05 20:47:37 +000033// All input object files must be for the same architecture
34// (e.g. it does not make sense to link x86 object files with
35// MIPS object files.) This function checks for that error.
George Rimardbbf60e2016-06-29 09:46:00 +000036template <class ELFT> static bool isCompatible(InputFile *F) {
37 if (!isa<ELFFileBase<ELFT>>(F) && !isa<BitcodeFile>(F))
Rui Ueyama16ba6692016-01-29 19:41:13 +000038 return true;
Rui Ueyama5e64d3f2016-06-29 01:30:50 +000039 if (F->EKind == Config->EKind && F->EMachine == Config->EMachine)
Rui Ueyama16ba6692016-01-29 19:41:13 +000040 return true;
Rui Ueyama25b44c92015-12-16 23:31:22 +000041 StringRef A = F->getName();
42 StringRef B = Config->Emulation;
43 if (B.empty())
44 B = Config->FirstElf->getName();
Rui Ueyama16ba6692016-01-29 19:41:13 +000045 error(A + " is incompatible with " + B);
46 return false;
Rui Ueyama25b44c92015-12-16 23:31:22 +000047}
48
Rui Ueyamac9559d92016-01-05 20:47:37 +000049// Add symbols in File to the symbol table.
Rui Ueyama38dbd3e2016-09-14 00:05:51 +000050template <class ELFT> void SymbolTable<ELFT>::addFile(InputFile *File) {
51 if (!isCompatible<ELFT>(File))
Rui Ueyama16ba6692016-01-29 19:41:13 +000052 return;
Rafael Espindola525914d2015-10-11 03:36:49 +000053
Michael J. Spencera9424f32016-09-09 22:08:04 +000054 // Binary file
Rui Ueyama38dbd3e2016-09-14 00:05:51 +000055 if (auto *F = dyn_cast<BinaryFile>(File)) {
Rafael Espindola093abab2016-10-27 17:45:40 +000056 BinaryFiles.push_back(F);
57 F->parse<ELFT>();
Michael J. Spencera9424f32016-09-09 22:08:04 +000058 return;
59 }
60
Rui Ueyama89575742015-12-16 22:59:13 +000061 // .a file
Rui Ueyama38dbd3e2016-09-14 00:05:51 +000062 if (auto *F = dyn_cast<ArchiveFile>(File)) {
Peter Collingbourne4f952702016-05-01 04:55:03 +000063 F->parse<ELFT>();
Michael J. Spencer1b348a62015-09-04 22:28:10 +000064 return;
65 }
Rui Ueyama3d451792015-10-12 18:03:21 +000066
George Rimar2a78fce2016-04-13 18:07:57 +000067 // Lazy object file
Rui Ueyama38dbd3e2016-09-14 00:05:51 +000068 if (auto *F = dyn_cast<LazyObjectFile>(File)) {
Peter Collingbourne4f952702016-05-01 04:55:03 +000069 F->parse<ELFT>();
George Rimar2a78fce2016-04-13 18:07:57 +000070 return;
71 }
72
73 if (Config->Trace)
Rui Ueyama38dbd3e2016-09-14 00:05:51 +000074 outs() << getFilename(File) << "\n";
George Rimar2a78fce2016-04-13 18:07:57 +000075
Rui Ueyama89575742015-12-16 22:59:13 +000076 // .so file
Rui Ueyama38dbd3e2016-09-14 00:05:51 +000077 if (auto *F = dyn_cast<SharedFile<ELFT>>(File)) {
Rui Ueyama89575742015-12-16 22:59:13 +000078 // DSOs are uniquified not by filename but by soname.
79 F->parseSoName();
George Rimarbcba39a2016-11-02 10:16:25 +000080 if (HasError || !SoNames.insert(F->getSoName()).second)
Rafael Espindola6a3b5de2015-10-01 19:52:48 +000081 return;
Rui Ueyama38dbd3e2016-09-14 00:05:51 +000082 SharedFiles.push_back(F);
Rui Ueyama7c713312016-01-06 01:56:36 +000083 F->parseRest();
Rui Ueyama89575742015-12-16 22:59:13 +000084 return;
Rafael Espindola6a3b5de2015-10-01 19:52:48 +000085 }
Rui Ueyama89575742015-12-16 22:59:13 +000086
Rui Ueyamaf8baa662016-04-07 19:24:51 +000087 // LLVM bitcode file
Rui Ueyama38dbd3e2016-09-14 00:05:51 +000088 if (auto *F = dyn_cast<BitcodeFile>(File)) {
89 BitcodeFiles.push_back(F);
Peter Collingbourne4f952702016-05-01 04:55:03 +000090 F->parse<ELFT>(ComdatGroups);
Rafael Espindola9f77ef02016-02-12 20:54:57 +000091 return;
92 }
93
Rui Ueyamaf8baa662016-04-07 19:24:51 +000094 // Regular object file
Rui Ueyama38dbd3e2016-09-14 00:05:51 +000095 auto *F = cast<ObjectFile<ELFT>>(File);
96 ObjectFiles.push_back(F);
Rui Ueyama52d3b672016-01-06 02:06:33 +000097 F->parse(ComdatGroups);
Michael J. Spencer84487f12015-07-24 21:03:07 +000098}
99
Rui Ueyama42554752016-04-23 00:26:32 +0000100// This function is where all the optimizations of link-time
101// optimization happens. When LTO is in use, some input files are
102// not in native object file format but in the LLVM bitcode format.
103// This function compiles bitcode files into a few big native files
104// using LLVM functions and replaces bitcode symbols with the results.
105// Because all bitcode files that consist of a program are passed
106// to the compiler at once, it can do whole-program optimization.
Rafael Espindola9f77ef02016-02-12 20:54:57 +0000107template <class ELFT> void SymbolTable<ELFT>::addCombinedLtoObject() {
108 if (BitcodeFiles.empty())
109 return;
Rui Ueyama25992482016-03-22 20:52:10 +0000110
Rui Ueyama38dbd3e2016-09-14 00:05:51 +0000111 // Compile bitcode files and replace bitcode symbols.
Rui Ueyama25992482016-03-22 20:52:10 +0000112 Lto.reset(new BitcodeCompiler);
Rui Ueyama38dbd3e2016-09-14 00:05:51 +0000113 for (BitcodeFile *F : BitcodeFiles)
Rui Ueyama25992482016-03-22 20:52:10 +0000114 Lto->add(*F);
Rui Ueyama25992482016-03-22 20:52:10 +0000115
Rui Ueyama38dbd3e2016-09-14 00:05:51 +0000116 for (InputFile *File : Lto->compile()) {
117 ObjectFile<ELFT> *Obj = cast<ObjectFile<ELFT>>(File);
Rafael Espindola8b2c85362016-10-21 19:49:42 +0000118 DenseSet<CachedHashStringRef> DummyGroups;
Davide Italianobc176632016-04-15 22:38:10 +0000119 Obj->parse(DummyGroups);
Rui Ueyama38dbd3e2016-09-14 00:05:51 +0000120 ObjectFiles.push_back(Obj);
Rafael Espindola9f77ef02016-02-12 20:54:57 +0000121 }
122}
123
Rafael Espindola0e604f92015-09-25 18:56:53 +0000124template <class ELFT>
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +0000125DefinedRegular<ELFT> *SymbolTable<ELFT>::addAbsolute(StringRef Name,
126 uint8_t Visibility) {
Peter Collingbourne4f952702016-05-01 04:55:03 +0000127 return cast<DefinedRegular<ELFT>>(
Rafael Espindola093abab2016-10-27 17:45:40 +0000128 addRegular(Name, Visibility, nullptr, STB_GLOBAL, STT_NOTYPE, 0)->body());
Rafael Espindola0e604f92015-09-25 18:56:53 +0000129}
130
Rui Ueyamac9559d92016-01-05 20:47:37 +0000131// Add Name as an "ignored" symbol. An ignored symbol is a regular
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +0000132// linker-synthesized defined symbol, but is only defined if needed.
Simon Atanasyan09dae7c2015-12-16 14:45:09 +0000133template <class ELFT>
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +0000134DefinedRegular<ELFT> *SymbolTable<ELFT>::addIgnored(StringRef Name,
135 uint8_t Visibility) {
136 if (!find(Name))
137 return nullptr;
138 return addAbsolute(Name, Visibility);
Rafael Espindola5d413262015-10-01 21:22:26 +0000139}
140
Rui Ueyama69c778c2016-07-17 17:50:09 +0000141// Set a flag for --trace-symbol so that we can print out a log message
142// if a new symbol with the same name is inserted into the symbol table.
143template <class ELFT> void SymbolTable<ELFT>::trace(StringRef Name) {
Justin Lebar3c11e932016-10-18 17:50:36 +0000144 Symtab.insert({CachedHashStringRef(Name), {-1, true}});
Rui Ueyama69c778c2016-07-17 17:50:09 +0000145}
146
Rui Ueyamadeb15402016-01-07 17:20:07 +0000147// Rename SYM as __wrap_SYM. The original symbol is preserved as __real_SYM.
148// Used to implement --wrap.
149template <class ELFT> void SymbolTable<ELFT>::wrap(StringRef Name) {
Rui Ueyama1b70d662016-04-28 00:03:38 +0000150 SymbolBody *B = find(Name);
151 if (!B)
Rui Ueyamadeb15402016-01-07 17:20:07 +0000152 return;
Peter Collingbourne4f952702016-05-01 04:55:03 +0000153 Symbol *Sym = B->symbol();
154 Symbol *Real = addUndefined(Saver.save("__real_" + Name));
155 Symbol *Wrap = addUndefined(Saver.save("__wrap_" + Name));
156 // We rename symbols by replacing the old symbol's SymbolBody with the new
157 // symbol's SymbolBody. This causes all SymbolBody pointers referring to the
158 // old symbol to instead refer to the new symbol.
159 memcpy(Real->Body.buffer, Sym->Body.buffer, sizeof(Sym->Body));
160 memcpy(Sym->Body.buffer, Wrap->Body.buffer, sizeof(Wrap->Body));
Rui Ueyamadeb15402016-01-07 17:20:07 +0000161}
162
Peter Collingbournedadcc172016-04-22 18:42:48 +0000163static uint8_t getMinVisibility(uint8_t VA, uint8_t VB) {
164 if (VA == STV_DEFAULT)
165 return VB;
166 if (VB == STV_DEFAULT)
167 return VA;
168 return std::min(VA, VB);
169}
170
Rui Ueyamadace8382016-07-21 13:13:21 +0000171// Parses a symbol in the form of <name>@<version> or <name>@@<version>.
172static std::pair<StringRef, uint16_t> getSymbolVersion(StringRef S) {
173 if (Config->VersionDefinitions.empty())
174 return {S, Config->DefaultSymbolVersion};
175
176 size_t Pos = S.find('@');
177 if (Pos == 0 || Pos == StringRef::npos)
178 return {S, Config->DefaultSymbolVersion};
179
180 StringRef Name = S.substr(0, Pos);
181 StringRef Verstr = S.substr(Pos + 1);
182 if (Verstr.empty())
183 return {S, Config->DefaultSymbolVersion};
184
185 // '@@' in a symbol name means the default version.
186 // It is usually the most recent one.
187 bool IsDefault = (Verstr[0] == '@');
188 if (IsDefault)
189 Verstr = Verstr.substr(1);
190
191 for (VersionDefinition &V : Config->VersionDefinitions) {
192 if (V.Name == Verstr)
193 return {Name, IsDefault ? V.Id : (V.Id | VERSYM_HIDDEN)};
194 }
195
196 // It is an error if the specified version was not defined.
197 error("symbol " + S + " has undefined version " + Verstr);
198 return {S, Config->DefaultSymbolVersion};
199}
200
Rui Ueyamab4de5952016-01-08 22:01:33 +0000201// Find an existing symbol or create and insert a new one.
Peter Collingbourne4f952702016-05-01 04:55:03 +0000202template <class ELFT>
Rui Ueyamadace8382016-07-21 13:13:21 +0000203std::pair<Symbol *, bool> SymbolTable<ELFT>::insert(StringRef &Name) {
Justin Lebar3c11e932016-10-18 17:50:36 +0000204 auto P = Symtab.insert(
205 {CachedHashStringRef(Name), SymIndex((int)SymVector.size(), false)});
Rui Ueyamae3357902016-07-18 01:35:00 +0000206 SymIndex &V = P.first->second;
Rui Ueyama69c778c2016-07-17 17:50:09 +0000207 bool IsNew = P.second;
208
Rui Ueyamae3357902016-07-18 01:35:00 +0000209 if (V.Idx == -1) {
210 IsNew = true;
George Rimarb0841252016-07-20 14:26:48 +0000211 V = SymIndex((int)SymVector.size(), true);
Rui Ueyamae3357902016-07-18 01:35:00 +0000212 }
213
Rafael Espindola7f0b7272016-04-14 20:42:43 +0000214 Symbol *Sym;
Rui Ueyama69c778c2016-07-17 17:50:09 +0000215 if (IsNew) {
Rui Ueyama55518e72016-10-28 20:57:25 +0000216 Sym = new (BAlloc) Symbol;
Peter Collingbourne4f952702016-05-01 04:55:03 +0000217 Sym->Binding = STB_WEAK;
Peter Collingbourne66ac1d62016-04-22 20:21:26 +0000218 Sym->Visibility = STV_DEFAULT;
219 Sym->IsUsedInRegularObj = false;
220 Sym->ExportDynamic = false;
Rui Ueyamae3357902016-07-18 01:35:00 +0000221 Sym->Traced = V.Traced;
Rui Ueyamadace8382016-07-21 13:13:21 +0000222 std::tie(Name, Sym->VersionId) = getSymbolVersion(Name);
Rafael Espindola7f0b7272016-04-14 20:42:43 +0000223 SymVector.push_back(Sym);
224 } else {
Rui Ueyamae3357902016-07-18 01:35:00 +0000225 Sym = SymVector[V.Idx];
Rafael Espindola7f0b7272016-04-14 20:42:43 +0000226 }
Rui Ueyama69c778c2016-07-17 17:50:09 +0000227 return {Sym, IsNew};
Peter Collingbourne4f952702016-05-01 04:55:03 +0000228}
Peter Collingbournedadcc172016-04-22 18:42:48 +0000229
Rui Ueyama8fcc3af2016-10-26 18:28:08 +0000230// Construct a string in the form of "Sym in File1 and File2".
231// Used to construct an error message.
232static std::string conflictMsg(SymbolBody *Existing, InputFile *NewFile) {
233 return maybeDemangle(Existing->getName()) + " in " +
234 getFilename(Existing->File) + " and " + getFilename(NewFile);
235}
236
Peter Collingbourne4f952702016-05-01 04:55:03 +0000237// Find an existing symbol or create and insert a new one, then apply the given
238// attributes.
239template <class ELFT>
240std::pair<Symbol *, bool>
Rui Ueyamadace8382016-07-21 13:13:21 +0000241SymbolTable<ELFT>::insert(StringRef &Name, uint8_t Type, uint8_t Visibility,
Davide Italiano786d8e32016-09-29 00:40:08 +0000242 bool CanOmitFromDynSym, InputFile *File) {
Rafael Espindola05098762016-08-31 13:49:23 +0000243 bool IsUsedInRegularObj = !File || File->kind() == InputFile::ObjectKind;
Peter Collingbourne4f952702016-05-01 04:55:03 +0000244 Symbol *S;
245 bool WasInserted;
246 std::tie(S, WasInserted) = insert(Name);
247
248 // Merge in the new symbol's visibility.
249 S->Visibility = getMinVisibility(S->Visibility, Visibility);
250 if (!CanOmitFromDynSym && (Config->Shared || Config->ExportDynamic))
251 S->ExportDynamic = true;
252 if (IsUsedInRegularObj)
253 S->IsUsedInRegularObj = true;
Peter Collingbournef3a2b0e2016-05-03 18:03:47 +0000254 if (!WasInserted && S->body()->Type != SymbolBody::UnknownType &&
255 ((Type == STT_TLS) != S->body()->isTls()))
George Rimara4c7e742016-10-20 08:36:42 +0000256 error("TLS attribute mismatch for symbol: " + conflictMsg(S->body(), File));
Peter Collingbourne4f952702016-05-01 04:55:03 +0000257
258 return {S, WasInserted};
259}
260
Peter Collingbourne4f952702016-05-01 04:55:03 +0000261template <class ELFT> Symbol *SymbolTable<ELFT>::addUndefined(StringRef Name) {
262 return addUndefined(Name, STB_GLOBAL, STV_DEFAULT, /*Type*/ 0,
Davide Italiano786d8e32016-09-29 00:40:08 +0000263 /*CanOmitFromDynSym*/ false, /*File*/ nullptr);
Peter Collingbourne4f952702016-05-01 04:55:03 +0000264}
265
266template <class ELFT>
267Symbol *SymbolTable<ELFT>::addUndefined(StringRef Name, uint8_t Binding,
268 uint8_t StOther, uint8_t Type,
Rafael Espindolacc70da32016-06-15 17:56:10 +0000269 bool CanOmitFromDynSym,
Davide Italiano786d8e32016-09-29 00:40:08 +0000270 InputFile *File) {
Peter Collingbourne4f952702016-05-01 04:55:03 +0000271 Symbol *S;
272 bool WasInserted;
273 std::tie(S, WasInserted) =
Davide Italiano786d8e32016-09-29 00:40:08 +0000274 insert(Name, Type, StOther & 3, CanOmitFromDynSym, File);
Peter Collingbourne4f952702016-05-01 04:55:03 +0000275 if (WasInserted) {
276 S->Binding = Binding;
Rui Ueyama434b5612016-07-17 03:11:46 +0000277 replaceBody<Undefined>(S, Name, StOther, Type, File);
Peter Collingbourne4f952702016-05-01 04:55:03 +0000278 return S;
279 }
Peter Collingbourneca8c9942016-06-09 18:01:35 +0000280 if (Binding != STB_WEAK) {
281 if (S->body()->isShared() || S->body()->isLazy())
282 S->Binding = Binding;
283 if (auto *SS = dyn_cast<SharedSymbol<ELFT>>(S->body()))
Rui Ueyama434b5612016-07-17 03:11:46 +0000284 SS->file()->IsUsed = true;
Peter Collingbourneca8c9942016-06-09 18:01:35 +0000285 }
Peter Collingbourne4f952702016-05-01 04:55:03 +0000286 if (auto *L = dyn_cast<Lazy>(S->body())) {
287 // An undefined weak will not fetch archive members, but we have to remember
288 // its type. See also comment in addLazyArchive.
289 if (S->isWeak())
290 L->Type = Type;
Rui Ueyama55518e72016-10-28 20:57:25 +0000291 else if (InputFile *F = L->fetch())
Rui Ueyama38dbd3e2016-09-14 00:05:51 +0000292 addFile(F);
Peter Collingbourne4f952702016-05-01 04:55:03 +0000293 }
294 return S;
295}
296
297// We have a new defined symbol with the specified binding. Return 1 if the new
298// symbol should win, -1 if the new symbol should lose, or 0 if both symbols are
299// strong defined symbols.
300static int compareDefined(Symbol *S, bool WasInserted, uint8_t Binding) {
301 if (WasInserted)
302 return 1;
303 SymbolBody *Body = S->body();
304 if (Body->isLazy() || Body->isUndefined() || Body->isShared())
305 return 1;
306 if (Binding == STB_WEAK)
307 return -1;
308 if (S->isWeak())
309 return 1;
310 return 0;
311}
312
313// We have a new non-common defined symbol with the specified binding. Return 1
314// if the new symbol should win, -1 if the new symbol should lose, or 0 if there
315// is a conflict. If the new symbol wins, also update the binding.
Eugene Leviant3e6b0272016-07-28 19:24:13 +0000316static int compareDefinedNonCommon(Symbol *S, bool WasInserted,
317 uint8_t Binding) {
Peter Collingbourne4f952702016-05-01 04:55:03 +0000318 if (int Cmp = compareDefined(S, WasInserted, Binding)) {
319 if (Cmp > 0)
320 S->Binding = Binding;
321 return Cmp;
322 }
Rafael Espindolae7553e42016-08-31 13:28:33 +0000323 if (isa<DefinedCommon>(S->body())) {
Peter Collingbourne4f952702016-05-01 04:55:03 +0000324 // Non-common symbols take precedence over common symbols.
325 if (Config->WarnCommon)
Rui Ueyamad31e13f2016-09-29 21:00:23 +0000326 warn("common " + S->body()->getName() + " is overridden");
Peter Collingbourne4f952702016-05-01 04:55:03 +0000327 return 1;
328 }
329 return 0;
330}
331
332template <class ELFT>
333Symbol *SymbolTable<ELFT>::addCommon(StringRef N, uint64_t Size,
334 uint64_t Alignment, uint8_t Binding,
335 uint8_t StOther, uint8_t Type,
Davide Italiano786d8e32016-09-29 00:40:08 +0000336 InputFile *File) {
Peter Collingbourne4f952702016-05-01 04:55:03 +0000337 Symbol *S;
338 bool WasInserted;
Davide Italiano786d8e32016-09-29 00:40:08 +0000339 std::tie(S, WasInserted) =
340 insert(N, Type, StOther & 3, /*CanOmitFromDynSym*/ false, File);
Peter Collingbourne4f952702016-05-01 04:55:03 +0000341 int Cmp = compareDefined(S, WasInserted, Binding);
342 if (Cmp > 0) {
343 S->Binding = Binding;
Rafael Espindolae7553e42016-08-31 13:28:33 +0000344 replaceBody<DefinedCommon>(S, N, Size, Alignment, StOther, Type, File);
Peter Collingbourne4f952702016-05-01 04:55:03 +0000345 } else if (Cmp == 0) {
Rafael Espindolae7553e42016-08-31 13:28:33 +0000346 auto *C = dyn_cast<DefinedCommon>(S->body());
Peter Collingbourne4f952702016-05-01 04:55:03 +0000347 if (!C) {
348 // Non-common symbols take precedence over common symbols.
349 if (Config->WarnCommon)
Rui Ueyamad31e13f2016-09-29 21:00:23 +0000350 warn("common " + S->body()->getName() + " is overridden");
Peter Collingbourne4f952702016-05-01 04:55:03 +0000351 return S;
352 }
353
354 if (Config->WarnCommon)
Rui Ueyamad31e13f2016-09-29 21:00:23 +0000355 warn("multiple common of " + S->body()->getName());
Peter Collingbourne4f952702016-05-01 04:55:03 +0000356
Rafael Espindola8db87292016-08-31 13:42:08 +0000357 Alignment = C->Alignment = std::max(C->Alignment, Alignment);
358 if (Size > C->Size)
359 replaceBody<DefinedCommon>(S, N, Size, Alignment, StOther, Type, File);
Peter Collingbourne4f952702016-05-01 04:55:03 +0000360 }
361 return S;
362}
363
364template <class ELFT>
365void SymbolTable<ELFT>::reportDuplicate(SymbolBody *Existing,
366 InputFile *NewFile) {
367 std::string Msg = "duplicate symbol: " + conflictMsg(Existing, NewFile);
368 if (Config->AllowMultipleDefinition)
Rui Ueyamad31e13f2016-09-29 21:00:23 +0000369 warn(Msg);
Peter Collingbourne4f952702016-05-01 04:55:03 +0000370 else
371 error(Msg);
372}
373
374template <typename ELFT>
375Symbol *SymbolTable<ELFT>::addRegular(StringRef Name, const Elf_Sym &Sym,
376 InputSectionBase<ELFT> *Section) {
Rafael Espindola5ceeb602016-10-26 20:57:14 +0000377 return addRegular(Name, Sym.st_other, Sym.getType(), Sym.st_value,
378 Sym.st_size, Sym.getBinding(), Section);
379}
380
381template <typename ELFT>
382Symbol *SymbolTable<ELFT>::addRegular(StringRef Name, uint8_t StOther,
383 uint8_t Type, uintX_t Value, uintX_t Size,
384 uint8_t Binding,
385 InputSectionBase<ELFT> *Section) {
Peter Collingbourne4f952702016-05-01 04:55:03 +0000386 Symbol *S;
387 bool WasInserted;
Rafael Espindola5ceeb602016-10-26 20:57:14 +0000388 std::tie(S, WasInserted) = insert(Name, Type, StOther & 3,
Davide Italiano786d8e32016-09-29 00:40:08 +0000389 /*CanOmitFromDynSym*/ false,
390 Section ? Section->getFile() : nullptr);
Rafael Espindola5ceeb602016-10-26 20:57:14 +0000391 int Cmp = compareDefinedNonCommon(S, WasInserted, Binding);
Peter Collingbourne4f952702016-05-01 04:55:03 +0000392 if (Cmp > 0)
Rafael Espindola5ceeb602016-10-26 20:57:14 +0000393 replaceBody<DefinedRegular<ELFT>>(S, Name, StOther, Type, Value, Size,
394 Section);
Peter Collingbourne4f952702016-05-01 04:55:03 +0000395 else if (Cmp == 0)
396 reportDuplicate(S->body(), Section->getFile());
397 return S;
398}
399
400template <typename ELFT>
Rafael Espindola093abab2016-10-27 17:45:40 +0000401Symbol *SymbolTable<ELFT>::addRegular(StringRef Name, uint8_t StOther,
402 InputSectionBase<ELFT> *Section,
403 uint8_t Binding, uint8_t Type,
404 uintX_t Value) {
405 return addRegular(Name, StOther, Type, Value, 0, Binding, Section);
Peter Collingbourne4f952702016-05-01 04:55:03 +0000406}
407
408template <typename ELFT>
409Symbol *SymbolTable<ELFT>::addSynthetic(StringRef N,
Peter Collingbourne6a422592016-05-03 01:21:08 +0000410 OutputSectionBase<ELFT> *Section,
George Rimare1937bb2016-08-19 15:36:32 +0000411 uintX_t Value, uint8_t StOther) {
Peter Collingbourne4f952702016-05-01 04:55:03 +0000412 Symbol *S;
413 bool WasInserted;
George Rimare1937bb2016-08-19 15:36:32 +0000414 std::tie(S, WasInserted) = insert(N, STT_NOTYPE, /*Visibility*/ StOther & 0x3,
Davide Italiano786d8e32016-09-29 00:40:08 +0000415 /*CanOmitFromDynSym*/ false, nullptr);
Rafael Espindolae7553e42016-08-31 13:28:33 +0000416 int Cmp = compareDefinedNonCommon(S, WasInserted, STB_GLOBAL);
Peter Collingbourne4f952702016-05-01 04:55:03 +0000417 if (Cmp > 0)
418 replaceBody<DefinedSynthetic<ELFT>>(S, N, Value, Section);
419 else if (Cmp == 0)
420 reportDuplicate(S->body(), nullptr);
421 return S;
422}
423
424template <typename ELFT>
425void SymbolTable<ELFT>::addShared(SharedFile<ELFT> *F, StringRef Name,
426 const Elf_Sym &Sym,
427 const typename ELFT::Verdef *Verdef) {
428 // DSO symbols do not affect visibility in the output, so we pass STV_DEFAULT
429 // as the visibility, which will leave the visibility in the symbol table
430 // unchanged.
431 Symbol *S;
432 bool WasInserted;
433 std::tie(S, WasInserted) =
Davide Italiano786d8e32016-09-29 00:40:08 +0000434 insert(Name, Sym.getType(), STV_DEFAULT, /*CanOmitFromDynSym*/ true, F);
Peter Collingbourne4f952702016-05-01 04:55:03 +0000435 // Make sure we preempt DSO symbols with default visibility.
436 if (Sym.getVisibility() == STV_DEFAULT)
437 S->ExportDynamic = true;
Peter Collingbourneca8c9942016-06-09 18:01:35 +0000438 if (WasInserted || isa<Undefined>(S->body())) {
Peter Collingbourne4f952702016-05-01 04:55:03 +0000439 replaceBody<SharedSymbol<ELFT>>(S, F, Name, Sym, Verdef);
Peter Collingbourneca8c9942016-06-09 18:01:35 +0000440 if (!S->isWeak())
441 F->IsUsed = true;
442 }
Peter Collingbourne4f952702016-05-01 04:55:03 +0000443}
444
445template <class ELFT>
Rafael Espindolacceb92a2016-08-30 20:53:26 +0000446Symbol *SymbolTable<ELFT>::addBitcode(StringRef Name, uint8_t Binding,
Peter Collingbourne4f952702016-05-01 04:55:03 +0000447 uint8_t StOther, uint8_t Type,
Davide Italiano786d8e32016-09-29 00:40:08 +0000448 bool CanOmitFromDynSym, BitcodeFile *F) {
Peter Collingbourne4f952702016-05-01 04:55:03 +0000449 Symbol *S;
450 bool WasInserted;
Davide Italiano35af5b32016-08-30 20:15:03 +0000451 std::tie(S, WasInserted) =
Davide Italiano786d8e32016-09-29 00:40:08 +0000452 insert(Name, Type, StOther & 3, CanOmitFromDynSym, F);
Rafael Espindolae7553e42016-08-31 13:28:33 +0000453 int Cmp = compareDefinedNonCommon(S, WasInserted, Binding);
Peter Collingbourne4f952702016-05-01 04:55:03 +0000454 if (Cmp > 0)
Rafael Espindolaa6c97442016-08-31 12:30:34 +0000455 replaceBody<DefinedRegular<ELFT>>(S, Name, StOther, Type, F);
Peter Collingbourne4f952702016-05-01 04:55:03 +0000456 else if (Cmp == 0)
457 reportDuplicate(S->body(), F);
458 return S;
Michael J. Spencer1b348a62015-09-04 22:28:10 +0000459}
Michael J. Spencer84487f12015-07-24 21:03:07 +0000460
Rui Ueyamaf8432d92015-10-13 16:34:14 +0000461template <class ELFT> SymbolBody *SymbolTable<ELFT>::find(StringRef Name) {
Justin Lebar3c11e932016-10-18 17:50:36 +0000462 auto It = Symtab.find(CachedHashStringRef(Name));
Rui Ueyamaf8432d92015-10-13 16:34:14 +0000463 if (It == Symtab.end())
464 return nullptr;
Rui Ueyamae3357902016-07-18 01:35:00 +0000465 SymIndex V = It->second;
466 if (V.Idx == -1)
467 return nullptr;
468 return SymVector[V.Idx]->body();
Michael J. Spencer1b348a62015-09-04 22:28:10 +0000469}
470
George Rimarc91930a2016-09-02 21:17:20 +0000471// Returns a list of defined symbols that match with a given regex.
Rui Ueyama3d451792015-10-12 18:03:21 +0000472template <class ELFT>
Rui Ueyamaf91282e2016-11-03 17:57:38 +0000473std::vector<SymbolBody *> SymbolTable<ELFT>::findAll(const StringMatcher &M) {
Rui Ueyama48e42512016-06-29 04:47:39 +0000474 std::vector<SymbolBody *> Res;
Rui Ueyamad6328522016-07-18 01:34:57 +0000475 for (Symbol *Sym : SymVector) {
476 SymbolBody *B = Sym->body();
George Rimarc91930a2016-09-02 21:17:20 +0000477 StringRef Name = B->getName();
Rui Ueyamaf91282e2016-11-03 17:57:38 +0000478 if (!B->isUndefined() && M.match(Name))
Rui Ueyama48e42512016-06-29 04:47:39 +0000479 Res.push_back(B);
480 }
481 return Res;
Davide Italiano8e1131d2016-06-29 02:46:51 +0000482}
483
484template <class ELFT>
Rui Ueyama818bb2f2016-07-16 18:55:47 +0000485void SymbolTable<ELFT>::addLazyArchive(ArchiveFile *F,
486 const object::Archive::Symbol Sym) {
Peter Collingbourne4f952702016-05-01 04:55:03 +0000487 Symbol *S;
488 bool WasInserted;
Rui Ueyamadace8382016-07-21 13:13:21 +0000489 StringRef Name = Sym.getName();
490 std::tie(S, WasInserted) = insert(Name);
Peter Collingbourne4f952702016-05-01 04:55:03 +0000491 if (WasInserted) {
Rafael Espindola07543a82016-06-14 21:40:23 +0000492 replaceBody<LazyArchive>(S, *F, Sym, SymbolBody::UnknownType);
Rui Ueyamac5b95122015-12-16 23:23:14 +0000493 return;
494 }
Peter Collingbourne4f952702016-05-01 04:55:03 +0000495 if (!S->body()->isUndefined())
496 return;
Rui Ueyamac5b95122015-12-16 23:23:14 +0000497
Peter Collingbourne4f952702016-05-01 04:55:03 +0000498 // Weak undefined symbols should not fetch members from archives. If we were
499 // to keep old symbol we would not know that an archive member was available
500 // if a strong undefined symbol shows up afterwards in the link. If a strong
501 // undefined symbol never shows up, this lazy symbol will get to the end of
502 // the link and must be treated as the weak undefined one. We already marked
503 // this symbol as used when we added it to the symbol table, but we also need
504 // to preserve its type. FIXME: Move the Type field to Symbol.
505 if (S->isWeak()) {
Rafael Espindola07543a82016-06-14 21:40:23 +0000506 replaceBody<LazyArchive>(S, *F, Sym, S->body()->Type);
Peter Collingbourne4f952702016-05-01 04:55:03 +0000507 return;
508 }
Davide Italianobcdd6c62016-10-12 19:35:54 +0000509 std::pair<MemoryBufferRef, uint64_t> MBInfo = F->getMember(&Sym);
510 if (!MBInfo.first.getBuffer().empty())
Rui Ueyama55518e72016-10-28 20:57:25 +0000511 addFile(createObjectFile(MBInfo.first, F->getName(), MBInfo.second));
Peter Collingbourne4f952702016-05-01 04:55:03 +0000512}
513
514template <class ELFT>
Rafael Espindola65c65ce2016-06-14 21:56:36 +0000515void SymbolTable<ELFT>::addLazyObject(StringRef Name, LazyObjectFile &Obj) {
Peter Collingbourne4f952702016-05-01 04:55:03 +0000516 Symbol *S;
517 bool WasInserted;
518 std::tie(S, WasInserted) = insert(Name);
519 if (WasInserted) {
Rafael Espindola65c65ce2016-06-14 21:56:36 +0000520 replaceBody<LazyObject>(S, Name, Obj, SymbolBody::UnknownType);
Peter Collingbourne4f952702016-05-01 04:55:03 +0000521 return;
522 }
523 if (!S->body()->isUndefined())
524 return;
525
526 // See comment for addLazyArchive above.
Rafael Espindola65c65ce2016-06-14 21:56:36 +0000527 if (S->isWeak()) {
528 replaceBody<LazyObject>(S, Name, Obj, S->body()->Type);
529 } else {
530 MemoryBufferRef MBRef = Obj.getBuffer();
531 if (!MBRef.getBuffer().empty())
Rui Ueyama55518e72016-10-28 20:57:25 +0000532 addFile(createObjectFile(MBRef));
Rafael Espindola65c65ce2016-06-14 21:56:36 +0000533 }
Michael J. Spencer84487f12015-07-24 21:03:07 +0000534}
Rafael Espindola0e604f92015-09-25 18:56:53 +0000535
Peter Collingbourne892d49802016-04-27 00:05:03 +0000536// Process undefined (-u) flags by loading lazy symbols named by those flags.
Peter Collingbourne4f952702016-05-01 04:55:03 +0000537template <class ELFT> void SymbolTable<ELFT>::scanUndefinedFlags() {
Peter Collingbourne892d49802016-04-27 00:05:03 +0000538 for (StringRef S : Config->Undefined)
Peter Collingbourne4f952702016-05-01 04:55:03 +0000539 if (auto *L = dyn_cast_or_null<Lazy>(find(S)))
Rui Ueyama55518e72016-10-28 20:57:25 +0000540 if (InputFile *File = L->fetch())
Rui Ueyama38dbd3e2016-09-14 00:05:51 +0000541 addFile(File);
Peter Collingbourne892d49802016-04-27 00:05:03 +0000542}
543
Rui Ueyama93bfee52015-10-13 18:10:33 +0000544// This function takes care of the case in which shared libraries depend on
545// the user program (not the other way, which is usual). Shared libraries
546// may have undefined symbols, expecting that the user program provides
547// the definitions for them. An example is BSD's __progname symbol.
548// We need to put such symbols to the main program's .dynsym so that
549// shared libraries can find them.
550// Except this, we ignore undefined symbols in DSOs.
551template <class ELFT> void SymbolTable<ELFT>::scanShlibUndefined() {
Rui Ueyama38dbd3e2016-09-14 00:05:51 +0000552 for (SharedFile<ELFT> *File : SharedFiles)
Rui Ueyamaf8432d92015-10-13 16:34:14 +0000553 for (StringRef U : File->getUndefinedSymbols())
554 if (SymbolBody *Sym = find(U))
555 if (Sym->isDefined())
Peter Collingbourne4f952702016-05-01 04:55:03 +0000556 Sym->symbol()->ExportDynamic = true;
Rui Ueyamaf8432d92015-10-13 16:34:14 +0000557}
558
Rui Ueyamadad2b882016-09-02 22:15:08 +0000559// This function processes --export-dynamic-symbol and --dynamic-list.
Adhemerval Zanella9df07202016-04-13 18:51:11 +0000560template <class ELFT> void SymbolTable<ELFT>::scanDynamicList() {
561 for (StringRef S : Config->DynamicList)
562 if (SymbolBody *B = find(S))
Peter Collingbourne4f952702016-05-01 04:55:03 +0000563 B->symbol()->ExportDynamic = true;
Adhemerval Zanella9df07202016-04-13 18:51:11 +0000564}
565
George Rimar50dcece2016-07-16 12:26:39 +0000566static void setVersionId(SymbolBody *Body, StringRef VersionName,
567 StringRef Name, uint16_t Version) {
568 if (!Body || Body->isUndefined()) {
569 if (Config->NoUndefinedVersion)
570 error("version script assignment of " + VersionName + " to symbol " +
571 Name + " failed: symbol not defined");
572 return;
573 }
574
575 Symbol *Sym = Body->symbol();
Rui Ueyama962b2772016-07-16 18:45:25 +0000576 if (Sym->VersionId != Config->DefaultSymbolVersion)
Rui Ueyamad31e13f2016-09-29 21:00:23 +0000577 warn("duplicate symbol " + Name + " in version script");
George Rimar50dcece2016-07-16 12:26:39 +0000578 Sym->VersionId = Version;
579}
580
Rui Ueyamafbde7102016-09-13 20:41:06 +0000581// Returns a map from demangled symbols to symbol objects.
582// The relationship is 1:N instead of 1:1 because with the symbol
583// versioning, more than one symbol may have the same name.
George Rimar50dcece2016-07-16 12:26:39 +0000584template <class ELFT>
George Rimar31c25ae2016-09-15 12:44:38 +0000585std::map<std::string, std::vector<SymbolBody *>>
586SymbolTable<ELFT>::getDemangledSyms() {
587 std::map<std::string, std::vector<SymbolBody *>> Result;
Rui Ueyamad6328522016-07-18 01:34:57 +0000588 for (Symbol *Sym : SymVector) {
589 SymbolBody *B = Sym->body();
George Rimar31c25ae2016-09-15 12:44:38 +0000590 Result[demangle(B->getName())].push_back(B);
Rui Ueyamad6328522016-07-18 01:34:57 +0000591 }
George Rimar50dcece2016-07-16 12:26:39 +0000592 return Result;
593}
594
595static bool hasExternCpp() {
596 for (VersionDefinition &V : Config->VersionDefinitions)
597 for (SymbolVersion Sym : V.Globals)
598 if (Sym.IsExternCpp)
599 return true;
600 return false;
601}
602
George Rimar31c25ae2016-09-15 12:44:38 +0000603static ArrayRef<SymbolBody *>
604findDemangled(std::map<std::string, std::vector<SymbolBody *>> &D,
605 StringRef Name) {
George Rimarc3ec9d02016-08-30 09:29:37 +0000606 auto I = D.find(Name);
607 if (I != D.end())
608 return I->second;
George Rimar31c25ae2016-09-15 12:44:38 +0000609 return {};
George Rimarc3ec9d02016-08-30 09:29:37 +0000610}
611
George Rimar397cd87a2016-08-30 09:35:03 +0000612static std::vector<SymbolBody *>
George Rimar31c25ae2016-09-15 12:44:38 +0000613findAllDemangled(const std::map<std::string, std::vector<SymbolBody *>> &D,
Rui Ueyamaf91282e2016-11-03 17:57:38 +0000614 StringMatcher &M) {
George Rimar397cd87a2016-08-30 09:35:03 +0000615 std::vector<SymbolBody *> Res;
616 for (auto &P : D) {
Rui Ueyamaf91282e2016-11-03 17:57:38 +0000617 if (M.match(P.first))
George Rimar31c25ae2016-09-15 12:44:38 +0000618 for (SymbolBody *Body : P.second)
619 if (!Body->isUndefined())
620 Res.push_back(Body);
George Rimar397cd87a2016-08-30 09:35:03 +0000621 }
622 return Res;
623}
624
Rui Ueyamaea265042016-09-13 20:51:30 +0000625// If there's only one anonymous version definition in a version
626// script file, the script does not actullay define any symbol version,
627// but just specifies symbols visibilities. We assume that the script was
628// in the form of { global: foo; bar; local *; }. So, local is default.
629// In this function, we make specified symbols global.
630template <class ELFT> void SymbolTable<ELFT>::handleAnonymousVersion() {
631 std::vector<StringRef> Patterns;
632 for (SymbolVersion &Sym : Config->VersionScriptGlobals) {
633 if (hasWildcard(Sym.Name)) {
634 Patterns.push_back(Sym.Name);
635 continue;
636 }
637 if (SymbolBody *B = find(Sym.Name))
638 B->symbol()->VersionId = VER_NDX_GLOBAL;
639 }
640 if (Patterns.empty())
641 return;
Rui Ueyamaf91282e2016-11-03 17:57:38 +0000642 StringMatcher M(Patterns);
643 std::vector<SymbolBody *> Syms = findAll(M);
Rui Ueyamaea265042016-09-13 20:51:30 +0000644 for (SymbolBody *B : Syms)
645 B->symbol()->VersionId = VER_NDX_GLOBAL;
646}
647
Rui Ueyamadad2b882016-09-02 22:15:08 +0000648// This function processes version scripts by updating VersionId
649// member of symbols.
Peter Collingbourne66ac1d62016-04-22 20:21:26 +0000650template <class ELFT> void SymbolTable<ELFT>::scanVersionScript() {
Rui Ueyamaea265042016-09-13 20:51:30 +0000651 // Handle edge cases first.
George Rimard3566302016-06-20 11:55:12 +0000652 if (!Config->VersionScriptGlobals.empty()) {
Rui Ueyamaea265042016-09-13 20:51:30 +0000653 handleAnonymousVersion();
George Rimard3566302016-06-20 11:55:12 +0000654 return;
655 }
656
Rui Ueyamaaf469d42016-07-16 04:09:27 +0000657 if (Config->VersionDefinitions.empty())
George Rimarf73a2582016-07-07 07:45:27 +0000658 return;
659
Rui Ueyamadad2b882016-09-02 22:15:08 +0000660 // Now we have version definitions, so we need to set version ids to symbols.
661 // Each version definition has a glob pattern, and all symbols that match
662 // with the pattern get that version.
663
664 // Users can use "extern C++ {}" directive to match against demangled
665 // C++ symbols. For example, you can write a pattern such as
666 // "llvm::*::foo(int, ?)". Obviously, there's no way to handle this
667 // other than trying to match a regexp against all demangled symbols.
668 // So, if "extern C++" feature is used, we demangle all known symbols.
George Rimar31c25ae2016-09-15 12:44:38 +0000669 std::map<std::string, std::vector<SymbolBody *>> Demangled;
George Rimar50dcece2016-07-16 12:26:39 +0000670 if (hasExternCpp())
671 Demangled = getDemangledSyms();
George Rimardd64bb32016-07-13 08:19:04 +0000672
Rui Ueyamadad2b882016-09-02 22:15:08 +0000673 // First, we assign versions to exact matching symbols,
674 // i.e. version definitions not containing any glob meta-characters.
George Rimar50dcece2016-07-16 12:26:39 +0000675 for (VersionDefinition &V : Config->VersionDefinitions) {
676 for (SymbolVersion Sym : V.Globals) {
George Rimarcd574a52016-09-09 14:35:36 +0000677 if (Sym.HasWildcards)
George Rimardd64bb32016-07-13 08:19:04 +0000678 continue;
George Rimar31c25ae2016-09-15 12:44:38 +0000679
George Rimarc3ec9d02016-08-30 09:29:37 +0000680 StringRef N = Sym.Name;
George Rimar31c25ae2016-09-15 12:44:38 +0000681 if (Sym.IsExternCpp) {
682 for (SymbolBody *B : findDemangled(Demangled, N))
683 setVersionId(B, V.Name, N, V.Id);
684 continue;
685 }
686 setVersionId(find(N), V.Name, N, V.Id);
George Rimar36b2c0a2016-06-28 08:07:26 +0000687 }
George Rimarf73a2582016-07-07 07:45:27 +0000688 }
689
Rui Ueyamadad2b882016-09-02 22:15:08 +0000690 // Next, we assign versions to fuzzy matching symbols,
691 // i.e. version definitions containing glob meta-characters.
692 // Note that because the last match takes precedence over previous matches,
693 // we iterate over the definitions in the reverse order.
Rui Ueyamaaf469d42016-07-16 04:09:27 +0000694 for (size_t I = Config->VersionDefinitions.size() - 1; I != (size_t)-1; --I) {
695 VersionDefinition &V = Config->VersionDefinitions[I];
George Rimar7af64522016-08-30 09:39:36 +0000696 for (SymbolVersion &Sym : V.Globals) {
George Rimarcd574a52016-09-09 14:35:36 +0000697 if (!Sym.HasWildcards)
George Rimar7af64522016-08-30 09:39:36 +0000698 continue;
Rui Ueyamaf91282e2016-11-03 17:57:38 +0000699 StringMatcher M({Sym.Name});
Rui Ueyamadad2b882016-09-02 22:15:08 +0000700 std::vector<SymbolBody *> Syms =
Rui Ueyamaf91282e2016-11-03 17:57:38 +0000701 Sym.IsExternCpp ? findAllDemangled(Demangled, M) : findAll(M);
George Rimar397cd87a2016-08-30 09:35:03 +0000702
Rui Ueyamadad2b882016-09-02 22:15:08 +0000703 // Exact matching takes precendence over fuzzy matching,
704 // so we set a version to a symbol only if no version has been assigned
705 // to the symbol. This behavior is compatible with GNU.
706 for (SymbolBody *B : Syms)
George Rimar7af64522016-08-30 09:39:36 +0000707 if (B->symbol()->VersionId == Config->DefaultSymbolVersion)
708 B->symbol()->VersionId = V.Id;
709 }
George Rimard3566302016-06-20 11:55:12 +0000710 }
Peter Collingbourne66ac1d62016-04-22 20:21:26 +0000711}
712
Rafael Espindolae0df00b2016-02-28 00:25:54 +0000713template class elf::SymbolTable<ELF32LE>;
714template class elf::SymbolTable<ELF32BE>;
715template class elf::SymbolTable<ELF64LE>;
716template class elf::SymbolTable<ELF64BE>;