[PATCH] D79247: [lld][WebAssembly] Honor --allow-undefined for data symbols too
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 1 17:15:06 PDT 2020
sbc100 created this revision.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff.
Herald added a project: LLVM.
sbc100 added reviewers: ruiu, kripken.
sbc100 added a comment.
Followup: https://reviews.llvm.org/D79248
This was originally the way this worked before before
https://reviews.llvm.org/D60882.
In retrospect it seems inconsistent that `--allow-undefined` doesn't
work for all symbols. See:
https://groups.google.com/g/emscripten-discuss/c/HSRgQiIq1gI/m/Kt9oFWHiAwAJ
I'm also planning a followup change which implement the full
`--unresolved-symbols=..` flags supported by ELF linkers (both ld and
ld.lld) since it seems more standard.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D79247
Files:
lld/test/wasm/undefined-data.ll
lld/wasm/Relocations.cpp
Index: lld/wasm/Relocations.cpp
===================================================================
--- lld/wasm/Relocations.cpp
+++ lld/wasm/Relocations.cpp
@@ -21,13 +21,6 @@
}
static bool allowUndefined(const Symbol* sym) {
- // Historically --allow-undefined doesn't work for data symbols since we don't
- // have any way to represent these as imports in the final binary. The idea
- // behind allowing undefined symbols is to allow importing these symbols from
- // the embedder and we can't do this for data symbols (at least not without
- // compiling with -fPIC)
- if (isa<DataSymbol>(sym))
- return false;
// Undefined functions with explicit import name are allowed to be undefined
// at link time.
if (auto *F = dyn_cast<UndefinedFunction>(sym))
Index: lld/test/wasm/undefined-data.ll
===================================================================
--- lld/test/wasm/undefined-data.ll
+++ lld/test/wasm/undefined-data.ll
@@ -1,6 +1,6 @@
; RUN: llc -filetype=obj %s -o %t.o
; RUN: not wasm-ld -o %t.wasm %t.o 2>&1 | FileCheck %s -check-prefix=UNDEF
-; RUN: not wasm-ld --allow-undefined -o %t.wasm %t.o 2>&1 | FileCheck %s -check-prefix=UNDEF
+; RUN: wasm-ld --allow-undefined -o %t.wasm %t.o
; RUN: not wasm-ld --shared -o %t.wasm %t.o 2>&1 | FileCheck %s -check-prefix=SHARED
target triple = "wasm32-unknown-unknown"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79247.261488.patch
Type: text/x-patch
Size: 1362 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200502/5729a419/attachment.bin>
More information about the llvm-commits
mailing list