i386: Update I386_NEED_DYNAMIC_RELOC_TYPE_P for DT_TEXTREL
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 15 Feb 2022 23:03:02 +0000 (15:03 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 15 Feb 2022 23:08:17 +0000 (15:08 -0800)
Update I386_NEED_DYNAMIC_RELOC_TYPE_P to allow R_386_TLS_IE for relocation
in read-only section.

bfd/

PR ld/28894
* elfxx-x86.h (I386_NEED_DYNAMIC_RELOC_TYPE_P): Allow
R_386_TLS_IE.

ld/
PR ld/28894
* testsuite/ld-i386/i386.exp: Run pr28894.
* testsuite/ld-i386/pr28894.d: New file.
* testsuite/ld-i386/pr28894.s: Likewise.

bfd/elfxx-x86.h
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-i386/pr28894.d [new file with mode: 0644]
ld/testsuite/ld-i386/pr28894.s [new file with mode: 0644]

index 3219f363a9ae90048831913e0cd4c90473ee5a7f..77fb1ad72bc284cdac29d2e9bae3ad53ee60f7cf 100644 (file)
@@ -80,6 +80,7 @@
 #define I386_NEED_DYNAMIC_RELOC_TYPE_P(TYPE) \
   (I386_SIZE_TYPE_P (TYPE) \
    || I386_RELATIVE_RELOC_TYPE_P (TYPE) \
+   || (TYPE) == R_386_TLS_IE \
    || (TYPE) == R_386_TLS_LE \
    || (TYPE) == R_386_TLS_LE_32)
 #define X86_NEED_DYNAMIC_RELOC_TYPE_P(IS_X86_64, TYPE) \
index d997c757325833847bb225e5ac1aa7e9c0c51404..fadbd16042086a0d49f599379e0e124447620a4c 100644 (file)
@@ -510,6 +510,7 @@ run_dump_test "pr27491-4"
 run_dump_test "dt-relr-1a"
 run_dump_test "dt-relr-1b"
 run_dump_test "pr28870"
+run_dump_test "pr28894"
 
 if { !([istarget "i?86-*-linux*"]
        || [istarget "i?86-*-gnu*"]
diff --git a/ld/testsuite/ld-i386/pr28894.d b/ld/testsuite/ld-i386/pr28894.d
new file mode 100644 (file)
index 0000000..a8d1111
--- /dev/null
@@ -0,0 +1,3 @@
+#as: --32
+#ld: -shared -melf_i386 --warn-shared-textrel --fatal-warnings
+#error: .*warning: creating DT_TEXTREL in a shared object
diff --git a/ld/testsuite/ld-i386/pr28894.s b/ld/testsuite/ld-i386/pr28894.s
new file mode 100644 (file)
index 0000000..1d3e3f3
--- /dev/null
@@ -0,0 +1,7 @@
+       .text
+       addl    foo@INDNTPOFF, %eax
+       .section .tbss,"awT",@nobits
+       .globl  foo
+       .hidden foo
+foo:
+       .byte 0