@@ -70,8 +70,7 @@ void Ctx::reset() {
70
70
isPic = false ;
71
71
legacyFunctionTable = false ;
72
72
emitBssSegments = false ;
73
- wasmSym.reset ();
74
- wasmSym = std::make_unique<WasmSym>();
73
+ sym = WasmSym{};
75
74
}
76
75
77
76
namespace {
@@ -947,14 +946,14 @@ static void createSyntheticSymbols() {
947
946
true };
948
947
static llvm::wasm::WasmGlobalType mutableGlobalTypeI64 = {WASM_TYPE_I64,
949
948
true };
950
- ctx.wasmSym -> callCtors = symtab->addSyntheticFunction (
949
+ ctx.sym . callCtors = symtab->addSyntheticFunction (
951
950
" __wasm_call_ctors" , WASM_SYMBOL_VISIBILITY_HIDDEN,
952
951
make<SyntheticFunction>(nullSignature, " __wasm_call_ctors" ));
953
952
954
953
bool is64 = ctx.arg .is64 .value_or (false );
955
954
956
955
if (ctx.isPic ) {
957
- ctx.wasmSym -> stackPointer =
956
+ ctx.sym . stackPointer =
958
957
createUndefinedGlobal (" __stack_pointer" , ctx.arg .is64 .value_or (false )
959
958
? &mutableGlobalTypeI64
960
959
: &mutableGlobalTypeI32);
@@ -964,22 +963,22 @@ static void createSyntheticSymbols() {
964
963
// See:
965
964
// https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md
966
965
auto *globalType = is64 ? &globalTypeI64 : &globalTypeI32;
967
- ctx.wasmSym -> memoryBase =
966
+ ctx.sym . memoryBase =
968
967
createUndefinedGlobal (" __memory_base" , globalType);
969
- ctx.wasmSym -> tableBase = createUndefinedGlobal (" __table_base" , globalType);
970
- ctx.wasmSym -> memoryBase ->markLive ();
971
- ctx.wasmSym -> tableBase ->markLive ();
968
+ ctx.sym . tableBase = createUndefinedGlobal (" __table_base" , globalType);
969
+ ctx.sym . memoryBase ->markLive ();
970
+ ctx.sym . tableBase ->markLive ();
972
971
} else {
973
972
// For non-PIC code
974
- ctx.wasmSym -> stackPointer = createGlobalVariable (" __stack_pointer" , true );
975
- ctx.wasmSym -> stackPointer ->markLive ();
973
+ ctx.sym . stackPointer = createGlobalVariable (" __stack_pointer" , true );
974
+ ctx.sym . stackPointer ->markLive ();
976
975
}
977
976
978
977
if (ctx.arg .sharedMemory ) {
979
- ctx.wasmSym -> tlsBase = createGlobalVariable (" __tls_base" , true );
980
- ctx.wasmSym -> tlsSize = createGlobalVariable (" __tls_size" , false );
981
- ctx.wasmSym -> tlsAlign = createGlobalVariable (" __tls_align" , false );
982
- ctx.wasmSym -> initTLS = symtab->addSyntheticFunction (
978
+ ctx.sym . tlsBase = createGlobalVariable (" __tls_base" , true );
979
+ ctx.sym . tlsSize = createGlobalVariable (" __tls_size" , false );
980
+ ctx.sym . tlsAlign = createGlobalVariable (" __tls_align" , false );
981
+ ctx.sym . initTLS = symtab->addSyntheticFunction (
983
982
" __wasm_init_tls" , WASM_SYMBOL_VISIBILITY_HIDDEN,
984
983
make<SyntheticFunction>(is64 ? i64ArgSignature : i32ArgSignature,
985
984
" __wasm_init_tls" ));
@@ -990,27 +989,27 @@ static void createOptionalSymbols() {
990
989
if (ctx.arg .relocatable )
991
990
return ;
992
991
993
- ctx.wasmSym -> dsoHandle = symtab->addOptionalDataSymbol (" __dso_handle" );
992
+ ctx.sym . dsoHandle = symtab->addOptionalDataSymbol (" __dso_handle" );
994
993
995
994
if (!ctx.arg .shared )
996
- ctx.wasmSym -> dataEnd = symtab->addOptionalDataSymbol (" __data_end" );
995
+ ctx.sym . dataEnd = symtab->addOptionalDataSymbol (" __data_end" );
997
996
998
997
if (!ctx.isPic ) {
999
- ctx.wasmSym -> stackLow = symtab->addOptionalDataSymbol (" __stack_low" );
1000
- ctx.wasmSym -> stackHigh = symtab->addOptionalDataSymbol (" __stack_high" );
1001
- ctx.wasmSym -> globalBase = symtab->addOptionalDataSymbol (" __global_base" );
1002
- ctx.wasmSym -> heapBase = symtab->addOptionalDataSymbol (" __heap_base" );
1003
- ctx.wasmSym -> heapEnd = symtab->addOptionalDataSymbol (" __heap_end" );
1004
- ctx.wasmSym -> definedMemoryBase =
998
+ ctx.sym . stackLow = symtab->addOptionalDataSymbol (" __stack_low" );
999
+ ctx.sym . stackHigh = symtab->addOptionalDataSymbol (" __stack_high" );
1000
+ ctx.sym . globalBase = symtab->addOptionalDataSymbol (" __global_base" );
1001
+ ctx.sym . heapBase = symtab->addOptionalDataSymbol (" __heap_base" );
1002
+ ctx.sym . heapEnd = symtab->addOptionalDataSymbol (" __heap_end" );
1003
+ ctx.sym . definedMemoryBase =
1005
1004
symtab->addOptionalDataSymbol (" __memory_base" );
1006
- ctx.wasmSym -> definedTableBase =
1005
+ ctx.sym . definedTableBase =
1007
1006
symtab->addOptionalDataSymbol (" __table_base" );
1008
1007
}
1009
1008
1010
- ctx.wasmSym -> firstPageEnd =
1009
+ ctx.sym . firstPageEnd =
1011
1010
symtab->addOptionalDataSymbol (" __wasm_first_page_end" );
1012
- if (ctx.wasmSym -> firstPageEnd )
1013
- ctx.wasmSym -> firstPageEnd ->setVA (ctx.arg .pageSize );
1011
+ if (ctx.sym . firstPageEnd )
1012
+ ctx.sym . firstPageEnd ->setVA (ctx.arg .pageSize );
1014
1013
1015
1014
// For non-shared memory programs we still need to define __tls_base since we
1016
1015
// allow object files built with TLS to be linked into single threaded
@@ -1022,7 +1021,7 @@ static void createOptionalSymbols() {
1022
1021
// __tls_size and __tls_align are not needed in this case since they are only
1023
1022
// needed for __wasm_init_tls (which we do not create in this case).
1024
1023
if (!ctx.arg .sharedMemory )
1025
- ctx.wasmSym -> tlsBase = createOptionalGlobal (" __tls_base" , false );
1024
+ ctx.sym . tlsBase = createOptionalGlobal (" __tls_base" , false );
1026
1025
}
1027
1026
1028
1027
static void processStubLibrariesPreLTO () {
@@ -1397,9 +1396,9 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
1397
1396
// by libc/etc., because destructors are registered dynamically with
1398
1397
// `__cxa_atexit` and friends.
1399
1398
if (!ctx.arg .relocatable && !ctx.arg .shared &&
1400
- !ctx.wasmSym -> callCtors ->isUsedInRegularObj &&
1401
- ctx.wasmSym -> callCtors ->getName () != ctx.arg .entry &&
1402
- !ctx.arg .exportedSymbols .count (ctx.wasmSym -> callCtors ->getName ())) {
1399
+ !ctx.sym . callCtors ->isUsedInRegularObj &&
1400
+ ctx.sym . callCtors ->getName () != ctx.arg .entry &&
1401
+ !ctx.arg .exportedSymbols .count (ctx.sym . callCtors ->getName ())) {
1403
1402
if (Symbol *callDtors =
1404
1403
handleUndefined (" __wasm_call_dtors" , " <internal>" )) {
1405
1404
if (auto *callDtorsFunc = dyn_cast<DefinedFunction>(callDtors)) {
@@ -1408,7 +1407,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
1408
1407
!callDtorsFunc->signature ->Returns .empty ())) {
1409
1408
error (" __wasm_call_dtors must have no argument or return values" );
1410
1409
}
1411
- ctx.wasmSym -> callDtors = callDtorsFunc;
1410
+ ctx.sym . callDtors = callDtorsFunc;
1412
1411
} else {
1413
1412
error (" __wasm_call_dtors must be a function" );
1414
1413
}
@@ -1501,7 +1500,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
1501
1500
markLive ();
1502
1501
1503
1502
// Provide the indirect function table if needed.
1504
- ctx.wasmSym -> indirectFunctionTable =
1503
+ ctx.sym . indirectFunctionTable =
1505
1504
symtab->resolveIndirectFunctionTable (/* required =*/ false );
1506
1505
1507
1506
if (errorCount ())
0 commit comments