@@ -70,6 +70,7 @@ void Ctx::reset() {
7070 isPic = false ;
7171 legacyFunctionTable = false ;
7272 emitBssSegments = false ;
73+ sym = WasmSym{};
7374}
7475
7576namespace {
@@ -941,14 +942,14 @@ static void createSyntheticSymbols() {
941942 true };
942943 static llvm::wasm::WasmGlobalType mutableGlobalTypeI64 = {WASM_TYPE_I64,
943944 true };
944- WasmSym:: callCtors = symtab->addSyntheticFunction (
945+ ctx. sym . callCtors = symtab->addSyntheticFunction (
945946 " __wasm_call_ctors" , WASM_SYMBOL_VISIBILITY_HIDDEN,
946947 make<SyntheticFunction>(nullSignature, " __wasm_call_ctors" ));
947948
948949 bool is64 = ctx.arg .is64 .value_or (false );
949950
950951 if (ctx.isPic ) {
951- WasmSym:: stackPointer =
952+ ctx. sym . stackPointer =
952953 createUndefinedGlobal (" __stack_pointer" , ctx.arg .is64 .value_or (false )
953954 ? &mutableGlobalTypeI64
954955 : &mutableGlobalTypeI32);
@@ -958,45 +959,44 @@ static void createSyntheticSymbols() {
958959 // See:
959960 // https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md
960961 auto *globalType = is64 ? &globalTypeI64 : &globalTypeI32;
961- WasmSym:: memoryBase = createUndefinedGlobal (" __memory_base" , globalType);
962- WasmSym:: tableBase = createUndefinedGlobal (" __table_base" , globalType);
963- WasmSym:: memoryBase->markLive ();
964- WasmSym:: tableBase->markLive ();
962+ ctx. sym . memoryBase = createUndefinedGlobal (" __memory_base" , globalType);
963+ ctx. sym . tableBase = createUndefinedGlobal (" __table_base" , globalType);
964+ ctx. sym . memoryBase ->markLive ();
965+ ctx. sym . tableBase ->markLive ();
965966 } else {
966967 // For non-PIC code
967- WasmSym:: stackPointer = createGlobalVariable (" __stack_pointer" , true );
968- WasmSym:: stackPointer->markLive ();
968+ ctx. sym . stackPointer = createGlobalVariable (" __stack_pointer" , true );
969+ ctx. sym . stackPointer ->markLive ();
969970 }
970971
971972 if (ctx.arg .sharedMemory ) {
972- WasmSym:: tlsBase = createGlobalVariable (" __tls_base" , true );
973- WasmSym:: tlsSize = createGlobalVariable (" __tls_size" , false );
974- WasmSym:: tlsAlign = createGlobalVariable (" __tls_align" , false );
975- WasmSym:: initTLS = symtab->addSyntheticFunction (
973+ ctx. sym . tlsBase = createGlobalVariable (" __tls_base" , true );
974+ ctx. sym . tlsSize = createGlobalVariable (" __tls_size" , false );
975+ ctx. sym . tlsAlign = createGlobalVariable (" __tls_align" , false );
976+ ctx. sym . initTLS = symtab->addSyntheticFunction (
976977 " __wasm_init_tls" , WASM_SYMBOL_VISIBILITY_HIDDEN,
977- make<SyntheticFunction>(
978- is64 ? i64ArgSignature : i32ArgSignature,
979- " __wasm_init_tls" ));
978+ make<SyntheticFunction>(is64 ? i64ArgSignature : i32ArgSignature,
979+ " __wasm_init_tls" ));
980980 }
981981}
982982
983983static void createOptionalSymbols () {
984984 if (ctx.arg .relocatable )
985985 return ;
986986
987- WasmSym:: dsoHandle = symtab->addOptionalDataSymbol (" __dso_handle" );
987+ ctx. sym . dsoHandle = symtab->addOptionalDataSymbol (" __dso_handle" );
988988
989989 if (!ctx.arg .shared )
990- WasmSym:: dataEnd = symtab->addOptionalDataSymbol (" __data_end" );
990+ ctx. sym . dataEnd = symtab->addOptionalDataSymbol (" __data_end" );
991991
992992 if (!ctx.isPic ) {
993- WasmSym:: stackLow = symtab->addOptionalDataSymbol (" __stack_low" );
994- WasmSym:: stackHigh = symtab->addOptionalDataSymbol (" __stack_high" );
995- WasmSym:: globalBase = symtab->addOptionalDataSymbol (" __global_base" );
996- WasmSym:: heapBase = symtab->addOptionalDataSymbol (" __heap_base" );
997- WasmSym:: heapEnd = symtab->addOptionalDataSymbol (" __heap_end" );
998- WasmSym:: definedMemoryBase = symtab->addOptionalDataSymbol (" __memory_base" );
999- WasmSym:: definedTableBase = symtab->addOptionalDataSymbol (" __table_base" );
993+ ctx. sym . stackLow = symtab->addOptionalDataSymbol (" __stack_low" );
994+ ctx. sym . stackHigh = symtab->addOptionalDataSymbol (" __stack_high" );
995+ ctx. sym . globalBase = symtab->addOptionalDataSymbol (" __global_base" );
996+ ctx. sym . heapBase = symtab->addOptionalDataSymbol (" __heap_base" );
997+ ctx. sym . heapEnd = symtab->addOptionalDataSymbol (" __heap_end" );
998+ ctx. sym . definedMemoryBase = symtab->addOptionalDataSymbol (" __memory_base" );
999+ ctx. sym . definedTableBase = symtab->addOptionalDataSymbol (" __table_base" );
10001000 }
10011001
10021002 // For non-shared memory programs we still need to define __tls_base since we
@@ -1009,7 +1009,7 @@ static void createOptionalSymbols() {
10091009 // __tls_size and __tls_align are not needed in this case since they are only
10101010 // needed for __wasm_init_tls (which we do not create in this case).
10111011 if (!ctx.arg .sharedMemory )
1012- WasmSym:: tlsBase = createOptionalGlobal (" __tls_base" , false );
1012+ ctx. sym . tlsBase = createOptionalGlobal (" __tls_base" , false );
10131013}
10141014
10151015static void processStubLibrariesPreLTO () {
@@ -1384,9 +1384,9 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
13841384 // by libc/etc., because destructors are registered dynamically with
13851385 // `__cxa_atexit` and friends.
13861386 if (!ctx.arg .relocatable && !ctx.arg .shared &&
1387- !WasmSym:: callCtors->isUsedInRegularObj &&
1388- WasmSym:: callCtors->getName () != ctx.arg .entry &&
1389- !ctx.arg .exportedSymbols .count (WasmSym:: callCtors->getName ())) {
1387+ !ctx. sym . callCtors ->isUsedInRegularObj &&
1388+ ctx. sym . callCtors ->getName () != ctx.arg .entry &&
1389+ !ctx.arg .exportedSymbols .count (ctx. sym . callCtors ->getName ())) {
13901390 if (Symbol *callDtors =
13911391 handleUndefined (" __wasm_call_dtors" , " <internal>" )) {
13921392 if (auto *callDtorsFunc = dyn_cast<DefinedFunction>(callDtors)) {
@@ -1395,7 +1395,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
13951395 !callDtorsFunc->signature ->Returns .empty ())) {
13961396 error (" __wasm_call_dtors must have no argument or return values" );
13971397 }
1398- WasmSym:: callDtors = callDtorsFunc;
1398+ ctx. sym . callDtors = callDtorsFunc;
13991399 } else {
14001400 error (" __wasm_call_dtors must be a function" );
14011401 }
@@ -1488,7 +1488,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
14881488 markLive ();
14891489
14901490 // Provide the indirect function table if needed.
1491- WasmSym:: indirectFunctionTable =
1491+ ctx. sym . indirectFunctionTable =
14921492 symtab->resolveIndirectFunctionTable (/* required =*/ false );
14931493
14941494 if (errorCount ())
0 commit comments