blob: ee75d037cb90c221c38bfa600cc2343836d4d863 [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"
Michael J. Spencer84487f12015-07-24 21:03:07 +000020#include "Symbols.h"
Rafael Espindola9f77ef02016-02-12 20:54:57 +000021#include "llvm/Bitcode/ReaderWriter.h"
Rui Ueyamadeb15402016-01-07 17:20:07 +000022#include "llvm/Support/StringSaver.h"
Michael J. Spencer84487f12015-07-24 21:03:07 +000023
24using namespace llvm;
Rafael Espindoladaa92a62015-08-31 01:16:19 +000025using namespace llvm::object;
Rafael Espindola01205f72015-09-22 18:19:46 +000026using namespace llvm::ELF;
Michael J. Spencer84487f12015-07-24 21:03:07 +000027
28using namespace lld;
Rafael Espindolae0df00b2016-02-28 00:25:54 +000029using namespace lld::elf;
Michael J. Spencer84487f12015-07-24 21:03:07 +000030
Rui Ueyamac9559d92016-01-05 20:47:37 +000031// All input object files must be for the same architecture
32// (e.g. it does not make sense to link x86 object files with
33// MIPS object files.) This function checks for that error.
Rui Ueyama16ba6692016-01-29 19:41:13 +000034template <class ELFT> static bool isCompatible(InputFile *FileP) {
Rui Ueyama25b44c92015-12-16 23:31:22 +000035 auto *F = dyn_cast<ELFFileBase<ELFT>>(FileP);
36 if (!F)
Rui Ueyama16ba6692016-01-29 19:41:13 +000037 return true;
Rui Ueyama25b44c92015-12-16 23:31:22 +000038 if (F->getELFKind() == Config->EKind && F->getEMachine() == Config->EMachine)
Rui Ueyama16ba6692016-01-29 19:41:13 +000039 return true;
Rui Ueyama25b44c92015-12-16 23:31:22 +000040 StringRef A = F->getName();
41 StringRef B = Config->Emulation;
42 if (B.empty())
43 B = Config->FirstElf->getName();
Rui Ueyama16ba6692016-01-29 19:41:13 +000044 error(A + " is incompatible with " + B);
45 return false;
Rui Ueyama25b44c92015-12-16 23:31:22 +000046}
47
George Rimar2a78fce2016-04-13 18:07:57 +000048// Returns "(internal)", "foo.a(bar.o)" or "baz.o".
49static std::string getFilename(InputFile *F) {
50 if (!F)
51 return "(internal)";
52 if (!F->ArchiveName.empty())
53 return (F->ArchiveName + "(" + F->getName() + ")").str();
54 return F->getName();
55}
56
Rui Ueyamac9559d92016-01-05 20:47:37 +000057// Add symbols in File to the symbol table.
Rui Ueyama25b44c92015-12-16 23:31:22 +000058template <class ELFT>
Rui Ueyama3ce825e2015-10-09 21:07:25 +000059void SymbolTable<ELFT>::addFile(std::unique_ptr<InputFile> File) {
Rafael Espindola21f7bd42015-12-23 14:35:51 +000060 InputFile *FileP = File.get();
Rui Ueyama16ba6692016-01-29 19:41:13 +000061 if (!isCompatible<ELFT>(FileP))
62 return;
Rafael Espindola525914d2015-10-11 03:36:49 +000063
Rui Ueyama89575742015-12-16 22:59:13 +000064 // .a file
65 if (auto *F = dyn_cast<ArchiveFile>(FileP)) {
Rafael Espindola21f7bd42015-12-23 14:35:51 +000066 ArchiveFiles.emplace_back(cast<ArchiveFile>(File.release()));
Rui Ueyama89575742015-12-16 22:59:13 +000067 F->parse();
68 for (Lazy &Sym : F->getLazySymbols())
Michael J. Spencer1b348a62015-09-04 22:28:10 +000069 addLazy(&Sym);
70 return;
71 }
Rui Ueyama3d451792015-10-12 18:03:21 +000072
George Rimar2a78fce2016-04-13 18:07:57 +000073 // Lazy object file
74 if (auto *F = dyn_cast<LazyObjectFile>(FileP)) {
75 LazyObjectFiles.emplace_back(cast<LazyObjectFile>(File.release()));
76 F->parse();
77 for (Lazy &Sym : F->getLazySymbols())
78 addLazy(&Sym);
79 return;
80 }
81
82 if (Config->Trace)
83 llvm::outs() << getFilename(FileP) << "\n";
84
Rui Ueyama89575742015-12-16 22:59:13 +000085 // .so file
86 if (auto *F = dyn_cast<SharedFile<ELFT>>(FileP)) {
87 // DSOs are uniquified not by filename but by soname.
88 F->parseSoName();
Rui Ueyama131e0ff2016-01-08 22:17:42 +000089 if (!SoNames.insert(F->getSoName()).second)
Rafael Espindola6a3b5de2015-10-01 19:52:48 +000090 return;
Rui Ueyama89575742015-12-16 22:59:13 +000091
Rafael Espindola21f7bd42015-12-23 14:35:51 +000092 SharedFiles.emplace_back(cast<SharedFile<ELFT>>(File.release()));
Rui Ueyama7c713312016-01-06 01:56:36 +000093 F->parseRest();
Rui Ueyama89575742015-12-16 22:59:13 +000094 for (SharedSymbol<ELFT> &B : F->getSharedSymbols())
95 resolve(&B);
96 return;
Rafael Espindola6a3b5de2015-10-01 19:52:48 +000097 }
Rui Ueyama89575742015-12-16 22:59:13 +000098
Rui Ueyamaf8baa662016-04-07 19:24:51 +000099 // LLVM bitcode file
Rafael Espindola9f77ef02016-02-12 20:54:57 +0000100 if (auto *F = dyn_cast<BitcodeFile>(FileP)) {
101 BitcodeFiles.emplace_back(cast<BitcodeFile>(File.release()));
Rafael Espindola4de44b72016-03-02 15:43:50 +0000102 F->parse(ComdatGroups);
Rafael Espindola297ce4e2016-02-26 21:31:34 +0000103 for (SymbolBody *B : F->getSymbols())
Rui Ueyamaf7149552016-03-11 18:46:51 +0000104 if (B)
105 resolve(B);
Rafael Espindola9f77ef02016-02-12 20:54:57 +0000106 return;
107 }
108
Rui Ueyamaf8baa662016-04-07 19:24:51 +0000109 // Regular object file
Rui Ueyama89575742015-12-16 22:59:13 +0000110 auto *F = cast<ObjectFile<ELFT>>(FileP);
Rafael Espindola21f7bd42015-12-23 14:35:51 +0000111 ObjectFiles.emplace_back(cast<ObjectFile<ELFT>>(File.release()));
Rui Ueyama52d3b672016-01-06 02:06:33 +0000112 F->parse(ComdatGroups);
Rafael Espindola67d72c02016-03-11 12:06:30 +0000113 for (SymbolBody *B : F->getNonLocalSymbols())
Rui Ueyama89575742015-12-16 22:59:13 +0000114 resolve(B);
Michael J. Spencer84487f12015-07-24 21:03:07 +0000115}
116
Rafael Espindola9f77ef02016-02-12 20:54:57 +0000117template <class ELFT> void SymbolTable<ELFT>::addCombinedLtoObject() {
118 if (BitcodeFiles.empty())
119 return;
Rui Ueyama25992482016-03-22 20:52:10 +0000120
121 // Compile bitcode files.
122 Lto.reset(new BitcodeCompiler);
123 for (const std::unique_ptr<BitcodeFile> &F : BitcodeFiles)
124 Lto->add(*F);
Davide Italianobc176632016-04-15 22:38:10 +0000125 std::vector<std::unique_ptr<InputFile>> IFs = Lto->compile();
Rui Ueyama25992482016-03-22 20:52:10 +0000126
127 // Replace bitcode symbols.
Davide Italianobc176632016-04-15 22:38:10 +0000128 for (auto &IF : IFs) {
129 ObjectFile<ELFT> *Obj = cast<ObjectFile<ELFT>>(IF.release());
130
131 llvm::DenseSet<StringRef> DummyGroups;
132 Obj->parse(DummyGroups);
133 for (SymbolBody *Body : Obj->getNonLocalSymbols()) {
134 Symbol *Sym = insert(Body);
135 Sym->Body->setUsedInRegularObj();
136 if (Sym->Body->isShared())
137 Sym->Body->MustBeInDynSym = true;
138 if (Sym->Body->MustBeInDynSym)
139 Body->MustBeInDynSym = true;
140 if (!Sym->Body->isUndefined() && Body->isUndefined())
141 continue;
142 Sym->Body = Body;
143 }
144 ObjectFiles.emplace_back(Obj);
Rafael Espindola9f77ef02016-02-12 20:54:57 +0000145 }
146}
147
Rui Ueyama01a65b12015-12-24 10:37:32 +0000148// Add an undefined symbol.
Rui Ueyamaff777682015-10-09 21:12:40 +0000149template <class ELFT>
150SymbolBody *SymbolTable<ELFT>::addUndefined(StringRef Name) {
Rafael Espindolaf4765732016-04-06 13:22:41 +0000151 auto *Sym = new (Alloc)
152 UndefinedElf<ELFT>(Name, STB_GLOBAL, STV_DEFAULT, /*Type*/ 0, false);
Rui Ueyamaff777682015-10-09 21:12:40 +0000153 resolve(Sym);
154 return Sym;
Rafael Espindola1d6063e2015-09-22 21:24:52 +0000155}
156
Rui Ueyama01a65b12015-12-24 10:37:32 +0000157// Add an undefined symbol. Unlike addUndefined, that symbol
158// doesn't have to be resolved, thus "opt" (optional).
Rui Ueyamaff777682015-10-09 21:12:40 +0000159template <class ELFT>
160SymbolBody *SymbolTable<ELFT>::addUndefinedOpt(StringRef Name) {
Rafael Espindolaf4765732016-04-06 13:22:41 +0000161 auto *Sym = new (Alloc)
162 UndefinedElf<ELFT>(Name, STB_GLOBAL, STV_HIDDEN, /*Type*/ 0, true);
Rui Ueyamaff777682015-10-09 21:12:40 +0000163 resolve(Sym);
164 return Sym;
Denis Protivensky22220d52015-10-05 09:43:57 +0000165}
166
Rafael Espindola0e604f92015-09-25 18:56:53 +0000167template <class ELFT>
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +0000168DefinedRegular<ELFT> *SymbolTable<ELFT>::addAbsolute(StringRef Name,
169 uint8_t Visibility) {
Rui Ueyama79c73732016-01-08 21:53:28 +0000170 // Pass nullptr because absolute symbols have no corresponding input sections.
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +0000171 auto *Sym = new (Alloc) DefinedRegular<ELFT>(Name, STB_GLOBAL, Visibility);
Rui Ueyama79c73732016-01-08 21:53:28 +0000172 resolve(Sym);
173 return Sym;
Igor Kudrin15cd9ff2015-11-06 07:43:03 +0000174}
175
176template <class ELFT>
Rui Ueyama79c73732016-01-08 21:53:28 +0000177SymbolBody *SymbolTable<ELFT>::addSynthetic(StringRef Name,
George Rimaraa4dc202016-03-01 16:23:13 +0000178 OutputSectionBase<ELFT> &Sec,
Peter Collingbournef6e9b4e2016-04-13 16:57:28 +0000179 uintX_t Val) {
180 auto *Sym = new (Alloc) DefinedSynthetic<ELFT>(Name, Val, Sec);
Rui Ueyama3ce825e2015-10-09 21:07:25 +0000181 resolve(Sym);
Rui Ueyama79c73732016-01-08 21:53:28 +0000182 return Sym;
Rafael Espindola0e604f92015-09-25 18:56:53 +0000183}
184
Rui Ueyamac9559d92016-01-05 20:47:37 +0000185// Add Name as an "ignored" symbol. An ignored symbol is a regular
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +0000186// linker-synthesized defined symbol, but is only defined if needed.
Simon Atanasyan09dae7c2015-12-16 14:45:09 +0000187template <class ELFT>
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +0000188DefinedRegular<ELFT> *SymbolTable<ELFT>::addIgnored(StringRef Name,
189 uint8_t Visibility) {
190 if (!find(Name))
191 return nullptr;
192 return addAbsolute(Name, Visibility);
Rafael Espindola5d413262015-10-01 21:22:26 +0000193}
194
Rui Ueyamadeb15402016-01-07 17:20:07 +0000195// Rename SYM as __wrap_SYM. The original symbol is preserved as __real_SYM.
196// Used to implement --wrap.
197template <class ELFT> void SymbolTable<ELFT>::wrap(StringRef Name) {
198 if (Symtab.count(Name) == 0)
199 return;
200 StringSaver Saver(Alloc);
201 Symbol *Sym = addUndefined(Name)->getSymbol();
202 Symbol *Real = addUndefined(Saver.save("__real_" + Name))->getSymbol();
203 Symbol *Wrap = addUndefined(Saver.save("__wrap_" + Name))->getSymbol();
204 Real->Body = Sym->Body;
205 Sym->Body = Wrap->Body;
206}
207
Rui Ueyama533336a2015-12-16 22:26:48 +0000208// Returns a file from which symbol B was created.
Rui Ueyama2a65a492016-01-05 20:01:29 +0000209// If B does not belong to any file, returns a nullptr.
Rafael Espindola18f09502016-02-26 21:49:38 +0000210template <class ELFT> InputFile *SymbolTable<ELFT>::findFile(SymbolBody *B) {
Rui Ueyama533336a2015-12-16 22:26:48 +0000211 for (const std::unique_ptr<ObjectFile<ELFT>> &F : ObjectFiles) {
Rafael Espindola5d7593b2015-12-22 23:00:50 +0000212 ArrayRef<SymbolBody *> Syms = F->getSymbols();
213 if (std::find(Syms.begin(), Syms.end(), B) != Syms.end())
Rui Ueyama533336a2015-12-16 22:26:48 +0000214 return F.get();
Rafael Espindola1a49e582015-09-23 14:10:24 +0000215 }
Rafael Espindola18f09502016-02-26 21:49:38 +0000216 for (const std::unique_ptr<BitcodeFile> &F : BitcodeFiles) {
217 ArrayRef<SymbolBody *> Syms = F->getSymbols();
218 if (std::find(Syms.begin(), Syms.end(), B) != Syms.end())
219 return F.get();
220 }
Rui Ueyama533336a2015-12-16 22:26:48 +0000221 return nullptr;
222}
223
Rui Ueyamab4de5952016-01-08 22:01:33 +0000224// Construct a string in the form of "Sym in File1 and File2".
225// Used to construct an error message.
Rui Ueyama533336a2015-12-16 22:26:48 +0000226template <class ELFT>
227std::string SymbolTable<ELFT>::conflictMsg(SymbolBody *Old, SymbolBody *New) {
Rafael Espindola18f09502016-02-26 21:49:38 +0000228 InputFile *F1 = findFile(Old);
229 InputFile *F2 = findFile(New);
Rui Ueyamaf0904012015-12-16 22:26:45 +0000230 StringRef Sym = Old->getName();
Rui Ueyama71c066d2016-02-02 08:22:41 +0000231 return demangle(Sym) + " in " + getFilename(F1) + " and " + getFilename(F2);
Rafael Espindola1a49e582015-09-23 14:10:24 +0000232}
233
Michael J. Spencer84487f12015-07-24 21:03:07 +0000234// This function resolves conflicts if there's an existing symbol with
235// the same name. Decisions are made based on symbol type.
Rui Ueyama3ce825e2015-10-09 21:07:25 +0000236template <class ELFT> void SymbolTable<ELFT>::resolve(SymbolBody *New) {
Michael J. Spencer1b348a62015-09-04 22:28:10 +0000237 Symbol *Sym = insert(New);
238 if (Sym->Body == New)
239 return;
240
241 SymbolBody *Existing = Sym->Body;
242
Davide Italianoc4965002016-04-02 23:47:54 +0000243 if (auto *L = dyn_cast<Lazy>(Existing)) {
Rafael Espindolaf4765732016-04-06 13:22:41 +0000244 if (New->isUndefined()) {
245 addMemberFile(New, L);
Michael J. Spencer1b348a62015-09-04 22:28:10 +0000246 return;
247 }
Rui Ueyamac5b95122015-12-16 23:23:14 +0000248 // Found a definition for something also in an archive.
249 // Ignore the archive definition.
Rafael Espindola5cea9692016-04-05 01:38:43 +0000250 if (L->isUsedInRegularObj())
251 New->setUsedInRegularObj();
Michael J. Spencer1b348a62015-09-04 22:28:10 +0000252 Sym->Body = New;
253 return;
254 }
255
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +0000256 if (New->isTls() != Existing->isTls()) {
Rui Ueyama16ba6692016-01-29 19:41:13 +0000257 error("TLS attribute mismatch for symbol: " + conflictMsg(Existing, New));
258 return;
259 }
Igor Kudrin65bddea2015-10-09 09:58:39 +0000260
Michael J. Spencer1b348a62015-09-04 22:28:10 +0000261 // compare() returns -1, 0, or 1 if the lhs symbol is less preferable,
262 // equivalent (conflicting), or more preferable, respectively.
Peter Collingbourned0856a62016-04-05 00:47:58 +0000263 int Comp = Existing->compare(New);
Rui Ueyama2e0a9ff2016-01-06 00:09:39 +0000264 if (Comp == 0) {
George Rimar57610422016-03-11 14:43:02 +0000265 std::string S = "duplicate symbol: " + conflictMsg(Existing, New);
Rui Ueyama16ba6692016-01-29 19:41:13 +0000266 if (Config->AllowMultipleDefinition)
267 warning(S);
268 else
269 error(S);
Rui Ueyamaf0904012015-12-16 22:26:45 +0000270 return;
271 }
Rui Ueyama2e0a9ff2016-01-06 00:09:39 +0000272 if (Comp < 0)
Michael J. Spencer1b348a62015-09-04 22:28:10 +0000273 Sym->Body = New;
Michael J. Spencer1b348a62015-09-04 22:28:10 +0000274}
275
Rui Ueyamab4de5952016-01-08 22:01:33 +0000276// Find an existing symbol or create and insert a new one.
Rui Ueyama3ce825e2015-10-09 21:07:25 +0000277template <class ELFT> Symbol *SymbolTable<ELFT>::insert(SymbolBody *New) {
Michael J. Spencer84487f12015-07-24 21:03:07 +0000278 StringRef Name = New->getName();
Rafael Espindola7f0b7272016-04-14 20:42:43 +0000279 unsigned NumSyms = SymVector.size();
280 auto P = Symtab.insert(std::make_pair(Name, NumSyms));
281 Symbol *Sym;
282 if (P.second) {
Rui Ueyama3554f592015-12-17 00:01:25 +0000283 Sym = new (Alloc) Symbol{New};
Rafael Espindola7f0b7272016-04-14 20:42:43 +0000284 SymVector.push_back(Sym);
285 } else {
286 Sym = SymVector[P.first->second];
287 }
Michael J. Spencer84487f12015-07-24 21:03:07 +0000288 New->setBackref(Sym);
Michael J. Spencer1b348a62015-09-04 22:28:10 +0000289 return Sym;
290}
Michael J. Spencer84487f12015-07-24 21:03:07 +0000291
Rui Ueyamaf8432d92015-10-13 16:34:14 +0000292template <class ELFT> SymbolBody *SymbolTable<ELFT>::find(StringRef Name) {
293 auto It = Symtab.find(Name);
294 if (It == Symtab.end())
295 return nullptr;
Rafael Espindola7f0b7272016-04-14 20:42:43 +0000296 return SymVector[It->second]->Body;
Rui Ueyamaf8432d92015-10-13 16:34:14 +0000297}
298
Rui Ueyamac5b95122015-12-16 23:23:14 +0000299template <class ELFT> void SymbolTable<ELFT>::addLazy(Lazy *L) {
300 Symbol *Sym = insert(L);
Rafael Espindolaf4765732016-04-06 13:22:41 +0000301 SymbolBody *Cur = Sym->Body;
302 if (Cur == L)
Michael J. Spencer1b348a62015-09-04 22:28:10 +0000303 return;
Rafael Espindolaf4765732016-04-06 13:22:41 +0000304 if (Cur->isUndefined()) {
Rui Ueyamac5b95122015-12-16 23:23:14 +0000305 Sym->Body = L;
Rafael Espindolaf4765732016-04-06 13:22:41 +0000306 addMemberFile(Cur, L);
Rafael Espindola8614c562015-10-06 14:33:58 +0000307 }
Michael J. Spencer1b348a62015-09-04 22:28:10 +0000308}
309
Rui Ueyama3d451792015-10-12 18:03:21 +0000310template <class ELFT>
Rafael Espindolaf4765732016-04-06 13:22:41 +0000311void SymbolTable<ELFT>::addMemberFile(SymbolBody *Undef, Lazy *L) {
Rafael Espindola5cea9692016-04-05 01:38:43 +0000312 if (Undef->isUsedInRegularObj())
313 L->setUsedInRegularObj();
Rui Ueyamac5b95122015-12-16 23:23:14 +0000314 // Weak undefined symbols should not fetch members from archives.
315 // If we were to keep old symbol we would not know that an archive member was
316 // available if a strong undefined symbol shows up afterwards in the link.
317 // If a strong undefined symbol never shows up, this lazy symbol will
318 // get to the end of the link and must be treated as the weak undefined one.
319 // We set UsedInRegularObj in a similar way to what is done with shared
Rafael Espindola8176d572016-02-22 23:19:29 +0000320 // symbols and copy information to reduce how many special cases are needed.
Rui Ueyamac5b95122015-12-16 23:23:14 +0000321 if (Undef->isWeak()) {
322 L->setUsedInRegularObj();
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +0000323 L->Binding = Undef->Binding;
324 L->Type = Undef->Type;
Rafael Espindola8176d572016-02-22 23:19:29 +0000325
326 // FIXME: Do we need to copy more?
Rui Ueyamac5b95122015-12-16 23:23:14 +0000327 return;
328 }
329
330 // Fetch a member file that has the definition for L.
Michael J. Spencer1b348a62015-09-04 22:28:10 +0000331 // getMember returns nullptr if the member was already read from the library.
Rui Ueyamaf8baa662016-04-07 19:24:51 +0000332 if (std::unique_ptr<InputFile> File = L->getFile())
Rui Ueyama690db672015-10-14 22:32:10 +0000333 addFile(std::move(File));
Michael J. Spencer84487f12015-07-24 21:03:07 +0000334}
Rafael Espindola0e604f92015-09-25 18:56:53 +0000335
Rui Ueyama93bfee52015-10-13 18:10:33 +0000336// This function takes care of the case in which shared libraries depend on
337// the user program (not the other way, which is usual). Shared libraries
338// may have undefined symbols, expecting that the user program provides
339// the definitions for them. An example is BSD's __progname symbol.
340// We need to put such symbols to the main program's .dynsym so that
341// shared libraries can find them.
342// Except this, we ignore undefined symbols in DSOs.
343template <class ELFT> void SymbolTable<ELFT>::scanShlibUndefined() {
Rui Ueyamaf8432d92015-10-13 16:34:14 +0000344 for (std::unique_ptr<SharedFile<ELFT>> &File : SharedFiles)
345 for (StringRef U : File->getUndefinedSymbols())
346 if (SymbolBody *Sym = find(U))
347 if (Sym->isDefined())
Rafael Espindolaabebed92016-02-05 15:27:15 +0000348 Sym->MustBeInDynSym = true;
Rui Ueyamaf8432d92015-10-13 16:34:14 +0000349}
350
Adhemerval Zanella9df07202016-04-13 18:51:11 +0000351// This function process the dynamic list option by marking all the symbols
352// to be exported in the dynamic table.
353template <class ELFT> void SymbolTable<ELFT>::scanDynamicList() {
354 for (StringRef S : Config->DynamicList)
355 if (SymbolBody *B = find(S))
356 B->MustBeInDynSym = true;
357}
358
Rafael Espindolae0df00b2016-02-28 00:25:54 +0000359template class elf::SymbolTable<ELF32LE>;
360template class elf::SymbolTable<ELF32BE>;
361template class elf::SymbolTable<ELF64LE>;
362template class elf::SymbolTable<ELF64BE>;