[lld][WebAssembly] Update incorrect assertion in global relocation code - #215929
Merged
Conversation
When extended-const is enabled, non-TLS global relocations are handled via extended constant expressions. However, TLS GOT entries still require runtime relocation code in `__wasm_apply_global_tls_relocs` because TLS global addresses depend on `__tls_base`. Allow `GlobalSection::generateRelocationCode` to be called when `TLS` is true even if `ctx.arg.extendedConst` is set.
|
@llvm/pr-subscribers-lld-wasm @llvm/pr-subscribers-lld Author: Sam Clegg (sbc100) ChangesWhen extended-const is enabled, non-TLS global relocations are handled via extended constant expressions. However, TLS GOT entries still require runtime relocation code in Allow Full diff: https://github.com/llvm/llvm-project/pull/215929.diff 2 Files Affected:
diff --git a/lld/test/wasm/tls-init-symbols.s b/lld/test/wasm/tls-init-symbols.s
index 601766d681d85..944c9c349701a 100644
--- a/lld/test/wasm/tls-init-symbols.s
+++ b/lld/test/wasm/tls-init-symbols.s
@@ -9,6 +9,7 @@
# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
# RUN: wasm-ld -no-gc-sections --shared-memory -o %t.wasm %t.o
+# RUN: wasm-ld -no-gc-sections --shared-memory --extra-features=extended-const -o %t.extended.wasm %t.o
# RUN: obj2yaml %t.wasm | FileCheck %s
# RUN: llvm-objdump -d --no-show-raw-insn --no-leading-addr %t.wasm | FileCheck %s --check-prefixes DIS
diff --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp
index 050f61c7f5c56..b6d572277e7cd 100644
--- a/lld/wasm/SyntheticSections.cpp
+++ b/lld/wasm/SyntheticSections.cpp
@@ -474,7 +474,7 @@ void GlobalSection::addInternalGOTEntry(Symbol *sym) {
}
void GlobalSection::generateRelocationCode(raw_ostream &os, bool TLS) const {
- assert(!ctx.arg.extendedConst);
+ assert(!ctx.arg.extendedConst || TLS);
bool is64 = ctx.arg.is64.value_or(false);
unsigned opcode_ptr_add = is64 ? WASM_OPCODE_I64_ADD : WASM_OPCODE_I32_ADD;
|
dschuff
approved these changes
Aug 13, 2026
zhangweize9-cyber
pushed a commit
to zhangweize9-cyber/llvm-project
that referenced
this pull request
Aug 16, 2026
…de (llvm#215929) When extended-const is enabled, non-TLS global relocations are handled via extended constant expressions. However, TLS GOT entries still require runtime relocation code in `__wasm_apply_global_tls_relocs` because TLS global addresses depend on `__tls_base`. Allow `GlobalSection::generateRelocationCode` to be called when `TLS` is true even if `ctx.arg.extendedConst` is set.
Contributor
Author
|
/cherry-pick 82ea231 |
Member
|
/pull-request #217380 |
dyung
pushed a commit
to llvmbot/llvm-project
that referenced
this pull request
Aug 20, 2026
…de (llvm#215929) When extended-const is enabled, non-TLS global relocations are handled via extended constant expressions. However, TLS GOT entries still require runtime relocation code in `__wasm_apply_global_tls_relocs` because TLS global addresses depend on `__tls_base`. Allow `GlobalSection::generateRelocationCode` to be called when `TLS` is true even if `ctx.arg.extendedConst` is set. (cherry picked from commit 82ea231)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When extended-const is enabled, non-TLS global relocations are handled via extended constant expressions. However, TLS GOT entries still require runtime relocation code in
__wasm_apply_global_tls_relocsbecause TLS global addresses depend on__tls_base.Allow
GlobalSection::generateRelocationCodeto be called whenTLSis true even ifctx.arg.extendedConstis set.