aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLulu Cai <cailulu@loongson.cn>2025-11-24 18:03:47 +0800
committercailulu <cailulu@loongson.cn>2025-11-25 09:55:37 +0800
commit94e722179949b307f8f8560634dd5c878aee54a3 (patch)
tree6af36641a43c16188372104f7a5b1c63fb829872
parent430bb75294ec6ae84355337e63d299527a00a34f (diff)
downloadbinutils-binutils-2_43-branch.zip
binutils-binutils-2_43-branch.tar.gz
binutils-binutils-2_43-branch.tar.bz2
LoongArch: Use more appropriate assertions for the relocation of TLS LEbinutils-2_43-branch
PR ld/33427 Patches introduced in the GCC mainline: commit 8cad8f94b450be9b73d07bdeef7fa1778d3f2b96 Author: H.J. Lu <hjl.tools@gmail.com> Date: Fri Sep 5 15:40:51 2025 -0700 c: Update TLS model after processing a TLS variable Set a tentative TLS model in grokvardecl and update TLS mode with the default TLS access model after a TLS variable has been fully processed if the default TLS access model is stronger, triggered a linker error when building glibc using build-many-glibcs.py. See: https://sourceware.org/pipermail/binutils/2025-September/144225.html This fix uses more appropriate assertions. (cherry picked from commit 87961e47c3666d0527b8ce60e56617e63db0a6c4)
-rw-r--r--bfd/elfnn-loongarch.c2
-rw-r--r--ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp12
-rw-r--r--ld/testsuite/ld-loongarch-elf/undefweak_le.s7
3 files changed, 20 insertions, 1 deletions
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index 610713a..5015b43 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -4237,7 +4237,7 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
case R_LARCH_TLS_LE_LO12_R:
case R_LARCH_TLS_LE64_LO20:
case R_LARCH_TLS_LE64_HI12:
- BFD_ASSERT (resolved_local && elf_hash_table (info)->tls_sec);
+ BFD_ASSERT (bfd_link_executable (info));
relocation += rel->r_addend;
relocation = tlsoff (info, relocation);
diff --git a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
index 09c4c9f..8456090 100644
--- a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
+++ b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
@@ -118,6 +118,18 @@ if [istarget "loongarch64-*-*"] {
"abi1_max_imm" \
] \
]
+
+ run_ld_link_tests \
+ [list \
+ [list \
+ "undefind weak with tls le" \
+ "" "-e0" \
+ "" \
+ {undefweak_le.s} \
+ {} \
+ "undefweak_le" \
+ ] \
+ ]
}
if [istarget "loongarch64-*-*"] {
diff --git a/ld/testsuite/ld-loongarch-elf/undefweak_le.s b/ld/testsuite/ld-loongarch-elf/undefweak_le.s
new file mode 100644
index 0000000..6e73018
--- /dev/null
+++ b/ld/testsuite/ld-loongarch-elf/undefweak_le.s
@@ -0,0 +1,7 @@
+_start:
+ lu12i.w $t0,%le_hi20_r(undefweak_le)
+ add.d $t0,$t0,$tp,%le_add_r(undefweak_le)
+ ld.d $t0,$t0,%le_lo12_r(undefweak_le)
+
+ .weak undefweak_le
+ .hidden undefweak_le