[LD][AARCH64]Add group relocations to create PC-relative offset.
authorRenlin Li <renlin.li@arm.com>
Thu, 18 Jan 2018 12:17:55 +0000 (12:17 +0000)
committerRenlin Li <renlin.li@arm.com>
Wed, 24 Jan 2018 16:20:05 +0000 (16:20 +0000)
This is a patch to add linker support for group relocations to create a
16, 32, 48, or 64 bit PC-relative offset inline.

The following relocations are added along with the test cases:
BFD_RELOC_AARCH64_MOVW_PREL_G0, BFD_RELOC_AARCH64_MOVW_PREL_G0_NC,
BFD_RELOC_AARCH64_MOVW_PREL_G1, BFD_RELOC_AARCH64_MOVW_PREL_G1_NC,
BFD_RELOC_AARCH64_MOVW_PREL_G2, BFD_RELOC_AARCH64_MOVW_PREL_G2_NC,
BFD_RELOC_AARCH64_MOVW_PREL_G3.

bfd/

2018-01-24  Renlin Li  <renlin.li@arm.com>

* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Add support for
BFD_RELOC_AARCH64_MOVW_PREL_G0, BFD_RELOC_AARCH64_MOVW_PREL_G0_NC,
BFD_RELOC_AARCH64_MOVW_PREL_G1, BFD_RELOC_AARCH64_MOVW_PREL_G1_NC,
BFD_RELOC_AARCH64_MOVW_PREL_G2, BFD_RELOC_AARCH64_MOVW_PREL_G2_NC,
BFD_RELOC_AARCH64_MOVW_PREL_G3.
* elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
(_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/

2018-01-24  Renlin Li  <renlin.li@arm.com>

* testsuite/ld-aarch64/aarch64-elf.exp: Run new testes.
* testsuite/ld-aarch64/emit-relocs-287.s: Fix test case.
* testsuite/ld-aarch64/emit-relocs-287.d: Fix expected output.
* testsuite/ld-aarch64/emit-relocs-287-overflow.s: New.
* testsuite/ld-aarch64/emit-relocs-287-overflow.d: New.
* testsuite/ld-aarch64/emit-relocs-288.d: New.
* testsuite/ld-aarch64/emit-relocs-288.s: New.
* testsuite/ld-aarch64/emit-relocs-289.d: New.
* testsuite/ld-aarch64/emit-relocs-289.s: New.
* testsuite/ld-aarch64/emit-relocs-289-overflow.s: New.
* testsuite/ld-aarch64/emit-relocs-289-overflow.d: New.
* testsuite/ld-aarch64/emit-relocs-290.d: New.
* testsuite/ld-aarch64/emit-relocs-290.s: New.
* testsuite/ld-aarch64/emit-relocs-291.d: New.
* testsuite/ld-aarch64/emit-relocs-291.s: New.
* testsuite/ld-aarch64/emit-relocs-291-overflow.s: New.
* testsuite/ld-aarch64/emit-relocs-291-overflow.d: New.
* testsuite/ld-aarch64/emit-relocs-292.d: New.
* testsuite/ld-aarch64/emit-relocs-292.s: New.
* testsuite/ld-aarch64/emit-relocs-293.d: New.
* testsuite/ld-aarch64/emit-relocs-293.s: New.

25 files changed:
bfd/ChangeLog
bfd/elfnn-aarch64.c
bfd/elfxx-aarch64.c
ld/ChangeLog
ld/testsuite/ld-aarch64/aarch64-elf.exp
ld/testsuite/ld-aarch64/emit-relocs-287-overflow.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-287-overflow.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-287.d
ld/testsuite/ld-aarch64/emit-relocs-287.s
ld/testsuite/ld-aarch64/emit-relocs-288.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-288.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-289-overflow.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-289-overflow.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-289.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-289.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-290.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-290.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-291-overflow.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-291-overflow.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-291.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-291.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-292.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-292.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-293.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-293.s [new file with mode: 0644]

index 35e42a2ad3d7dedc9d869ce80b5ad85709064d07..b9fed6f4da214f09f0c47edd0f7f09076af69aa0 100644 (file)
@@ -1,3 +1,13 @@
+2018-01-24  Renlin Li  <renlin.li@arm.com>
+
+       * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Add support for
+       BFD_RELOC_AARCH64_MOVW_PREL_G0, BFD_RELOC_AARCH64_MOVW_PREL_G0_NC,
+       BFD_RELOC_AARCH64_MOVW_PREL_G1, BFD_RELOC_AARCH64_MOVW_PREL_G1_NC,
+       BFD_RELOC_AARCH64_MOVW_PREL_G2, BFD_RELOC_AARCH64_MOVW_PREL_G2_NC,
+       BFD_RELOC_AARCH64_MOVW_PREL_G3.
+       * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
+       (_bfd_aarch64_elf_resolve_relocation): Likewise.
+
 2018-01-24  Renlin Li  <renlin.li@arm.com>
 
        * reloc.c: Add BFD_RELOC_AARCH64_MOVW_PREL_G0,
index b84c8ba7635406f721a37b83f435069ac76e3ec0..af448f98aef6fb39081d932a22951b58d8fc6515 100644 (file)
@@ -5462,6 +5462,13 @@ bad_ifunc_reloc:
     case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
     case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
     case BFD_RELOC_AARCH64_LD_LO19_PCREL:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G0:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G0_NC:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G1:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G1_NC:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G2:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G2_NC:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G3:
       if (bfd_link_pic (info)
          && (input_section->flags & SEC_ALLOC) != 0
          && (input_section->flags & SEC_READONLY) != 0
index 9d4aa8fb20b078df05164bfe8dfad1a5d7b46b3c..4fa5682e0d0a41a3832d59b215b2fe0aa46fc68e 100644 (file)
@@ -301,6 +301,10 @@ _bfd_aarch64_elf_put_addend (bfd *abfd,
     case BFD_RELOC_AARCH64_MOVW_G0_S:
     case BFD_RELOC_AARCH64_MOVW_G1_S:
     case BFD_RELOC_AARCH64_MOVW_G2_S:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G0:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G1:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G2:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G3:
     case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0:
     case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1:
     case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2:
@@ -333,6 +337,9 @@ _bfd_aarch64_elf_put_addend (bfd *abfd,
     case BFD_RELOC_AARCH64_MOVW_G3:
     case BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC:
     case BFD_RELOC_AARCH64_MOVW_GOTOFF_G1:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G0_NC:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G1_NC:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G2_NC:
     case BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC:
     case BFD_RELOC_AARCH64_TLSDESC_OFF_G1:
     case BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC:
@@ -395,6 +402,13 @@ _bfd_aarch64_elf_resolve_relocation (bfd_reloc_code_real_type r_type,
     case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
     case BFD_RELOC_AARCH64_BRANCH19:
     case BFD_RELOC_AARCH64_LD_LO19_PCREL:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G0:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G0_NC:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G1:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G1_NC:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G2:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G2_NC:
+    case BFD_RELOC_AARCH64_MOVW_PREL_G3:
     case BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21:
     case BFD_RELOC_AARCH64_TLSDESC_LD_PREL19:
     case BFD_RELOC_AARCH64_TLSGD_ADR_PREL21:
index b33714bebc9484397c5aa2f08385fae5aff6eccd..5271a6acf19bdde3c91e84482ddfa24ec42a7821 100644 (file)
@@ -1,3 +1,27 @@
+2018-01-24  Renlin Li  <renlin.li@arm.com>
+
+       * testsuite/ld-aarch64/aarch64-elf.exp: Run new testes.
+       * testsuite/ld-aarch64/emit-relocs-287.s: Fix test case.
+       * testsuite/ld-aarch64/emit-relocs-287.d: Fix expected output.
+       * testsuite/ld-aarch64/emit-relocs-287-overflow.s: New.
+       * testsuite/ld-aarch64/emit-relocs-287-overflow.d: New.
+       * testsuite/ld-aarch64/emit-relocs-288.d: New.
+       * testsuite/ld-aarch64/emit-relocs-288.s: New.
+       * testsuite/ld-aarch64/emit-relocs-289.d: New.
+       * testsuite/ld-aarch64/emit-relocs-289.s: New.
+       * testsuite/ld-aarch64/emit-relocs-289-overflow.s: New.
+       * testsuite/ld-aarch64/emit-relocs-289-overflow.d: New.
+       * testsuite/ld-aarch64/emit-relocs-290.d: New.
+       * testsuite/ld-aarch64/emit-relocs-290.s: New.
+       * testsuite/ld-aarch64/emit-relocs-291.d: New.
+       * testsuite/ld-aarch64/emit-relocs-291.s: New.
+       * testsuite/ld-aarch64/emit-relocs-291-overflow.s: New.
+       * testsuite/ld-aarch64/emit-relocs-291-overflow.d: New.
+       * testsuite/ld-aarch64/emit-relocs-292.d: New.
+       * testsuite/ld-aarch64/emit-relocs-292.s: New.
+       * testsuite/ld-aarch64/emit-relocs-293.d: New.
+       * testsuite/ld-aarch64/emit-relocs-293.s: New.
+
 2018-01-20  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/22721
index f31089361b80e79812fa70e14716fa60ca500775..2602a43dd90558e80c0f384abe393b7f41fd850f 100644 (file)
@@ -143,7 +143,17 @@ run_dump_test_lp64 "emit-relocs-284"
 run_dump_test_lp64 "emit-relocs-285"
 run_dump_test_lp64 "emit-relocs-286"
 run_dump_test_lp64 "emit-relocs-286-bad"
-# 287-298 are not done yet
+run_dump_test_lp64 "emit-relocs-287"
+run_dump_test_lp64 "emit-relocs-287-overflow"
+run_dump_test_lp64 "emit-relocs-288"
+run_dump_test_lp64 "emit-relocs-289"
+run_dump_test_lp64 "emit-relocs-289-overflow"
+run_dump_test_lp64 "emit-relocs-290"
+run_dump_test_lp64 "emit-relocs-291"
+run_dump_test_lp64 "emit-relocs-291-overflow"
+run_dump_test_lp64 "emit-relocs-292"
+run_dump_test_lp64 "emit-relocs-293"
+# 294-298 are not done yet
 run_dump_test_lp64 "emit-relocs-299"
 # 300 is not done yet
 run_dump_test_lp64 "emit-relocs-301"
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-287-overflow.d b/ld/testsuite/ld-aarch64/emit-relocs-287-overflow.d
new file mode 100644 (file)
index 0000000..54f42c6
--- /dev/null
@@ -0,0 +1,5 @@
+#source: emit-relocs-287-overflow.s
+#ld: -T relocs.ld --defsym tempy=0x20000 --defsym tempy2=0x0 -e0 --emit-relocs
+#objdump: -dr
+#error: .*\(.text\+0x\d+\): relocation truncated to fit: R_AARCH64_MOVW_PREL_G0 against symbol `tempy' .*
+#error: .*\(.text\+0x\d+\): relocation truncated to fit: R_AARCH64_MOVW_PREL_G0 against symbol `tempy2' .*
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-287-overflow.s b/ld/testsuite/ld-aarch64/emit-relocs-287-overflow.s
new file mode 100644 (file)
index 0000000..999cd15
--- /dev/null
@@ -0,0 +1,5 @@
+.comm   gempy,4,4
+.text
+
+       movz    x4, :prel_g0:tempy
+       movz    x4, :prel_g0:tempy2
index 4d5fd43d18ce7123d6ed4704f8caae21ba093304..a76e0e62dadb89adf1c931e7aedbcde3ec0d75d7 100644 (file)
@@ -1,14 +1,10 @@
 #source: emit-relocs-287.s
-#ld: -T relocs.ld --defsym tempy=0x11000 --defsym tempy2=0x45000 --defsym tempy3=0x1234 --defsym _GOT_=0x10000 -e0 --emit-relocs
+#ld: -T relocs.ld --defsym tempy=0x1ffff --defsym tempy2=0x4 -e0 --emit-relocs
 #objdump: -dr
 
 #...
- +10000:       8a000000        and     x0, x0, x0
- +10004:       92400000        and     x0, x0, #0x1
- +10008:       d2820004        movz    x4, #0x1000
-       +10008: R_AARCH64_MOVW_PREL_G0  _GOT_
- +1000c:       d28a0007        movz    x7, #0x5000
-       +1000c: R_AARCH64_MOVW_PREL_G0  _GOT_
- +10010:       d2824691        movz    x17, #0x1234
-       +10010: R_AARCH64_MOVW_PREL_G0  _GOT_
+ +10000:       d29fffe4        mov     x4, #0xffff                     // #65535
+                       10000: R_AARCH64_MOVW_PREL_G0   tempy
+ +10004:       929ffff1        mov     x17, #0xffffffffffff0000        // #-65536
+                       10004: R_AARCH64_MOVW_PREL_G0   tempy2
 
index ae9476ff8ab03154b43818ffec4a220006a735a9..f9e53dcd655117e51cc1d70a8239b7c6074fc273 100644 (file)
@@ -1,9 +1,5 @@
 .comm   gempy,4,4
 .text
-
-       and     x0,x0,x0
-       and     x0,x0,#0x1
-        movz   x4, :prel_g0:tempy
-       movz    x7, :prel_g0:tempy2
-       movz    x17, :prel_g0:tempy3
+       movz    x4, :prel_g0:tempy
+       movz    x17, :prel_g0:tempy2
 
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-288.d b/ld/testsuite/ld-aarch64/emit-relocs-288.d
new file mode 100644 (file)
index 0000000..d57f1b3
--- /dev/null
@@ -0,0 +1,11 @@
+#source: emit-relocs-288.s
+#ld: -T relocs.ld --defsym tempy=0x1ffff --defsym tempy2=0x20000 --defsym tempy3=0x0 -e0 --emit-relocs
+#objdump: -dr
+
+#...
+ +10000:       f29fffe4        movk    x4, #0xffff
+                       10000: R_AARCH64_MOVW_PREL_G0_NC        tempy
+ +10004:       f29fff87        movk    x7, #0xfffc
+                       10004: R_AARCH64_MOVW_PREL_G0_NC        tempy2
+ +10008:       f29fff11        movk    x17, #0xfff8
+                       10008: R_AARCH64_MOVW_PREL_G0_NC        tempy3
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-288.s b/ld/testsuite/ld-aarch64/emit-relocs-288.s
new file mode 100644 (file)
index 0000000..8f556ed
--- /dev/null
@@ -0,0 +1,5 @@
+.comm   gempy,4,4
+.text
+       movk    x4, :prel_g0_nc:tempy
+       movk    x7, :prel_g0_nc:tempy2
+       movk    x17, :prel_g0_nc:tempy3
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-289-overflow.d b/ld/testsuite/ld-aarch64/emit-relocs-289-overflow.d
new file mode 100644 (file)
index 0000000..77a6d2a
--- /dev/null
@@ -0,0 +1,4 @@
+#source: emit-relocs-289-overflow.s
+#ld: -T relocs.ld --defsym tempy=0x1100000000 -e0 --emit-relocs
+#objdump: -dr
+#error: .*\(.text\+0x\d+\): relocation truncated to fit: R_AARCH64_MOVW_PREL_G1 against symbol `tempy' .*
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-289-overflow.s b/ld/testsuite/ld-aarch64/emit-relocs-289-overflow.s
new file mode 100644 (file)
index 0000000..7d9f25e
--- /dev/null
@@ -0,0 +1,4 @@
+.comm   gempy,4,4
+.text
+
+       movz    x4, :prel_g1:tempy
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-289.d b/ld/testsuite/ld-aarch64/emit-relocs-289.d
new file mode 100644 (file)
index 0000000..6c5ba23
--- /dev/null
@@ -0,0 +1,10 @@
+#source: emit-relocs-289.s
+#ld: -Ttext 0x100000000 --defsym tempy=0x1ffffffff --defsym tempy2=0x4 -e0 --emit-relocs
+#objdump: -dr
+
+#...
+ +100000000:   d2bfffe4        mov     x4, #0xffff0000                 // #4294901760
+                       100000000: R_AARCH64_MOVW_PREL_G1       tempy
+ +100000004:   92bffff1        mov     x17, #0xffffffff0000ffff        // #-4294901761
+                       100000004: R_AARCH64_MOVW_PREL_G1       tempy2
+
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-289.s b/ld/testsuite/ld-aarch64/emit-relocs-289.s
new file mode 100644 (file)
index 0000000..ae1da9c
--- /dev/null
@@ -0,0 +1,4 @@
+.comm   gempy,4,4
+.text
+       movz    x4, :prel_g1:tempy
+       movz    x17, :prel_g1:tempy2
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-290.d b/ld/testsuite/ld-aarch64/emit-relocs-290.d
new file mode 100644 (file)
index 0000000..bc2c6fc
--- /dev/null
@@ -0,0 +1,11 @@
+#source: emit-relocs-290.s
+#ld: -Ttext=0x100000000 --defsym tempy=0x200000000 --defsym tempy2=0x1ffff0000 --defsym tempy3=0x8 -e0 --emit-relocs
+#objdump: -dr
+
+#...
+ +100000000:   f2a00004        movk    x4, #0x0, lsl #16
+                       100000000: R_AARCH64_MOVW_PREL_G1_NC    tempy
+ +100000004:   f2bfffc7        movk    x7, #0xfffe, lsl #16
+                       100000004: R_AARCH64_MOVW_PREL_G1_NC    tempy2
+ +100000008:   f2a00011        movk    x17, #0x0, lsl #16
+                       100000008: R_AARCH64_MOVW_PREL_G1_NC    tempy3
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-290.s b/ld/testsuite/ld-aarch64/emit-relocs-290.s
new file mode 100644 (file)
index 0000000..066ad64
--- /dev/null
@@ -0,0 +1,5 @@
+.comm   gempy,4,4
+.text
+       movk    x4, :prel_g1_nc:tempy
+       movk    x7, :prel_g1_nc:tempy2
+       movk    x17, :prel_g1_nc:tempy3
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-291-overflow.d b/ld/testsuite/ld-aarch64/emit-relocs-291-overflow.d
new file mode 100644 (file)
index 0000000..0ea3e50
--- /dev/null
@@ -0,0 +1,4 @@
+#source: emit-relocs-291-overflow.s
+#ld: -T relocs.ld --defsym tempy=0x10000000000000 -e0 --emit-relocs
+#objdump: -dr
+#error: .*\(.text\+0x\d+\): relocation truncated to fit: R_AARCH64_MOVW_PREL_G2 against symbol `tempy' .*
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-291-overflow.s b/ld/testsuite/ld-aarch64/emit-relocs-291-overflow.s
new file mode 100644 (file)
index 0000000..02649fa
--- /dev/null
@@ -0,0 +1,4 @@
+.comm   gempy,4,4
+.text
+
+       movz    x4, :prel_g2:tempy
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-291.d b/ld/testsuite/ld-aarch64/emit-relocs-291.d
new file mode 100644 (file)
index 0000000..53eb0e9
--- /dev/null
@@ -0,0 +1,11 @@
+#source: emit-relocs-291.s
+#ld: -Ttext 0x1000000000000 --defsym tempy=0x1ffffffffffff --defsym tempy2=0x1ffff00000000 -defsym tempy3=0x8 -e0 --emit-relocs
+#objdump: -dr
+
+#...
+ +1000000000000:       d2dfffe4        mov     x4, #0xffff00000000             // #281470681743360
+                       1000000000000: R_AARCH64_MOVW_PREL_G2   tempy
+ +1000000000004:       d2dfffc7        mov     x7, #0xfffe00000000             // #281466386776064
+                       1000000000004: R_AARCH64_MOVW_PREL_G2   tempy2
+ +1000000000008:       92dffff1        mov     x17, #0xffff0000ffffffff        // #-281470681743361
+                       1000000000008: R_AARCH64_MOVW_PREL_G2   tempy3
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-291.s b/ld/testsuite/ld-aarch64/emit-relocs-291.s
new file mode 100644 (file)
index 0000000..955fe1b
--- /dev/null
@@ -0,0 +1,5 @@
+.comm   gempy,4,4
+.text
+       movz    x4, :prel_g2:tempy
+       movz    x7, :prel_g2:tempy2
+       movz    x17, :prel_g2:tempy3
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-292.d b/ld/testsuite/ld-aarch64/emit-relocs-292.d
new file mode 100644 (file)
index 0000000..3fbde20
--- /dev/null
@@ -0,0 +1,11 @@
+#source: emit-relocs-292.s
+#ld: -Ttext 0x1000000000000 --defsym tempy=0x2000000000000 --defsym tempy2=0x1ffff00000004 --defsym tempy3=0x4 -e0 --emit-relocs
+#objdump: -dr
+
+#...
+ +1000000000000:       f2c00004        movk    x4, #0x0, lsl #32
+                       1000000000000: R_AARCH64_MOVW_PREL_G2_NC        tempy
+ +1000000000004:       f2dfffe7        movk    x7, #0xffff, lsl #32
+                       1000000000004: R_AARCH64_MOVW_PREL_G2_NC        tempy2
+ +1000000000008:       f2dffff1        movk    x17, #0xffff, lsl #32
+                       1000000000008: R_AARCH64_MOVW_PREL_G2_NC        tempy3
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-292.s b/ld/testsuite/ld-aarch64/emit-relocs-292.s
new file mode 100644 (file)
index 0000000..82972df
--- /dev/null
@@ -0,0 +1,6 @@
+.comm   gempy,4,4
+.text
+
+       movk    x4, :prel_g2_nc:tempy
+       movk    x7, :prel_g2_nc:tempy2
+       movk    x17, :prel_g2_nc:tempy3
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-293.d b/ld/testsuite/ld-aarch64/emit-relocs-293.d
new file mode 100644 (file)
index 0000000..1e15f18
--- /dev/null
@@ -0,0 +1,9 @@
+#source: emit-relocs-293.s
+#ld: -Ttext 0x1000000000000 --defsym tempy=0x2000000000000000 --defsym tempy2=0x8 -e0 --emit-relocs
+#objdump: -dr
+
+#...
+ +1000000000000:       d2e3ffe4        mov     x4, #0x1fff000000000000         // #2305561534236983296
+                       1000000000000: R_AARCH64_MOVW_PREL_G3   tempy
+ +1000000000004:       92e00007        movn    x7, #0x0, lsl #48
+                       1000000000004: R_AARCH64_MOVW_PREL_G3   tempy2
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-293.s b/ld/testsuite/ld-aarch64/emit-relocs-293.s
new file mode 100644 (file)
index 0000000..d5803c1
--- /dev/null
@@ -0,0 +1,5 @@
+.comm   gempy,4,4
+.text
+
+       movz    x4, :prel_g3:tempy
+       movz    x7, :prel_g3:tempy2