Skip to content

Commit 85f9181

Browse files
committed
[lld][WebAssembly]: Restore non-pie dynamic-linking executable
Fixes #107387
1 parent 8287831 commit 85f9181

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

lld/wasm/Driver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,8 @@ static void createSyntheticSymbols() {
919919
}
920920

921921
if (ctx.isPic ||
922-
config->unresolvedSymbols == UnresolvedPolicy::ImportDynamic) {
922+
config->unresolvedSymbols == UnresolvedPolicy::ImportDynamic ||
923+
!config->isStatic) {
923924
// For PIC code, or when dynamically importing addresses, we create
924925
// synthetic functions that apply relocations. These get called from
925926
// __wasm_call_ctors before the user-level constructors.

lld/wasm/InputChunks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ void InputChunk::generateRelocationCode(raw_ostream &os) const {
378378
uint64_t offset = getVA(rel.Offset) - getInputSectionOffset();
379379

380380
Symbol *sym = file->getSymbol(rel);
381-
if (!ctx.isPic && sym->isDefined())
381+
if (!ctx.isPic && sym->isDefined() && !sym->hasGOTIndex())
382382
continue;
383383

384384
LLVM_DEBUG(dbgs() << "gen reloc: type=" << relocTypeToString(rel.Type)

lld/wasm/Relocations.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ void scanRelocations(InputChunk *chunk) {
146146

147147
if (ctx.isPic ||
148148
(sym->isUndefined() &&
149-
config->unresolvedSymbols == UnresolvedPolicy::ImportDynamic)) {
149+
config->unresolvedSymbols == UnresolvedPolicy::ImportDynamic) ||
150+
sym->isShared()) {
150151
switch (reloc.Type) {
151152
case R_WASM_TABLE_INDEX_SLEB:
152153
case R_WASM_TABLE_INDEX_SLEB64:

0 commit comments

Comments
 (0)