[lld] [lld][WebAssembly]: Restore non-pie dynamic-linking executable (PR #108146)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 10 23:14:05 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld-wasm
Author: YAMAMOTO Takashi (yamt)
<details>
<summary>Changes</summary>
Fixes https://github.com/llvm/llvm-project/issues/107387
---
Full diff: https://github.com/llvm/llvm-project/pull/108146.diff
3 Files Affected:
- (modified) lld/wasm/Driver.cpp (+2-1)
- (modified) lld/wasm/InputChunks.cpp (+1-1)
- (modified) lld/wasm/Relocations.cpp (+2-1)
``````````diff
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index cb8fe2534f5fe7..79cacc63922ee5 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -913,7 +913,8 @@ static void createSyntheticSymbols() {
}
if (ctx.isPic ||
- config->unresolvedSymbols == UnresolvedPolicy::ImportDynamic) {
+ config->unresolvedSymbols == UnresolvedPolicy::ImportDynamic ||
+ !config->isStatic) {
// For PIC code, or when dynamically importing addresses, we create
// synthetic functions that apply relocations. These get called from
// __wasm_call_ctors before the user-level constructors.
diff --git a/lld/wasm/InputChunks.cpp b/lld/wasm/InputChunks.cpp
index 975225974aff6e..dbf800422e45b5 100644
--- a/lld/wasm/InputChunks.cpp
+++ b/lld/wasm/InputChunks.cpp
@@ -378,7 +378,7 @@ void InputChunk::generateRelocationCode(raw_ostream &os) const {
uint64_t offset = getVA(rel.Offset) - getInputSectionOffset();
Symbol *sym = file->getSymbol(rel);
- if (!ctx.isPic && sym->isDefined())
+ if (!ctx.isPic && sym->isDefined() && !sym->hasGOTIndex())
continue;
LLVM_DEBUG(dbgs() << "gen reloc: type=" << relocTypeToString(rel.Type)
diff --git a/lld/wasm/Relocations.cpp b/lld/wasm/Relocations.cpp
index 6f33a4f28a9d09..70229179afdcfc 100644
--- a/lld/wasm/Relocations.cpp
+++ b/lld/wasm/Relocations.cpp
@@ -146,7 +146,8 @@ void scanRelocations(InputChunk *chunk) {
if (ctx.isPic ||
(sym->isUndefined() &&
- config->unresolvedSymbols == UnresolvedPolicy::ImportDynamic)) {
+ config->unresolvedSymbols == UnresolvedPolicy::ImportDynamic) ||
+ sym->isShared()) {
switch (reloc.Type) {
case R_WASM_TABLE_INDEX_SLEB:
case R_WASM_TABLE_INDEX_SLEB64:
``````````
</details>
https://github.com/llvm/llvm-project/pull/108146
More information about the llvm-commits
mailing list