[PATCH 02/11] alpha: set DF_TEXTREL rather than DT_TEXTREL in info->flags

Matt Turner mattst88@gmail.com
Tue Sep 1 02:33:09 GMT 2026


elf64_alpha_calc_dynrel_sizes ORs DT_TEXTREL (22) into info->flags where
it means DF_TEXTREL (4). The value happens to include the DF_TEXTREL
bit, so DT_TEXTREL still appeared, but DT_FLAGS also gained DF_SYMBOLIC
and DF_STATIC_TLS: a shared library with a text relocation against a
global symbol was treated by the dynamic linker as if linked with
-Bsymbolic, and dlopen of it could fail for lack of static TLS.

The stray DF_STATIC_TLS also fed back into the link:
elf64_alpha_relax_sec reads info->flags to decide that a general dynamic
TLS reference may as well be relaxed to initial exec, so such a library
was relaxed differently too.

Present since commit fcfbdf319ee in 2001, which introduced both this and
the correct DF_TEXTREL a few lines above it.
---
 bfd/elf64-alpha.c               |  2 +-
 ld/testsuite/ld-alpha/textrel.d |  9 +++++++++
 ld/testsuite/ld-alpha/textrel.s | 13 +++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 ld/testsuite/ld-alpha/textrel.d
 create mode 100644 ld/testsuite/ld-alpha/textrel.s

diff --git ./bfd/elf64-alpha.c ./bfd/elf64-alpha.c
index 4fc1a542704..a97acdc41de 100644
--- ./bfd/elf64-alpha.c
+++ ./bfd/elf64-alpha.c
@@ -2667,7 +2667,7 @@ elf64_alpha_calc_dynrel_sizes (struct alpha_elf_link_hash_entry *h,
 	    entries * sizeof (Elf64_External_Rela) * relent->count;
 	  if ((sec->flags & SEC_READONLY) != 0)
 	    {
-	      info->flags |= DT_TEXTREL;
+	      info->flags |= DF_TEXTREL;
 	      info->callbacks->minfo
 		(_("%pB: dynamic relocation against `%pT' in "
 		   "read-only section `%pA'\n"),
diff --git ./ld/testsuite/ld-alpha/textrel.d ./ld/testsuite/ld-alpha/textrel.d
new file mode 100644
index 00000000000..e319ab203d3
--- /dev/null
+++ ./ld/testsuite/ld-alpha/textrel.d
@@ -0,0 +1,9 @@
+#source: textrel.s
+#ld: -shared -melf64alpha -z notext
+#readelf: -d
+
+# Only DT_TEXTREL, with no DT_FLAGS carrying the SYMBOLIC and STATIC_TLS
+# bits of the value of DT_TEXTREL.
+#...
+ +0x0+16 +\(TEXTREL\) +0x0
+ +0x0+0 +\(NULL\) +0x0
diff --git ./ld/testsuite/ld-alpha/textrel.s ./ld/testsuite/ld-alpha/textrel.s
new file mode 100644
index 00000000000..bbd0675363d
--- /dev/null
+++ ./ld/testsuite/ld-alpha/textrel.s
@@ -0,0 +1,13 @@
+	.text
+	.globl	_start
+_start:
+	ret
+
+	.data
+	.globl	var
+var:
+	.quad	0
+
+	# A dynamic relocation against a global symbol in a read-only section.
+	.section .rodata,"a",@progbits
+	.quad	var
-- 
2.54.0



More information about the Binutils mailing list