@@ -45,6 +45,7 @@ using namespace llvm::wasm;
4545
4646namespace lld ::wasm {
4747Configuration *config;
48+ Ctx ctx;
4849
4950namespace {
5051
@@ -308,7 +309,7 @@ static std::optional<std::string> searchLibraryBaseName(StringRef name) {
308309 for (StringRef dir : config->searchPaths ) {
309310 // Currently we don't enable dynamic linking at all unless -shared or -pie
310311 // are used, so don't even look for .so files in that case..
311- if (config-> isPic && !config->isStatic )
312+ if (ctx. isPic && !config->isStatic )
312313 if (std::optional<std::string> s = findFile (dir, " lib" + name + " .so" ))
313314 return s;
314315 if (std::optional<std::string> s = findFile (dir, " lib" + name + " .a" ))
@@ -571,9 +572,9 @@ static void readConfigs(opt::InputArgList &args) {
571572// This function initialize such members. See Config.h for the details
572573// of these values.
573574static void setConfigs () {
574- config-> isPic = config->pie || config->shared ;
575+ ctx. isPic = config->pie || config->shared ;
575576
576- if (config-> isPic ) {
577+ if (ctx. isPic ) {
577578 if (config->exportTable )
578579 error (" -shared/-pie is incompatible with --export-table" );
579580 config->importTable = true ;
@@ -680,7 +681,7 @@ static void checkOptions(opt::InputArgList &args) {
680681 warn (" -Bsymbolic is only meaningful when combined with -shared" );
681682 }
682683
683- if (config-> isPic ) {
684+ if (ctx. isPic ) {
684685 if (config->globalBase )
685686 error (" --global-base may not be used with -shared/-pie" );
686687 if (config->tableBase )
@@ -707,7 +708,7 @@ static Symbol *handleUndefined(StringRef name, const char *option) {
707708 if (auto *lazySym = dyn_cast<LazySymbol>(sym)) {
708709 lazySym->extract ();
709710 if (!config->whyExtract .empty ())
710- config-> whyExtractRecords .emplace_back (option, sym->getFile (), *sym);
711+ ctx. whyExtractRecords .emplace_back (option, sym->getFile (), *sym);
711712 }
712713
713714 return sym;
@@ -722,8 +723,7 @@ static void handleLibcall(StringRef name) {
722723 MemoryBufferRef mb = lazySym->getMemberBuffer ();
723724 if (isBitcode (mb)) {
724725 if (!config->whyExtract .empty ())
725- config->whyExtractRecords .emplace_back (" <libcall>" , sym->getFile (),
726- *sym);
726+ ctx.whyExtractRecords .emplace_back (" <libcall>" , sym->getFile (), *sym);
727727 lazySym->extract ();
728728 }
729729 }
@@ -742,7 +742,7 @@ static void writeWhyExtract() {
742742 }
743743
744744 os << " reference\t extracted\t symbol\n " ;
745- for (auto &entry : config-> whyExtractRecords ) {
745+ for (auto &entry : ctx. whyExtractRecords ) {
746746 os << std::get<0 >(entry) << ' \t ' << toString (std::get<1 >(entry)) << ' \t '
747747 << toString (std::get<2 >(entry)) << ' \n ' ;
748748 }
@@ -811,7 +811,7 @@ static void createSyntheticSymbols() {
811811
812812 bool is64 = config->is64 .value_or (false );
813813
814- if (config-> isPic ) {
814+ if (ctx. isPic ) {
815815 WasmSym::stackPointer =
816816 createUndefinedGlobal (" __stack_pointer" , config->is64 .value_or (false )
817817 ? &mutableGlobalTypeI64
@@ -850,7 +850,7 @@ static void createSyntheticSymbols() {
850850 " __wasm_init_tls" ));
851851 }
852852
853- if (config-> isPic ||
853+ if (ctx. isPic ||
854854 config->unresolvedSymbols == UnresolvedPolicy::ImportDynamic) {
855855 // For PIC code, or when dynamically importing addresses, we create
856856 // synthetic functions that apply relocations. These get called from
@@ -871,7 +871,7 @@ static void createOptionalSymbols() {
871871 if (!config->shared )
872872 WasmSym::dataEnd = symtab->addOptionalDataSymbol (" __data_end" );
873873
874- if (!config-> isPic ) {
874+ if (!ctx. isPic ) {
875875 WasmSym::stackLow = symtab->addOptionalDataSymbol (" __stack_low" );
876876 WasmSym::stackHigh = symtab->addOptionalDataSymbol (" __stack_high" );
877877 WasmSym::globalBase = symtab->addOptionalDataSymbol (" __global_base" );
@@ -967,8 +967,8 @@ static void processStubLibraries() {
967967 depsAdded = true ;
968968 lazy->extract ();
969969 if (!config->whyExtract .empty ())
970- config-> whyExtractRecords .emplace_back (stub_file->getName (),
971- sym->getFile (), *sym);
970+ ctx. whyExtractRecords .emplace_back (stub_file->getName (),
971+ sym->getFile (), *sym);
972972 }
973973 }
974974 }
@@ -1305,7 +1305,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
13051305 sym->forceExport = true ;
13061306 }
13071307
1308- if (!config->relocatable && !config-> isPic ) {
1308+ if (!config->relocatable && !ctx. isPic ) {
13091309 // Add synthetic dummies for weak undefined functions. Must happen
13101310 // after LTO otherwise functions may not yet have signatures.
13111311 symtab->handleWeakUndefines ();
0 commit comments