@@ -109,6 +109,7 @@ void Ctx::reset() {
109
109
110
110
in.reset ();
111
111
sym = ElfSym{};
112
+ symtab = std::make_unique<SymbolTable>();
112
113
113
114
memoryBuffers.clear ();
114
115
objectFiles.clear ();
@@ -155,7 +156,6 @@ bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
155
156
context->e .cleanupCallback = []() {
156
157
elf::ctx.reset ();
157
158
elf::ctx.partitions .emplace_back ();
158
- symtab = SymbolTable ();
159
159
160
160
SharedFile::vernauxNum = 0 ;
161
161
};
@@ -167,6 +167,7 @@ bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
167
167
LinkerScript script (ctx);
168
168
ctx.script = &script;
169
169
ctx.symAux .emplace_back ();
170
+ ctx.symtab = std::make_unique<SymbolTable>();
170
171
171
172
ctx.partitions .clear ();
172
173
ctx.partitions .emplace_back ();
@@ -2194,7 +2195,7 @@ static void handleUndefinedGlob(Ctx &ctx, StringRef arg) {
2194
2195
// Calling sym->extract() in the loop is not safe because it may add new
2195
2196
// symbols to the symbol table, invalidating the current iterator.
2196
2197
SmallVector<Symbol *, 0 > syms;
2197
- for (Symbol *sym : symtab. getSymbols ())
2198
+ for (Symbol *sym : ctx. symtab -> getSymbols ())
2198
2199
if (!sym->isPlaceholder () && pat->match (sym->getName ()))
2199
2200
syms.push_back (sym);
2200
2201
@@ -2203,7 +2204,7 @@ static void handleUndefinedGlob(Ctx &ctx, StringRef arg) {
2203
2204
}
2204
2205
2205
2206
static void handleLibcall (Ctx &ctx, StringRef name) {
2206
- Symbol *sym = symtab. find (name);
2207
+ Symbol *sym = ctx. symtab -> find (name);
2207
2208
if (sym && sym->isLazy () && isa<BitcodeFile>(sym->file )) {
2208
2209
if (!ctx.arg .whyExtract .empty ())
2209
2210
ctx.whyExtractRecords .emplace_back (" <libcall>" , sym->file , *sym);
@@ -2390,7 +2391,7 @@ template <class ELFT>
2390
2391
static void findKeepUniqueSections (Ctx &ctx, opt::InputArgList &args) {
2391
2392
for (auto *arg : args.filtered (OPT_keep_unique)) {
2392
2393
StringRef name = arg->getValue ();
2393
- auto *d = dyn_cast_or_null<Defined>(symtab. find (name));
2394
+ auto *d = dyn_cast_or_null<Defined>(ctx. symtab -> find (name));
2394
2395
if (!d || !d->section ) {
2395
2396
warn (" could not find symbol " + name + " to keep unique" );
2396
2397
continue ;
@@ -2405,7 +2406,7 @@ static void findKeepUniqueSections(Ctx &ctx, opt::InputArgList &args) {
2405
2406
2406
2407
// Symbols in the dynsym could be address-significant in other executables
2407
2408
// or DSOs, so we conservatively mark them as address-significant.
2408
- for (Symbol *sym : symtab. getSymbols ())
2409
+ for (Symbol *sym : ctx. symtab -> getSymbols ())
2409
2410
if (sym->includeInDynsym ())
2410
2411
markAddrsig (sym);
2411
2412
@@ -2574,24 +2575,24 @@ static std::vector<WrappedSymbol> addWrappedSymbols(opt::InputArgList &args) {
2574
2575
if (!seen.insert (name).second )
2575
2576
continue ;
2576
2577
2577
- Symbol *sym = symtab. find (name);
2578
+ Symbol *sym = ctx. symtab -> find (name);
2578
2579
if (!sym)
2579
2580
continue ;
2580
2581
2581
- Symbol *wrap =
2582
- symtab. addUnusedUndefined ( saver ().save (" __wrap_" + name), sym->binding );
2582
+ Symbol *wrap = ctx. symtab -> addUnusedUndefined (
2583
+ saver ().save (" __wrap_" + name), sym->binding );
2583
2584
2584
2585
// If __real_ is referenced, pull in the symbol if it is lazy. Do this after
2585
2586
// processing __wrap_ as that may have referenced __real_.
2586
2587
StringRef realName = saver ().save (" __real_" + name);
2587
- if (Symbol *real = symtab. find (realName)) {
2588
- symtab. addUnusedUndefined (name, sym->binding );
2588
+ if (Symbol *real = ctx. symtab -> find (realName)) {
2589
+ ctx. symtab -> addUnusedUndefined (name, sym->binding );
2589
2590
// Update sym's binding, which will replace real's later in
2590
2591
// SymbolTable::wrap.
2591
2592
sym->binding = real->binding ;
2592
2593
}
2593
2594
2594
- Symbol *real = symtab. addUnusedUndefined (realName);
2595
+ Symbol *real = ctx. symtab -> addUnusedUndefined (realName);
2595
2596
v.push_back ({sym, real, wrap});
2596
2597
2597
2598
// We want to tell LTO not to inline symbols to be overwritten
@@ -2626,7 +2627,7 @@ static void combineVersionedSymbol(Symbol &sym,
2626
2627
//
2627
2628
// * There is a definition of foo@v1 and foo@@v1.
2628
2629
// * There is a definition of foo@v1 and foo.
2629
- Defined *sym2 = dyn_cast_or_null<Defined>(symtab. find (sym.getName ()));
2630
+ Defined *sym2 = dyn_cast_or_null<Defined>(ctx. symtab -> find (sym.getName ()));
2630
2631
if (!sym2)
2631
2632
return ;
2632
2633
const char *suffix2 = sym2->getVersionSuffix ();
@@ -2681,7 +2682,7 @@ static void redirectSymbols(Ctx &ctx, ArrayRef<WrappedSymbol> wrapped) {
2681
2682
// symbols with a non-default version (foo@v1) and check whether it should be
2682
2683
// combined with foo or foo@@v1.
2683
2684
if (ctx.arg .versionDefinitions .size () > 2 )
2684
- for (Symbol *sym : symtab. getSymbols ())
2685
+ for (Symbol *sym : ctx. symtab -> getSymbols ())
2685
2686
if (sym->hasVersionSuffix )
2686
2687
combineVersionedSymbol (*sym, map);
2687
2688
@@ -2697,7 +2698,7 @@ static void redirectSymbols(Ctx &ctx, ArrayRef<WrappedSymbol> wrapped) {
2697
2698
2698
2699
// Update pointers in the symbol table.
2699
2700
for (const WrappedSymbol &w : wrapped)
2700
- symtab. wrap (w.sym , w.real , w.wrap );
2701
+ ctx. symtab -> wrap (w.sym , w.real , w.wrap );
2701
2702
}
2702
2703
2703
2704
static void reportMissingFeature (StringRef config, const Twine &report) {
@@ -2861,22 +2862,22 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
2861
2862
2862
2863
// Handle --trace-symbol.
2863
2864
for (auto *arg : args.filtered (OPT_trace_symbol))
2864
- symtab. insert (arg->getValue ())->traced = true ;
2865
+ ctx. symtab -> insert (arg->getValue ())->traced = true ;
2865
2866
2866
2867
ctx.internalFile = createInternalFile (" <internal>" );
2867
2868
2868
2869
// Handle -u/--undefined before input files. If both a.a and b.so define foo,
2869
2870
// -u foo a.a b.so will extract a.a.
2870
2871
for (StringRef name : ctx.arg .undefined )
2871
- symtab. addUnusedUndefined (name)->referenced = true ;
2872
+ ctx. symtab -> addUnusedUndefined (name)->referenced = true ;
2872
2873
2873
2874
parseFiles (files, armCmseImpLib);
2874
2875
2875
2876
// Create dynamic sections for dynamic linking and static PIE.
2876
2877
ctx.arg .hasDynSymTab = !ctx.sharedFiles .empty () || ctx.arg .isPic ;
2877
2878
2878
2879
// If an entry symbol is in a static archive, pull out that file now.
2879
- if (Symbol *sym = symtab. find (ctx.arg .entry ))
2880
+ if (Symbol *sym = ctx. symtab -> find (ctx.arg .entry ))
2880
2881
handleUndefined (ctx, sym, " --entry" );
2881
2882
2882
2883
// Handle the `--undefined-glob <pattern>` options.
@@ -2890,13 +2891,13 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
2890
2891
2891
2892
// Prevent LTO from removing any definition referenced by -u.
2892
2893
for (StringRef name : ctx.arg .undefined )
2893
- if (Defined *sym = dyn_cast_or_null<Defined>(symtab. find (name)))
2894
+ if (Defined *sym = dyn_cast_or_null<Defined>(ctx. symtab -> find (name)))
2894
2895
sym->isUsedInRegularObj = true ;
2895
2896
2896
2897
// Mark -init and -fini symbols so that the LTO doesn't eliminate them.
2897
- if (Symbol *sym = dyn_cast_or_null<Defined>(symtab. find (ctx.arg .init )))
2898
+ if (Symbol *sym = dyn_cast_or_null<Defined>(ctx. symtab -> find (ctx.arg .init )))
2898
2899
sym->isUsedInRegularObj = true ;
2899
- if (Symbol *sym = dyn_cast_or_null<Defined>(symtab. find (ctx.arg .fini )))
2900
+ if (Symbol *sym = dyn_cast_or_null<Defined>(ctx. symtab -> find (ctx.arg .fini )))
2900
2901
sym->isUsedInRegularObj = true ;
2901
2902
2902
2903
// If any of our inputs are bitcode files, the LTO code generator may create
@@ -2977,7 +2978,7 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
2977
2978
// name "foo@ver1") rather do harm, so we don't call this if -r is given.
2978
2979
if (!ctx.arg .relocatable ) {
2979
2980
llvm::TimeTraceScope timeScope (" Process symbol versions" );
2980
- symtab. scanVersionScript ();
2981
+ ctx. symtab -> scanVersionScript ();
2981
2982
}
2982
2983
2983
2984
// Skip the normal linked output if some LTO options are specified.
0 commit comments