[PATCH] D155542: [lld][WebAssembly] Fix func reloc for internal GOT with extended-const
YAMAMOTO Takashi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 17 21:23:43 PDT 2023
yamt created this revision.
Herald added subscribers: pmatos, asb, sunfish, jgravelle-google, sbc100, dschuff.
Herald added a project: All.
yamt requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D155542
Files:
lld/wasm/SyntheticSections.cpp
Index: lld/wasm/SyntheticSections.cpp
===================================================================
--- lld/wasm/SyntheticSections.cpp
+++ lld/wasm/SyntheticSections.cpp
@@ -497,6 +497,17 @@
writeU8(os, is64 ? WASM_OPCODE_I64_ADD : WASM_OPCODE_I32_ADD, "add");
}
writeU8(os, WASM_OPCODE_END, "opcode:end");
+ } else if (config->extendedConst && config->isPic && !sym->isStub &&
+ isa<FunctionSymbol>(sym)) {
+ // We can use an extended init expression to add a constant
+ // offset of __table_base.
+ auto *f = cast<FunctionSymbol>(sym);
+ writeU8(os, WASM_OPCODE_GLOBAL_GET, "global get");
+ writeUleb128(os, WasmSym::tableBase->getGlobalIndex(),
+ "literal (global index)");
+ writePtrConst(os, f->getTableIndex(), is64, "offset");
+ writeU8(os, is64 ? WASM_OPCODE_I64_ADD : WASM_OPCODE_I32_ADD, "add");
+ writeU8(os, WASM_OPCODE_END, "opcode:end");
} else {
WasmInitExpr initExpr;
if (auto *d = dyn_cast<DefinedData>(sym))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155542.541312.patch
Type: text/x-patch
Size: 1049 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230718/0366509f/attachment.bin>
More information about the llvm-commits
mailing list