[lld] [lld][ELF] Allow explicit address expressions on .tbss output sections (PR #196447)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 14 12:43:14 PDT 2026
================
@@ -0,0 +1,49 @@
+# REQUIRES: x86
+## Test that an explicit address expression on a .tbss section is respected,
+## and that TLS offsets and PT_TLS are generated correctly when one is specified.
+
+# RUN: rm -rf %t && split-file %s %t && cd %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux a.s -o a.o
+
+# RUN: ld.lld -T explicit.t a.o -o explicit
+# RUN: llvm-readelf -S explicit | FileCheck %s --check-prefix=EXPLICIT
+# RUN: llvm-readelf -l explicit | FileCheck %s --check-prefix=PHDR
+# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn explicit | FileCheck %s --check-prefix=DIS
+
+## An explicit address on a .tbss output section is honored.
+# EXPLICIT: .tdata PROGBITS 0000000000100000 {{[0-9a-f]+}} 000004
+# EXPLICIT: .tbss NOBITS 0000000000200000 {{[0-9a-f]+}} 000004
+
+# PHDR: TLS 0x002000 0x0000000000100000 0x0000000000100000 0x000004 0x100004 R 0x1
+
+# DIS: movl %fs:-1048580, %eax
+# DIS-NEXT: movl %fs:-4, %eax
+
+#--- a.s
+.globl _start
+_start:
+ movl %fs:x at tpoff, %eax
+ movl %fs:y at tpoff, %eax
+
+.section .tdata,"awT", at progbits
+.globl x
+x:
+ .long 1
+
+.section .tbss,"awT", at nobits
+.globl y
+y:
+ .long 0
+
+#--- explicit.t
+MEMORY {
+ text_mem (rx) : ORIGIN = 0xFFFFFFFFFFF00000, LENGTH = 0x10000
+ tdata_mem (rw) : ORIGIN = 0x100000, LENGTH = 0x1000
----------------
MaskRay wrote:
misaligned. aligned columns isn't important, you can just delete the unneeded padding
https://github.com/llvm/llvm-project/pull/196447
More information about the llvm-commits
mailing list