[PATCH] D104495: [lld][WebAssembly] Fix crash calling weakly undefined function in PIC code
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 17 17:10:26 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd01e673a9f04: [lld][WebAssembly] Fix crash calling weakly undefined function in PIC code (authored by sbc100).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104495/new/
https://reviews.llvm.org/D104495
Files:
lld/test/wasm/weak-undefined-pic.s
lld/wasm/InputChunks.cpp
lld/wasm/Writer.cpp
Index: lld/wasm/Writer.cpp
===================================================================
--- lld/wasm/Writer.cpp
+++ lld/wasm/Writer.cpp
@@ -546,7 +546,7 @@
static bool shouldImport(Symbol *sym) {
if (!sym->isUndefined())
return false;
- if (sym->isWeak() && !config->relocatable)
+ if (sym->isWeak() && !config->relocatable && !config->isPic)
return false;
if (!sym->isLive())
return false;
Index: lld/wasm/InputChunks.cpp
===================================================================
--- lld/wasm/InputChunks.cpp
+++ lld/wasm/InputChunks.cpp
@@ -106,13 +106,12 @@
for (const WasmRelocation &rel : relocations) {
uint8_t *loc = buf + rel.Offset - inputSectionOffset;
- auto value = file->calcNewValue(rel, tombstone, this);
LLVM_DEBUG(dbgs() << "apply reloc: type=" << relocTypeToString(rel.Type));
if (rel.Type != R_WASM_TYPE_INDEX_LEB)
LLVM_DEBUG(dbgs() << " sym=" << file->getSymbols()[rel.Index]->getName());
LLVM_DEBUG(dbgs() << " addend=" << rel.Addend << " index=" << rel.Index
- << " value=" << value << " offset=" << rel.Offset
- << "\n");
+ << " offset=" << rel.Offset << "\n");
+ auto value = file->calcNewValue(rel, tombstone, this);
switch (rel.Type) {
case R_WASM_TYPE_INDEX_LEB:
Index: lld/test/wasm/weak-undefined-pic.s
===================================================================
--- lld/test/wasm/weak-undefined-pic.s
+++ lld/test/wasm/weak-undefined-pic.s
@@ -22,6 +22,7 @@
_start:
.functype _start () -> ()
call get_foo_addr
+ call foo
end_function
.weak foo
@@ -75,7 +76,10 @@
# RUN: obj2yaml %t3.wasm | FileCheck %s --check-prefix=IMPORT
# IMPORT: - Type: IMPORT
-# IMPORT: - Module: GOT.func
+# IMPORT: Field: foo
+# IMPORT-NEXT: Kind: FUNCTION
+# IMPORT-NEXT: SigIndex: 0
+# IMPORT-NEXT: - Module: GOT.func
# IMPORT-NEXT: Field: foo
# IMPORT-NEXT: Kind: GLOBAL
# IMPORT-NEXT: GlobalType: I32
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104495.352879.patch
Type: text/x-patch
Size: 2145 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210618/e4c472f4/attachment.bin>
More information about the llvm-commits
mailing list