]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[Morello] Linker tests for capability data relocations
authorSiddhesh Poyarekar <siddesh.poyarekar@arm.com>
Fri, 11 Sep 2020 03:48:10 +0000 (09:18 +0530)
committerLuis Machado <luis.machado@linaro.org>
Tue, 20 Oct 2020 18:04:15 +0000 (15:04 -0300)
ld/ChangeLog:

2020-10-20  Siddhesh Poyarekar  <siddesh.poyarekar@arm.com>

* testsuite/ld-aarch64/emit-relocs-morello-2-a64c.d: New test.
* testsuite/ld-aarch64/emit-relocs-morello-2.d: Likewise.
* testsuite/ld-aarch64/emit-relocs-morello-2.s: Likewise.
* testsuite/ld-aarch64/emit-relocs-morello-3-a64c.d: Likewise.
* testsuite/ld-aarch64/emit-relocs-morello-3.d: Likewise.
* testsuite/ld-aarch64/emit-relocs-morello-3.s: Likewise.
* testsuite/ld-aarch64/emit-relocs-morello-a64c.d: Likewise.
* testsuite/ld-aarch64/emit-relocs-morello.d: Likewise.
* testsuite/ld-aarch64/emit-relocs-morello.s: Likewise.
* testsuite/ld-aarch64/aarch64-elf.exp: Add new tests.

ld/ChangeLog
ld/testsuite/ld-aarch64/aarch64-elf.exp
ld/testsuite/ld-aarch64/emit-relocs-morello-2-a64c.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-morello-2.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-morello-2.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-morello-3-a64c.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-morello-3.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-morello-3.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-morello-a64c.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-morello.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/emit-relocs-morello.s [new file with mode: 0644]

index b952f416e0c6fa1f2f473f2c78ba35e8888cc023..13e55a71d51a5f23aaa6f6699c699c5bc79ff166 100644 (file)
@@ -1,3 +1,16 @@
+2020-10-20  Siddhesh Poyarekar  <siddesh.poyarekar@arm.com>
+
+       * testsuite/ld-aarch64/emit-relocs-morello-2-a64c.d: New test.
+       * testsuite/ld-aarch64/emit-relocs-morello-2.d: Likewise.
+       * testsuite/ld-aarch64/emit-relocs-morello-2.s: Likewise.
+       * testsuite/ld-aarch64/emit-relocs-morello-3-a64c.d: Likewise.
+       * testsuite/ld-aarch64/emit-relocs-morello-3.d: Likewise.
+       * testsuite/ld-aarch64/emit-relocs-morello-3.s: Likewise.
+       * testsuite/ld-aarch64/emit-relocs-morello-a64c.d: Likewise.
+       * testsuite/ld-aarch64/emit-relocs-morello.d: Likewise.
+       * testsuite/ld-aarch64/emit-relocs-morello.s: Likewise.
+       * testsuite/ld-aarch64/aarch64-elf.exp: Add new tests.
+
 2020-10-20  Siddhesh Poyarekar  <siddesh.poyarekar@arm.com>
 
        * testsuite/ld-aarch64/emit-relocs-morello-1.d: New file.
index ac0a998df90b0e3b381c209c52614bba7727d585..7604061506e9a4eccd533b6ca0310d0678984fde 100644 (file)
@@ -238,6 +238,12 @@ run_dump_test_lp64 "emit-relocs-558-overflow"
 run_dump_test_lp64 "emit-relocs-559"
 run_dump_test_lp64 "emit-relocs-560"
 run_dump_test_lp64 "emit-relocs-morello-1"
+run_dump_test_lp64 "emit-relocs-morello"
+run_dump_test_lp64 "emit-relocs-morello-a64c"
+run_dump_test_lp64 "emit-relocs-morello-2"
+run_dump_test_lp64 "emit-relocs-morello-2-a64c"
+run_dump_test_lp64 "emit-relocs-morello-3"
+run_dump_test_lp64 "emit-relocs-morello-3-a64c"
 
 run_dump_test_lp64 "morello-capinit"
 
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-morello-2-a64c.d b/ld/testsuite/ld-aarch64/emit-relocs-morello-2-a64c.d
new file mode 100644 (file)
index 0000000..f4a4735
--- /dev/null
@@ -0,0 +1,45 @@
+#source: emit-relocs-morello-2.s
+#as: -march=morello+a64c
+#ld: -shared
+#objdump: -DR -j .text -j .data -j .got
+
+.*:     file format .*
+
+
+Disassembly of section .text:
+
+.* <_start>:
+.*:    90000082        adrp    x2, [0-9a-f]+ <.*>
+.*:    826...42        ldr     c2, \[c2, #[0-9]+\]
+.*:    c24...42        ldr     c2, \[x2, #[0-9]+\]
+.*:    f94...42        ldr     x2, \[x2, #[0-9]+\]
+
+Disassembly of section .got:
+
+.* <.got>:
+.*:    [0-9a-f]+       .*
+       ...
+                       .*: R_MORELLO_GLOB_DAT  cap
+
+Disassembly of section .data:
+
+.* <str>:
+.*:    6c6c6548        .*
+.*:    6874206f        .*
+.*:    20657265        .*
+.*:    20676962        .*
+.*:    20646162        .*
+.*:    6c726f77        .*
+.*:    .*
+                       .*: R_AARCH64_RELATIVE  \*ABS\*\+.*
+
+.* <ptr>:
+.*:    [0-9a-f]+       .*
+       ...
+
+.* <cap>:
+.*:    [0-9a-f]+       .*
+                       .*: R_MORELLO_RELATIVE  \*ABS\*
+.*:    00000000        .*
+.*:    00001b02        .*
+.*:    00000000        .*
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-morello-2.d b/ld/testsuite/ld-aarch64/emit-relocs-morello-2.d
new file mode 100644 (file)
index 0000000..def5db0
--- /dev/null
@@ -0,0 +1,45 @@
+#source: emit-relocs-morello-2.s
+#as: -march=morello+c64 --defsym C64MODE=1
+#ld: -shared
+#objdump: -DR -j .text -j .data -j .got
+
+.*:     file format .*
+
+
+Disassembly of section .text:
+
+.* <_start>:
+.*:    90800082        adrp    c2, [0-9a-f]+ <.*>
+.*:    c24...42        ldr     c2, \[c2, #[0-9]+\]
+.*:    826...42        ldr     c2, \[x2, #[0-9]+\]
+.*:    826...42        ldr     x2, \[x2, #[0-9]+\]
+
+Disassembly of section .got:
+
+.* <.got>:
+.*:    [0-9a-f]+       .*
+       ...
+                       .*: R_MORELLO_GLOB_DAT  cap
+
+Disassembly of section .data:
+
+.* <str>:
+.*:    6c6c6548        .*
+.*:    6874206f        .*
+.*:    20657265        .*
+.*:    20676962        .*
+.*:    20646162        .*
+.*:    6c726f77        .*
+.*:            .*
+                       .*: R_AARCH64_RELATIVE  \*ABS\*\+.*
+
+.* <ptr>:
+.*:    00010350        .*
+       ...
+
+.* <cap>:
+.*:    00010350        .*
+                       .*: R_MORELLO_RELATIVE  \*ABS\*
+.*:    00000000        .*
+.*:    00001b02        .*
+.*:    00000000        .*
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-morello-2.s b/ld/testsuite/ld-aarch64/emit-relocs-morello-2.s
new file mode 100644 (file)
index 0000000..5e836de
--- /dev/null
@@ -0,0 +1,21 @@
+.data
+str:
+       .string "Hello there big bad world!"
+       .size str,.-str
+ptr:
+       .8byte str
+.align 4
+.globl cap
+cap:
+       .capinit str
+       .8byte 0
+       .8byte 0
+
+.text
+.globl _start
+.type _start STT_FUNC
+_start:
+       adrp    c2, :got:cap
+       ldr     c2, [c2, :got_lo12:cap]
+       ldr     c2, [x2, :got_lo12:cap]
+       ldr     x2, [x2, :got_lo12:cap]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-morello-3-a64c.d b/ld/testsuite/ld-aarch64/emit-relocs-morello-3-a64c.d
new file mode 100644 (file)
index 0000000..0feb5ae
--- /dev/null
@@ -0,0 +1,47 @@
+#source: emit-relocs-morello-3.s
+#as: -march=morello
+#ld: -shared
+#objdump: -DR -j .text -j .data -j .got
+
+.*:     file format .*
+
+
+Disassembly of section .text:
+
+.* <_start>:
+.*:    90000082        adrp    x2, [0-9a-f]+ <.*>
+.*:    826...42        ldr     c2, \[c2, #[0-9]+\]
+.*:    826...42        ldr     c2, \[c2, #[0-9]+\]
+.*:    826...42        ldr     c2, \[c2, #[0-9]+\]
+
+Disassembly of section .got:
+
+.* <.got>:
+.*:    [0-9a-f]+       .*
+       ...
+                       .*: R_MORELLO_GLOB_DAT  cap3
+                       .*: R_MORELLO_GLOB_DAT  cap2
+                       .*: R_MORELLO_GLOB_DAT  cap
+
+Disassembly of section .data:
+
+.* <str>:
+.*:    6c6c6548        .*
+.*:    6874206f        .*
+.*:    20657265        .*
+.*:    20676962        .*
+.*:    20646162        .*
+.*:    6c726f77        .*
+.*:    00002164        .*
+.*:    00000000        .*
+
+.* <cap>:
+.*:    [0-9a-f]+       .*
+                       .*: R_MORELLO_CAPINIT   str
+.*:    00000000        .*
+.*:    00001b02        .*
+.*:    00000000        .*
+
+.* <cap2>:
+       ...
+                       .*: R_MORELLO_CAPINIT   str2
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-morello-3.d b/ld/testsuite/ld-aarch64/emit-relocs-morello-3.d
new file mode 100644 (file)
index 0000000..38f65d0
--- /dev/null
@@ -0,0 +1,47 @@
+#source: emit-relocs-morello-3.s
+#as: -march=morello+c64 --defsym C64MODE=1
+#ld: -shared
+#objdump: -DR -j .text -j .data -j .got
+
+.*:     file format .*
+
+
+Disassembly of section .text:
+
+.* <_start>:
+.*:    90800082        adrp    c2, [0-9a-f]+ <.*>
+.*:    c24...42        ldr     c2, \[c2, #[0-9]+\]
+.*:    c24...42        ldr     c2, \[c2, #[0-9]+\]
+.*:    c24...42        ldr     c2, \[c2, #[0-9]+\]
+
+Disassembly of section .got:
+
+.* <.got>:
+.*:    [0-9a-f]+       .*
+       ...
+                       .*: R_MORELLO_GLOB_DAT  cap3
+                       .*: R_MORELLO_GLOB_DAT  cap2
+                       .*: R_MORELLO_GLOB_DAT  cap
+
+Disassembly of section .data:
+
+.* <str>:
+.*:    6c6c6548        .*
+.*:    6874206f        .*
+.*:    20657265        .*
+.*:    20676962        .*
+.*:    20646162        .*
+.*:    6c726f77        .*
+.*:    00002164        .*
+.*:    00000000        .*
+
+.* <cap>:
+.*:    [0-9a-f]+       .*
+                       .*: R_MORELLO_CAPINIT   str
+.*:    00000000        .*
+.*:    00001b02        .*
+.*:    00000000        .*
+
+.* <cap2>:
+       ...
+                       .*: R_MORELLO_CAPINIT   str2
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-morello-3.s b/ld/testsuite/ld-aarch64/emit-relocs-morello-3.s
new file mode 100644 (file)
index 0000000..32ad3ac
--- /dev/null
@@ -0,0 +1,28 @@
+.data
+.globl str
+str:
+       .string "Hello there big bad world!"
+       .size str,.-str
+.align 4
+.globl cap
+cap:
+       .capinit str
+       .8byte 0
+       .8byte 0
+
+.globl cap2
+cap2:
+       .capinit str2
+       .8byte 0
+       .8byte 0
+
+.text
+.globl _start
+.type _start STT_FUNC
+_start:
+       adrp    c2, :got:cap
+       ldr     c2, [c2, :got_lo12:cap]
+       ldr     c2, [c2, :got_lo12:cap2]
+       // An external symbol.  The linker should create a R_MORELLO_GLOB_DAT
+       // for this since it is a capability load.
+       ldr     c2, [c2, :got_lo12:cap3]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-morello-a64c.d b/ld/testsuite/ld-aarch64/emit-relocs-morello-a64c.d
new file mode 100644 (file)
index 0000000..d081fac
--- /dev/null
@@ -0,0 +1,45 @@
+#source: emit-relocs-morello.s
+#as: -march=morello
+#ld: -shared
+#objdump: -DR -j .text -j .data -j .got
+
+.*:     file format .*
+
+
+Disassembly of section .text:
+
+.* <_start>:
+.*:    826...42        ldr     c2, \[c2, #[0-9]+\]
+.*:    c24...42        ldr     c2, \[x2, #[0-9]+\]
+.*:    f94...42        ldr     x2, \[x2, #[0-9]+\]
+.*:    b94...42        ldr     w2, \[x2, #[0-9]+\]
+
+.* <f1>:
+.*:    826...42        ldr     c2, \[c2, #[0-9]+\]
+
+Disassembly of section .got:
+
+.* <.got>:
+.*:    [0-9a-f]+       .*
+.*:    00000000        .*
+
+Disassembly of section .data:
+
+.* <num>:
+.*:    00000042        .*
+
+.* <ptr>:
+.*:    [0-9a-f]+       .*
+                       .*: R_AARCH64_RELATIVE  \*ABS\*\+.*
+       ...
+
+.* <cap>:
+.*:    [0-9a-f]+       .*
+                       .*: R_MORELLO_RELATIVE  \*ABS\*
+.*:    00000000        .*
+.*:    00000402        .*
+.*:    00000000        .*
+
+.* <globcap>:
+       ...
+                       .*: R_MORELLO_CAPINIT   globvar
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-morello.d b/ld/testsuite/ld-aarch64/emit-relocs-morello.d
new file mode 100644 (file)
index 0000000..0da62ed
--- /dev/null
@@ -0,0 +1,45 @@
+#source: emit-relocs-morello.s
+#as: -march=morello+c64
+#ld: -shared
+#objdump: -DR -j .text -j .data -j .got
+
+.*:     file format .*
+
+
+Disassembly of section .text:
+
+.* <_start>:
+.*:    c24...42        ldr     c2, \[c2, #[0-9]+\]
+.*:    826...42        ldr     c2, \[x2, #[0-9]+\]
+.*:    826...42        ldr     x2, \[x2, #[0-9]+\]
+.*:    826...42        ldr     w2, \[x2, #[0-9]+\]
+
+.* <f1>:
+.*:    c24...42        ldr     c2, \[c2, #[0-9]+\]
+
+Disassembly of section .got:
+
+.* <.got>:
+.*:    [0-9a-f]+       .*
+.*:    00000000        .*
+
+Disassembly of section .data:
+
+.* <num>:
+.*:    00000042        .*
+
+.* <ptr>:
+.*:    [0-9a-f]+       .*
+                       .*: R_AARCH64_RELATIVE  \*ABS\*\+.*
+       ...
+
+.* <cap>:
+.*:    [0-9a-f]+       .*
+                       .*: R_MORELLO_RELATIVE  \*ABS\*
+.*:    00000000        .*
+.*:    00000402        .*
+.*:    00000000        .*
+
+.* <globcap>:
+       ...
+                       .*: R_MORELLO_CAPINIT   globvar
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-morello.s b/ld/testsuite/ld-aarch64/emit-relocs-morello.s
new file mode 100644 (file)
index 0000000..333f9b7
--- /dev/null
@@ -0,0 +1,29 @@
+.data
+num:
+       .word 0x42
+       .size num, .-num
+ptr:
+       .8byte num
+.align 4
+cap:
+       .capinit num
+       .8byte 0
+       .8byte 0
+
+globcap:
+       .capinit globvar
+       .8byte 0
+       .8byte 0
+
+.text
+.globl _start
+.type _start STT_FUNC
+_start:
+       ldr     c2, [c2, :lo12:cap]
+       ldr     c2, [x2, :lo12:cap]
+       ldr     x2, [x2, :lo12:cap]
+       ldr     w2, [x2, :lo12:cap]
+
+// Capability pointing to an undefined variable.
+f1:
+       ldr     c2, [c2, :lo12:globcap]