[lld] [lld][WebAssembly] Fix relocation of Wasm table index with GOT access (PR #104043)
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 12:49:34 PDT 2024
================
@@ -102,13 +102,27 @@ void scanRelocations(InputChunk *chunk) {
switch (reloc.Type) {
case R_WASM_TABLE_INDEX_I32:
case R_WASM_TABLE_INDEX_I64:
+ // These relocations target the data section and are handled
+ // by `generateRelocationCode`. GOT accesses are handled below.
+ if (requiresGOTAccess(sym))
+ break;
+ out.elemSec->addEntry(cast<FunctionSymbol>(sym));
+ break;
case R_WASM_TABLE_INDEX_SLEB:
case R_WASM_TABLE_INDEX_SLEB64:
case R_WASM_TABLE_INDEX_REL_SLEB:
case R_WASM_TABLE_INDEX_REL_SLEB64:
- if (requiresGOTAccess(sym))
- break;
- out.elemSec->addEntry(cast<FunctionSymbol>(sym));
+ // These relocations target the code section and can only be resolved
+ // at linking time.
+ if (requiresGOTAccess(sym)) {
+ addGOTEntry(sym);
+ }
+ // The indirect call needs a table element that can only be added
+ // for defined functions.
+ if (sym->isDefined()) {
+ out.elemSec->addEntry(cast<FunctionSymbol>(sym));
+ }
+ // Unresolved symbols are handled below.
----------------
sbc100 wrote:
Undefined?
https://github.com/llvm/llvm-project/pull/104043
More information about the llvm-commits
mailing list