Skip to content

Commit e12642f

Browse files
[Legacy Driver][wasm] Pass --table-base to reserve low function addresses
WebAssembly does not have a reserved address space by default, so we need to explicitly reserve low addresses for extra inhabitants for enum types with pointer payloads. #39300 added `--global-base` to reserve low data addresses, but we also need to reserve low function addresses with `--table-base` for function pointers because WebAssembly uses a separate address space for function pointers.
1 parent 6915a36 commit e12642f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/Driver/WebAssemblyToolChains.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ toolchains::WebAssembly::constructInvocation(const DynamicLinkJobAction &job,
194194
Arguments.push_back(context.Args.MakeArgString(
195195
Twine("--global-base=") +
196196
std::to_string(SWIFT_ABI_WASM32_LEAST_VALID_POINTER)));
197+
Arguments.push_back("-Xlinker");
198+
Arguments.push_back(context.Args.MakeArgString(
199+
Twine("--table-base=") +
200+
std::to_string(SWIFT_ABI_WASM32_LEAST_VALID_POINTER)));
197201

198202
// These custom arguments should be right before the object file at the end.
199203
context.Args.AddAllArgs(Arguments, options::OPT_linker_option_Group);

0 commit comments

Comments
 (0)