@@ -70,6 +70,7 @@ void Ctx::reset() {
70
70
isPic = false ;
71
71
legacyFunctionTable = false ;
72
72
emitBssSegments = false ;
73
+ sym = WasmSym{};
73
74
}
74
75
75
76
namespace {
@@ -941,14 +942,14 @@ static void createSyntheticSymbols() {
941
942
true };
942
943
static llvm::wasm::WasmGlobalType mutableGlobalTypeI64 = {WASM_TYPE_I64,
943
944
true };
944
- WasmSym:: callCtors = symtab->addSyntheticFunction (
945
+ ctx. sym . callCtors = symtab->addSyntheticFunction (
945
946
" __wasm_call_ctors" , WASM_SYMBOL_VISIBILITY_HIDDEN,
946
947
make<SyntheticFunction>(nullSignature, " __wasm_call_ctors" ));
947
948
948
949
bool is64 = ctx.arg .is64 .value_or (false );
949
950
950
951
if (ctx.isPic ) {
951
- WasmSym:: stackPointer =
952
+ ctx. sym . stackPointer =
952
953
createUndefinedGlobal (" __stack_pointer" , ctx.arg .is64 .value_or (false )
953
954
? &mutableGlobalTypeI64
954
955
: &mutableGlobalTypeI32);
@@ -958,45 +959,44 @@ static void createSyntheticSymbols() {
958
959
// See:
959
960
// https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md
960
961
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 ();
965
966
} else {
966
967
// 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 ();
969
970
}
970
971
971
972
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 (
976
977
" __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" ));
980
980
}
981
981
}
982
982
983
983
static void createOptionalSymbols () {
984
984
if (ctx.arg .relocatable )
985
985
return ;
986
986
987
- WasmSym:: dsoHandle = symtab->addOptionalDataSymbol (" __dso_handle" );
987
+ ctx. sym . dsoHandle = symtab->addOptionalDataSymbol (" __dso_handle" );
988
988
989
989
if (!ctx.arg .shared )
990
- WasmSym:: dataEnd = symtab->addOptionalDataSymbol (" __data_end" );
990
+ ctx. sym . dataEnd = symtab->addOptionalDataSymbol (" __data_end" );
991
991
992
992
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" );
1000
1000
}
1001
1001
1002
1002
// For non-shared memory programs we still need to define __tls_base since we
@@ -1009,7 +1009,7 @@ static void createOptionalSymbols() {
1009
1009
// __tls_size and __tls_align are not needed in this case since they are only
1010
1010
// needed for __wasm_init_tls (which we do not create in this case).
1011
1011
if (!ctx.arg .sharedMemory )
1012
- WasmSym:: tlsBase = createOptionalGlobal (" __tls_base" , false );
1012
+ ctx. sym . tlsBase = createOptionalGlobal (" __tls_base" , false );
1013
1013
}
1014
1014
1015
1015
static void processStubLibrariesPreLTO () {
@@ -1384,9 +1384,9 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
1384
1384
// by libc/etc., because destructors are registered dynamically with
1385
1385
// `__cxa_atexit` and friends.
1386
1386
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 ())) {
1390
1390
if (Symbol *callDtors =
1391
1391
handleUndefined (" __wasm_call_dtors" , " <internal>" )) {
1392
1392
if (auto *callDtorsFunc = dyn_cast<DefinedFunction>(callDtors)) {
@@ -1395,7 +1395,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
1395
1395
!callDtorsFunc->signature ->Returns .empty ())) {
1396
1396
error (" __wasm_call_dtors must have no argument or return values" );
1397
1397
}
1398
- WasmSym:: callDtors = callDtorsFunc;
1398
+ ctx. sym . callDtors = callDtorsFunc;
1399
1399
} else {
1400
1400
error (" __wasm_call_dtors must be a function" );
1401
1401
}
@@ -1488,7 +1488,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
1488
1488
markLive ();
1489
1489
1490
1490
// Provide the indirect function table if needed.
1491
- WasmSym:: indirectFunctionTable =
1491
+ ctx. sym . indirectFunctionTable =
1492
1492
symtab->resolveIndirectFunctionTable (/* required =*/ false );
1493
1493
1494
1494
if (errorCount ())
0 commit comments