[binutils-gdb] alpha: set DF_TEXTREL rather than DT_TEXTREL in info->flags

Sam James sjames@sourceware.org
Sat Sep 5 08:34:43 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ab572c2269df22364bd7fd3cd4ba7c642de5c0e6

commit ab572c2269df22364bd7fd3cd4ba7c642de5c0e6
Author: Matt Turner <mattst88@gmail.com>
Date:   Mon Aug 31 22:33:09 2026 -0400

    alpha: set DF_TEXTREL rather than DT_TEXTREL in info->flags
    
    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.

Diff:
---
 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(-)

diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index 4fc1a542704..a97acdc41de 100644
--- a/bfd/elf64-alpha.c
+++ b/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 a/ld/testsuite/ld-alpha/textrel.d b/ld/testsuite/ld-alpha/textrel.d
new file mode 100644
index 00000000000..e319ab203d3
--- /dev/null
+++ b/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 a/ld/testsuite/ld-alpha/textrel.s b/ld/testsuite/ld-alpha/textrel.s
new file mode 100644
index 00000000000..bbd0675363d
--- /dev/null
+++ b/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


More information about the Binutils-cvs mailing list