Skip to content

Commit 28f2fb2

Browse files
authored
Revert "[lld][WebAssembly] Do not relocate ABSOLUTE symbols" (#154371)
Reverts #153763 This caused a bunch of failures on the emscripten waterfall, specifically most of the lsan tests started failing.
1 parent f82054e commit 28f2fb2

File tree

2 files changed

+4
-28
lines changed

2 files changed

+4
-28
lines changed

lld/test/wasm/pie.s

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-emscripten %S/Inputs/internal_func.s -o %t.internal_func.o
33
# RUN: wasm-ld --no-gc-sections --experimental-pic -pie --unresolved-symbols=import-dynamic -o %t.wasm %t.o %t.internal_func.o
44
# RUN: obj2yaml %t.wasm | FileCheck %s
5-
# RUN: llvm-objdump --disassemble-symbols=__wasm_call_ctors,__wasm_apply_data_relocs,__wasm_apply_global_relocs --no-show-raw-insn --no-leading-addr %t.wasm | FileCheck %s --check-prefixes DISASSEM
5+
# RUN: llvm-objdump --disassemble-symbols=__wasm_call_ctors,__wasm_apply_data_relocs --no-show-raw-insn --no-leading-addr %t.wasm | FileCheck %s --check-prefixes DISASSEM
66

77
.functype external_func () -> ()
88
.functype internal_func1 () -> (i32)
@@ -41,9 +41,6 @@ foo:
4141
drop
4242

4343
global.get __stack_pointer
44-
drop
45-
46-
global.get __wasm_first_page_end@GOT
4744
end_function
4845

4946
get_data_address:
@@ -148,18 +145,6 @@ _start:
148145
# DISASSEM-LABEL: <__wasm_apply_data_relocs>:
149146
# DISASSEM: end
150147

151-
# global 6 is __wasm_first_page_end, which is ABSOLUTE and
152-
# thus should not be relocated.
153-
#
154-
# DISASSEM-LABEL: <__wasm_apply_global_relocs>:
155-
# DISASSEM: global.set 4
156-
# DISASSEM: global.set 5
157-
# DISASSEM-NOT: global.set 6
158-
# DISASSEM: global.set 7
159-
# DISASSEM: global.set 8
160-
# DISASSEM: global.set 9
161-
# DISASSEM: end
162-
163148
# Run the same test with extended-const support. When this is available
164149
# we don't need __wasm_apply_global_relocs and instead rely on the add
165150
# instruction in the InitExpr. We also, therefore, do not need these globals
@@ -188,23 +173,17 @@ _start:
188173
# EXTENDED-CONST-NEXT: Type: I32
189174
# EXTENDED-CONST-NEXT: Mutable: false
190175
# EXTENDED-CONST-NEXT: InitExpr:
191-
# EXTENDED-CONST-NEXT: Opcode: I32_CONST
192-
# EXTENDED-CONST-NEXT: Value: 65536
193-
# EXTENDED-CONST-NEXT: - Index: 7
194-
# EXTENDED-CONST-NEXT: Type: I32
195-
# EXTENDED-CONST-NEXT: Mutable: false
196-
# EXTENDED-CONST-NEXT: InitExpr:
197176
# EXTENDED-CONST-NEXT: Extended: true
198177
# This instruction sequence decodes to:
199178
# (global.get[0x23] 0x1 i32.const[0x41] 0x0C i32.add[0x6A] end[0x0b])
200179
# EXTENDED-CONST-NEXT: Body: 2301410C6A0B
201-
# EXTENDED-CONST-NEXT: - Index: 8
180+
# EXTENDED-CONST-NEXT: - Index: 7
202181
# EXTENDED-CONST-NEXT: Type: I32
203182
# EXTENDED-CONST-NEXT: Mutable: false
204183
# EXTENDED-CONST-NEXT: InitExpr:
205184
# EXTENDED-CONST-NEXT: Opcode: GLOBAL_GET
206185
# EXTENDED-CONST-NEXT: Index: 2
207-
# EXTENDED-CONST-NEXT: - Index: 9
186+
# EXTENDED-CONST-NEXT: - Index: 8
208187
# EXTENDED-CONST-NEXT: Type: I32
209188
# EXTENDED-CONST-NEXT: Mutable: false
210189
# EXTENDED-CONST-NEXT: InitExpr:

lld/wasm/SyntheticSections.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,6 @@ void GlobalSection::generateRelocationCode(raw_ostream &os, bool TLS) const {
440440
: WASM_OPCODE_I32_ADD;
441441

442442
for (const Symbol *sym : internalGotSymbols) {
443-
if (sym->flags & WASM_SYMBOL_ABSOLUTE)
444-
continue;
445443
if (TLS != sym->isTLS())
446444
continue;
447445

@@ -505,8 +503,7 @@ void GlobalSection::writeBody() {
505503
bool useExtendedConst = false;
506504
uint32_t globalIdx;
507505
int64_t offset;
508-
if (ctx.arg.extendedConst && ctx.isPic &&
509-
(sym->flags & WASM_SYMBOL_ABSOLUTE) == 0) {
506+
if (ctx.arg.extendedConst && ctx.isPic) {
510507
if (auto *d = dyn_cast<DefinedData>(sym)) {
511508
if (!sym->isTLS()) {
512509
globalIdx = ctx.sym.memoryBase->getGlobalIndex();

0 commit comments

Comments
 (0)