1 From ae1cab7d3f39686d9c7ddadbac297e9ae76ffccf Mon Sep 17 00:00:00 2001
2 From: "H.J. Lu" <hjl.tools@gmail.com>
3 Date: Tue, 15 Feb 2022 15:03:02 -0800
4 Subject: [PATCH] i386: Update I386_NEED_DYNAMIC_RELOC_TYPE_P for DT_TEXTREL
6 Update I386_NEED_DYNAMIC_RELOC_TYPE_P to allow R_386_TLS_IE for relocation
12 * elfxx-x86.h (I386_NEED_DYNAMIC_RELOC_TYPE_P): Allow
17 * testsuite/ld-i386/i386.exp: Run pr28894.
18 * testsuite/ld-i386/pr28894.d: New file.
19 * testsuite/ld-i386/pr28894.s: Likewise.
21 (cherry picked from commit 3319ba7a8d6a42ba071d691789bc184632399331)
24 ld/testsuite/ld-i386/i386.exp | 1 +
25 ld/testsuite/ld-i386/pr28894.d | 3 +++
26 ld/testsuite/ld-i386/pr28894.s | 7 +++++++
27 4 files changed, 12 insertions(+)
28 create mode 100644 ld/testsuite/ld-i386/pr28894.d
29 create mode 100644 ld/testsuite/ld-i386/pr28894.s
31 diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h
32 index 3219f363a9a..77fb1ad72bc 100644
36 #define I386_NEED_DYNAMIC_RELOC_TYPE_P(TYPE) \
37 (I386_SIZE_TYPE_P (TYPE) \
38 || I386_RELATIVE_RELOC_TYPE_P (TYPE) \
39 + || (TYPE) == R_386_TLS_IE \
40 || (TYPE) == R_386_TLS_LE \
41 || (TYPE) == R_386_TLS_LE_32)
42 #define X86_NEED_DYNAMIC_RELOC_TYPE_P(IS_X86_64, TYPE) \
43 diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
44 index d997c757325..fadbd160420 100644
45 --- a/ld/testsuite/ld-i386/i386.exp
46 +++ b/ld/testsuite/ld-i386/i386.exp
47 @@ -510,6 +510,7 @@ run_dump_test "pr27491-4"
48 run_dump_test "dt-relr-1a"
49 run_dump_test "dt-relr-1b"
50 run_dump_test "pr28870"
51 +run_dump_test "pr28894"
53 if { !([istarget "i?86-*-linux*"]
54 || [istarget "i?86-*-gnu*"]
55 diff --git a/ld/testsuite/ld-i386/pr28894.d b/ld/testsuite/ld-i386/pr28894.d
57 index 00000000000..a8d1111eb1f
59 +++ b/ld/testsuite/ld-i386/pr28894.d
62 +#ld: -shared -melf_i386 --warn-shared-textrel --fatal-warnings
63 +#error: .*warning: creating DT_TEXTREL in a shared object
64 diff --git a/ld/testsuite/ld-i386/pr28894.s b/ld/testsuite/ld-i386/pr28894.s
66 index 00000000000..1d3e3f37f3e
68 +++ b/ld/testsuite/ld-i386/pr28894.s
71 + addl foo@INDNTPOFF, %eax
72 + .section .tbss,"awT",@nobits