From: Siddhesh Poyarekar Date: Fri, 11 Sep 2020 03:48:10 +0000 (+0530) Subject: [Morello] Linker tests for capability data relocations X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a0b64c9957f2f4d8488dd381241b1534c163dce1;p=thirdparty%2Fbinutils-gdb.git [Morello] Linker tests for capability data relocations ld/ChangeLog: 2020-10-20 Siddhesh Poyarekar * 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. --- diff --git a/ld/ChangeLog b/ld/ChangeLog index b952f416e0c..13e55a71d51 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,16 @@ +2020-10-20 Siddhesh Poyarekar + + * 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 * testsuite/ld-aarch64/emit-relocs-morello-1.d: New file. diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp index ac0a998df90..7604061506e 100644 --- a/ld/testsuite/ld-aarch64/aarch64-elf.exp +++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp @@ -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 index 00000000000..f4a47355989 --- /dev/null +++ b/ld/testsuite/ld-aarch64/emit-relocs-morello-2-a64c.d @@ -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: + +.* : +.*: 6c6c6548 .* +.*: 6874206f .* +.*: 20657265 .* +.*: 20676962 .* +.*: 20646162 .* +.*: 6c726f77 .* +.*: .* + .*: R_AARCH64_RELATIVE \*ABS\*\+.* + +.* : +.*: [0-9a-f]+ .* + ... + +.* : +.*: [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 index 00000000000..def5db0ddc1 --- /dev/null +++ b/ld/testsuite/ld-aarch64/emit-relocs-morello-2.d @@ -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: + +.* : +.*: 6c6c6548 .* +.*: 6874206f .* +.*: 20657265 .* +.*: 20676962 .* +.*: 20646162 .* +.*: 6c726f77 .* +.*: .* + .*: R_AARCH64_RELATIVE \*ABS\*\+.* + +.* : +.*: 00010350 .* + ... + +.* : +.*: 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 index 00000000000..5e836de398e --- /dev/null +++ b/ld/testsuite/ld-aarch64/emit-relocs-morello-2.s @@ -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 index 00000000000..0feb5ae286d --- /dev/null +++ b/ld/testsuite/ld-aarch64/emit-relocs-morello-3-a64c.d @@ -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: + +.* : +.*: 6c6c6548 .* +.*: 6874206f .* +.*: 20657265 .* +.*: 20676962 .* +.*: 20646162 .* +.*: 6c726f77 .* +.*: 00002164 .* +.*: 00000000 .* + +.* : +.*: [0-9a-f]+ .* + .*: R_MORELLO_CAPINIT str +.*: 00000000 .* +.*: 00001b02 .* +.*: 00000000 .* + +.* : + ... + .*: 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 index 00000000000..38f65d09893 --- /dev/null +++ b/ld/testsuite/ld-aarch64/emit-relocs-morello-3.d @@ -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: + +.* : +.*: 6c6c6548 .* +.*: 6874206f .* +.*: 20657265 .* +.*: 20676962 .* +.*: 20646162 .* +.*: 6c726f77 .* +.*: 00002164 .* +.*: 00000000 .* + +.* : +.*: [0-9a-f]+ .* + .*: R_MORELLO_CAPINIT str +.*: 00000000 .* +.*: 00001b02 .* +.*: 00000000 .* + +.* : + ... + .*: 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 index 00000000000..32ad3acb34e --- /dev/null +++ b/ld/testsuite/ld-aarch64/emit-relocs-morello-3.s @@ -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 index 00000000000..d081fac519f --- /dev/null +++ b/ld/testsuite/ld-aarch64/emit-relocs-morello-a64c.d @@ -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]+\] + +.* : +.*: 826...42 ldr c2, \[c2, #[0-9]+\] + +Disassembly of section .got: + +.* <.got>: +.*: [0-9a-f]+ .* +.*: 00000000 .* + +Disassembly of section .data: + +.* : +.*: 00000042 .* + +.* : +.*: [0-9a-f]+ .* + .*: R_AARCH64_RELATIVE \*ABS\*\+.* + ... + +.* : +.*: [0-9a-f]+ .* + .*: R_MORELLO_RELATIVE \*ABS\* +.*: 00000000 .* +.*: 00000402 .* +.*: 00000000 .* + +.* : + ... + .*: 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 index 00000000000..0da62eda7a0 --- /dev/null +++ b/ld/testsuite/ld-aarch64/emit-relocs-morello.d @@ -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]+\] + +.* : +.*: c24...42 ldr c2, \[c2, #[0-9]+\] + +Disassembly of section .got: + +.* <.got>: +.*: [0-9a-f]+ .* +.*: 00000000 .* + +Disassembly of section .data: + +.* : +.*: 00000042 .* + +.* : +.*: [0-9a-f]+ .* + .*: R_AARCH64_RELATIVE \*ABS\*\+.* + ... + +.* : +.*: [0-9a-f]+ .* + .*: R_MORELLO_RELATIVE \*ABS\* +.*: 00000000 .* +.*: 00000402 .* +.*: 00000000 .* + +.* : + ... + .*: 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 index 00000000000..333f9b71c8d --- /dev/null +++ b/ld/testsuite/ld-aarch64/emit-relocs-morello.s @@ -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]