[lld] [lld][WebAssembly] Fix relocation of Wasm table index with GOT access (PR #104043)

Luc Blaeser via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 21 00:26:42 PDT 2024


================
@@ -102,13 +102,24 @@ 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:
+      // These relocations target the code section.
       if (requiresGOTAccess(sym))
-        break;
-      out.elemSec->addEntry(cast<FunctionSymbol>(sym));
+        addGOTEntry(sym);
----------------
luc-blaeser wrote:

Maybe adding a GOT entry is not even needed for those PIC relocations (cf. discussion of https://github.com/llvm/llvm-project/pull/104920)?

https://github.com/llvm/llvm-project/pull/104043


More information about the llvm-commits mailing list