|
|
869a11 |
From 279b2f94168ee91e02ccd070d27c983fc001fe12 Mon Sep 17 00:00:00 2001
|
|
|
869a11 |
From: Renlin Li <renlin.li@arm.com>
|
|
|
869a11 |
Date: Sat, 3 Feb 2018 13:18:17 +0000
|
|
|
869a11 |
Subject: [PATCH] [PR22764][LD][AARCH64]Allow R_AARCH64_ABS16 and
|
|
|
869a11 |
R_AARCH64_ABS32 against absolution symbol or undefine symbol in shared
|
|
|
869a11 |
object.
|
|
|
869a11 |
|
|
|
869a11 |
The assumption that R_AARCH64_ABS16 and R_AARCH64_ABS32 relocation in LP64 abi
|
|
|
869a11 |
will be used to generate an address does not hold for absolute symbol.
|
|
|
869a11 |
In this case, it is a value fixed at static linking time.
|
|
|
869a11 |
|
|
|
869a11 |
The condition to check the relocations is relax to allow absolute symbol and
|
|
|
869a11 |
undefined symbol case.
|
|
|
869a11 |
|
|
|
869a11 |
bfd/
|
|
|
869a11 |
|
|
|
869a11 |
2018-02-05 Renlin Li <renlin.li@arm.com>
|
|
|
869a11 |
|
|
|
869a11 |
PR ld/22764
|
|
|
869a11 |
* elfnn-aarch64.c (elfNN_aarch64_check_relocs): Relax the
|
|
|
869a11 |
R_AARCH64_ABS32 and R_AARCH64_ABS16 for absolute symbol. Apply the
|
|
|
869a11 |
check for writeable section as well.
|
|
|
869a11 |
|
|
|
869a11 |
ld/
|
|
|
869a11 |
|
|
|
869a11 |
2018-02-05 Renlin Li <renlin.li@arm.com>
|
|
|
869a11 |
|
|
|
869a11 |
PR ld/22764
|
|
|
869a11 |
* testsuite/ld-aarch64/emit-relocs-258.s: Define symbol as an address.
|
|
|
869a11 |
* testsuite/ld-aarch64/emit-relocs-259.s: Likewise.
|
|
|
869a11 |
* testsuite/ld-aarch64/aarch64-elf.exp: Run new test.
|
|
|
869a11 |
* testsuite/ld-aarch64/pr22764.s: New.
|
|
|
869a11 |
* testsuite/ld-aarch64/pr22764.d: New.
|
|
|
869a11 |
---
|
|
|
869a11 |
bfd/ChangeLog | 7 +++++++
|
|
|
869a11 |
bfd/elfnn-aarch64.c | 15 ++++++++++++---
|
|
|
869a11 |
ld/ChangeLog | 8 ++++++++
|
|
|
869a11 |
ld/testsuite/ld-aarch64/aarch64-elf.exp | 1 +
|
|
|
869a11 |
ld/testsuite/ld-aarch64/emit-relocs-258.s | 3 ++-
|
|
|
869a11 |
ld/testsuite/ld-aarch64/emit-relocs-259.s | 3 ++-
|
|
|
869a11 |
ld/testsuite/ld-aarch64/pr22764.d | 18 ++++++++++++++++++
|
|
|
869a11 |
ld/testsuite/ld-aarch64/pr22764.s | 6 ++++++
|
|
|
869a11 |
8 files changed, 56 insertions(+), 5 deletions(-)
|
|
|
869a11 |
create mode 100644 ld/testsuite/ld-aarch64/pr22764.d
|
|
|
869a11 |
create mode 100644 ld/testsuite/ld-aarch64/pr22764.s
|
|
|
869a11 |
|
|
|
869a11 |
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
|
|
|
869a11 |
index af448f9..2737773 100644
|
|
|
869a11 |
--- a/bfd/elfnn-aarch64.c
|
|
|
869a11 |
+++ b/bfd/elfnn-aarch64.c
|
|
|
869a11 |
@@ -7189,10 +7189,19 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
|
|
|
869a11 |
#if ARCH_SIZE == 64
|
|
|
869a11 |
case BFD_RELOC_AARCH64_32:
|
|
|
869a11 |
#endif
|
|
|
869a11 |
- if (bfd_link_pic (info)
|
|
|
869a11 |
- && (sec->flags & SEC_ALLOC) != 0
|
|
|
869a11 |
- && (sec->flags & SEC_READONLY) != 0)
|
|
|
869a11 |
+ if (bfd_link_pic (info) && (sec->flags & SEC_ALLOC) != 0)
|
|
|
869a11 |
{
|
|
|
869a11 |
+ if (h != NULL
|
|
|
869a11 |
+ /* This is an absolute symbol. It represents a value instead
|
|
|
869a11 |
+ of an address. */
|
|
|
869a11 |
+ && ((h->root.type == bfd_link_hash_defined
|
|
|
869a11 |
+ && bfd_is_abs_section (h->root.u.def.section))
|
|
|
869a11 |
+ /* This is an undefined symbol. */
|
|
|
869a11 |
+ || h->root.type == bfd_link_hash_undefined))
|
|
|
869a11 |
+ break;
|
|
|
869a11 |
+
|
|
|
869a11 |
+ /* For local symbols, defined global symbols in a non-ABS section,
|
|
|
869a11 |
+ it is assumed that the value is an address. */
|
|
|
869a11 |
int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START;
|
|
|
869a11 |
_bfd_error_handler
|
|
|
869a11 |
/* xgettext:c-format */
|
|
|
869a11 |
diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp
|
|
|
869a11 |
index 2602a43..c67ffb1 100644
|
|
|
869a11 |
--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp
|
|
|
869a11 |
+++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp
|
|
|
869a11 |
@@ -285,6 +285,7 @@ run_dump_test "pr17415"
|
|
|
869a11 |
run_dump_test_lp64 "tprel_g2_overflow"
|
|
|
869a11 |
run_dump_test "tprel_add_lo12_overflow"
|
|
|
869a11 |
run_dump_test "protected-data"
|
|
|
869a11 |
+run_dump_test_lp64 "pr22764"
|
|
|
869a11 |
|
|
|
869a11 |
# ifunc tests
|
|
|
869a11 |
run_dump_test "ifunc-1"
|
|
|
869a11 |
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-258.s b/ld/testsuite/ld-aarch64/emit-relocs-258.s
|
|
|
869a11 |
index f724776..87bb657 100644
|
|
|
869a11 |
--- a/ld/testsuite/ld-aarch64/emit-relocs-258.s
|
|
|
869a11 |
+++ b/ld/testsuite/ld-aarch64/emit-relocs-258.s
|
|
|
869a11 |
@@ -1,5 +1,6 @@
|
|
|
869a11 |
+.global dummy
|
|
|
869a11 |
.text
|
|
|
869a11 |
-
|
|
|
869a11 |
+dummy:
|
|
|
869a11 |
ldr x0, .L1
|
|
|
869a11 |
|
|
|
869a11 |
.L1:
|
|
|
869a11 |
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-259.s b/ld/testsuite/ld-aarch64/emit-relocs-259.s
|
|
|
869a11 |
index 7e1ba3c..0977c9d 100644
|
|
|
869a11 |
--- a/ld/testsuite/ld-aarch64/emit-relocs-259.s
|
|
|
869a11 |
+++ b/ld/testsuite/ld-aarch64/emit-relocs-259.s
|
|
|
869a11 |
@@ -1,5 +1,6 @@
|
|
|
869a11 |
+.global dummy
|
|
|
869a11 |
.text
|
|
|
869a11 |
-
|
|
|
869a11 |
+dummy:
|
|
|
869a11 |
ldr x0, .L1
|
|
|
869a11 |
|
|
|
869a11 |
.L1:
|
|
|
869a11 |
diff --git a/ld/testsuite/ld-aarch64/pr22764.d b/ld/testsuite/ld-aarch64/pr22764.d
|
|
|
869a11 |
new file mode 100644
|
|
|
869a11 |
index 0000000..997519f
|
|
|
869a11 |
--- /dev/null
|
|
|
869a11 |
+++ b/ld/testsuite/ld-aarch64/pr22764.d
|
|
|
869a11 |
@@ -0,0 +1,18 @@
|
|
|
869a11 |
+#source: pr22764.s
|
|
|
869a11 |
+#ld: -shared -T relocs.ld -defsym sym_abs1=0x1 -defsym sym_abs2=0x2 -defsym sym_abs3=0x3 -e0 --emit-relocs
|
|
|
869a11 |
+#notarget: aarch64_be-*-*
|
|
|
869a11 |
+#objdump: -dr
|
|
|
869a11 |
+#...
|
|
|
869a11 |
+
|
|
|
869a11 |
+Disassembly of section \.text:
|
|
|
869a11 |
+
|
|
|
869a11 |
+0000000000010000 \<\.text\>:
|
|
|
869a11 |
+ 10000: d503201f nop
|
|
|
869a11 |
+ ...
|
|
|
869a11 |
+ 10004: R_AARCH64_ABS64 sym_abs1
|
|
|
869a11 |
+ 1000c: 00000002 \.word 0x00000002
|
|
|
869a11 |
+ 1000c: R_AARCH64_ABS32 sym_abs2
|
|
|
869a11 |
+ 10010: 0003 \.short 0x0003
|
|
|
869a11 |
+ 10010: R_AARCH64_ABS16 sym_abs3
|
|
|
869a11 |
+ 10012: 0000 \.short 0x0000
|
|
|
869a11 |
+ 10014: d503201f nop
|
|
|
869a11 |
diff --git a/ld/testsuite/ld-aarch64/pr22764.s b/ld/testsuite/ld-aarch64/pr22764.s
|
|
|
869a11 |
new file mode 100644
|
|
|
869a11 |
index 0000000..25e36b4
|
|
|
869a11 |
--- /dev/null
|
|
|
869a11 |
+++ b/ld/testsuite/ld-aarch64/pr22764.s
|
|
|
869a11 |
@@ -0,0 +1,6 @@
|
|
|
869a11 |
+ .text
|
|
|
869a11 |
+ nop
|
|
|
869a11 |
+ .xword sym_abs1
|
|
|
869a11 |
+ .word sym_abs2
|
|
|
869a11 |
+ .short sym_abs3
|
|
|
869a11 |
+ nop
|
|
|
869a11 |
--
|
|
|
869a11 |
2.9.3
|