]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[PR22764][LD][AARCH64]Allow R_AARCH64_ABS16 and R_AARCH64_ABS32 against absolution...
authorRenlin Li <renlin.li@arm.com>
Sat, 3 Feb 2018 13:18:17 +0000 (13:18 +0000)
committerRenlin Li <renlin.li@arm.com>
Mon, 5 Feb 2018 18:25:28 +0000 (18:25 +0000)
backport from mainline

bfd/

2018-02-05  Renlin Li  <renlin.li@arm.com>

PR ld/22764
* elfnn-aarch64.c (elfNN_aarch64_check_relocs): Relax the
R_AARCH64_ABS32 and R_AARCH64_ABS16 for absolute symbol. Apply the
check for writeable section as well.

ld/

2018-02-05  Renlin Li  <renlin.li@arm.com>

PR ld/22764
* testsuite/ld-aarch64/emit-relocs-258.s: Define symbol as an address.
* testsuite/ld-aarch64/emit-relocs-259.s: Likewise.
* testsuite/ld-aarch64/aarch64-elf.exp: Run new test.
* testsuite/ld-aarch64/pr22764.s: New.
* testsuite/ld-aarch64/pr22764.d: New.

bfd/ChangeLog
bfd/elfnn-aarch64.c
ld/ChangeLog
ld/testsuite/ld-aarch64/aarch64-elf.exp
ld/testsuite/ld-aarch64/emit-relocs-258.s
ld/testsuite/ld-aarch64/emit-relocs-259.s
ld/testsuite/ld-aarch64/pr22764.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/pr22764.s [new file with mode: 0644]

index 92e26a8aa2388f7de6e3444fa848116abc4fc0df..9fe447a29e50b9cc880e5b7ff8184f20419748d0 100644 (file)
@@ -1,3 +1,10 @@
+2018-02-05  Renlin Li  <renlin.li@arm.com>
+
+       PR ld/22764
+       * elfnn-aarch64.c (elfNN_aarch64_check_relocs): Relax the
+       R_AARCH64_ABS32 and R_AARCH64_ABS16 for absolute symbol. Apply the
+       check for writeable section as well.
+
 2018-01-27  Nick Clifton  <nickc@redhat.com>
 
        Back to development.
index d5711e0eb1dc500d457191407aea57760d708591..973188220ba17bbb88eb19f850f2a482a56050cb 100644 (file)
@@ -7074,10 +7074,19 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
 #if ARCH_SIZE == 64
        case BFD_RELOC_AARCH64_32:
 #endif
-         if (bfd_link_pic (info)
-             && (sec->flags & SEC_ALLOC) != 0
-             && (sec->flags & SEC_READONLY) != 0)
+         if (bfd_link_pic (info) && (sec->flags & SEC_ALLOC) != 0)
            {
+             if (h != NULL
+                 /* This is an absolute symbol.  It represents a value instead
+                    of an address.  */
+                 && ((h->root.type == bfd_link_hash_defined
+                      && bfd_is_abs_section (h->root.u.def.section))
+                     /* This is an undefined symbol.  */
+                     || h->root.type == bfd_link_hash_undefined))
+               break;
+
+             /* For local symbols, defined global symbols in a non-ABS section,
+                it is assumed that the value is an address.  */
              int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START;
              _bfd_error_handler
                /* xgettext:c-format */
index ddc1d88f3c1915fd62d5feeabbc583294a3c6cf8..e871cef7c07dfb421971538f353b963a85ede1c5 100644 (file)
@@ -1,3 +1,11 @@
+2018-02-05  Renlin Li  <renlin.li@arm.com>
+
+       PR ld/22764
+       * testsuite/ld-aarch64/emit-relocs-258.s: Define symbol as an address.
+       * testsuite/ld-aarch64/emit-relocs-259.s: Likewise.
+       * testsuite/ld-aarch64/pr22764.s: New.
+       * testsuite/ld-aarch64/pr22764.d: New.
+
 2018-02-05  Nick Clifton  <nickc@redhat.com>
 
        * po/pt_BR.po: Updated Brazilian Portuguese translation.
index f31089361b80e79812fa70e14716fa60ca500775..d766f3736bc53467b560d8194a2eda154801df95 100644 (file)
@@ -275,6 +275,7 @@ run_dump_test "pr17415"
 run_dump_test_lp64 "tprel_g2_overflow"
 run_dump_test "tprel_add_lo12_overflow"
 run_dump_test "protected-data"
+run_dump_test_lp64 "pr22764"
 
 # ifunc tests
 run_dump_test "ifunc-1"
index f724776243199f4a9ff94b634b0998b963f92cf6..87bb657c5d99e739f7845869c4d221e4a485497a 100644 (file)
@@ -1,5 +1,6 @@
+.global dummy
 .text
-
+dummy:
   ldr x0, .L1
 
 .L1:
index 7e1ba3ceb400b582350aa43d3c7d925ef22efd53..0977c9d869f3bfd224c439310d1f0b34073dbcd0 100644 (file)
@@ -1,5 +1,6 @@
+.global dummy
 .text
-
+dummy:
   ldr x0, .L1
 
 .L1:
diff --git a/ld/testsuite/ld-aarch64/pr22764.d b/ld/testsuite/ld-aarch64/pr22764.d
new file mode 100644 (file)
index 0000000..997519f
--- /dev/null
@@ -0,0 +1,18 @@
+#source: pr22764.s
+#ld: -shared -T relocs.ld -defsym sym_abs1=0x1 -defsym sym_abs2=0x2 -defsym sym_abs3=0x3 -e0 --emit-relocs
+#notarget: aarch64_be-*-*
+#objdump: -dr
+#...
+
+Disassembly of section \.text:
+
+0000000000010000 \<\.text\>:
+   10000:      d503201f        nop
+       ...
+                       10004: R_AARCH64_ABS64  sym_abs1
+   1000c:      00000002        \.word  0x00000002
+                       1000c: R_AARCH64_ABS32  sym_abs2
+   10010:      0003            \.short 0x0003
+                       10010: R_AARCH64_ABS16  sym_abs3
+   10012:      0000            \.short 0x0000
+   10014:      d503201f        nop
diff --git a/ld/testsuite/ld-aarch64/pr22764.s b/ld/testsuite/ld-aarch64/pr22764.s
new file mode 100644 (file)
index 0000000..25e36b4
--- /dev/null
@@ -0,0 +1,6 @@
+  .text
+  nop
+  .xword sym_abs1
+  .word sym_abs2
+  .short sym_abs3
+  nop