diff options
author | Sudakshina Das <sudi.das@arm.com> | 2019-03-13 10:42:27 +0000 |
---|---|---|
committer | Sudakshina Das <sudi.das@arm.com> | 2019-03-13 11:47:00 +0000 |
commit | cd702818c6cf25277253b3b5c23f17d2cf7a94df (patch) | |
tree | adf2c3ce998dc047a9f77fe8e4d2765dae5812bd /ld | |
parent | 44b27f959abf267fc9ec228f4131c932597b01d4 (diff) | |
download | fsf-binutils-gdb-cd702818c6cf25277253b3b5c23f17d2cf7a94df.zip fsf-binutils-gdb-cd702818c6cf25277253b3b5c23f17d2cf7a94df.tar.gz fsf-binutils-gdb-cd702818c6cf25277253b3b5c23f17d2cf7a94df.tar.bz2 |
[BFD, LD, AArch64, 1/3] Add support for GNU PROPERTIES in AArch64 for BTI and PAC
This is part of the patch series to add support for BTI and
PAC in AArch64 linker.
This patch implements the following:
1) This extends in the gnu property support in the linker for
AArch64 by defining backend hooks for elf_backend_setup_gnu_properties,
elf_backend_merge_gnu_properties and elf_backend_parse_gnu_properties.
2) It defines AArch64 specific GNU property
GNU_PROPERTY_AARCH64_FEATURE_1_AND and 2 bit for BTI and PAC in it.
3) It also adds support in readelf.c to read and print these new
GNU properties in AArch64.
All these are made according to the new AArch64 ELF ABI
https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2018q4
*** bfd/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
* elf-properties.c (_bfd_elf_link_setup_gnu_properties): Exclude
linker created inputs from merge.
* elfnn-aarch64.c (struct elf_aarch64_obj_tdata): Add field for
GNU_PROPERTY_AARCH64_FEATURE_1_AND properties.
(elfNN_aarch64_link_setup_gnu_properties): New.
(elfNN_aarch64_merge_gnu_properties): New.
(elf_backend_setup_gnu_properties): Define for AArch64.
(elf_backend_merge_gnu_properties): Likewise.
* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Define.
(_bfd_aarch64_elf_parse_gnu_properties): Define.
(_bfd_aarch64_elf_merge_gnu_properties): Define.
* elfxx-aarch64.h (_bfd_aarch64_elf_link_setup_gnu_properties): Declare.
(_bfd_aarch64_elf_parse_gnu_properties): Declare.
(_bfd_aarch64_elf_merge_gnu_properties): Declare.
(elf_backend_parse_gnu_properties): Define for AArch64.
*** binutils/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
* readelf.c (decode_aarch64_feature_1_and): New.
(print_gnu_property_note): Add case for AArch64 gnu notes.
*** include/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
* elf/common.h (GNU_PROPERTY_AARCH64_FEATURE_1_AND): New.
(GNU_PROPERTY_AARCH64_FEATURE_1_BTI): New.
(GNU_PROPERTY_AARCH64_FEATURE_1_PAC): New.
*** ld/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
* NEWS: Document GNU_PROPERTY_AARCH64_FEATURE_1_BTI and
GNU_PROPERTY_AARCH64_FEATURE_1_PAC.
* testsuite/ld-aarch64/aarch64-elf.exp: Add run commands for new tests.
* testsuite/ld-aarch64/property-bti-pac1.d: New test.
* testsuite/ld-aarch64/property-bti-pac1.s: New test.
* testsuite/ld-aarch64/property-bti-pac2.d: New test.
* testsuite/ld-aarch64/property-bti-pac2.s: New test.
* testsuite/ld-aarch64/property-bti-pac3.d: New test.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 11 | ||||
-rw-r--r-- | ld/NEWS | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/aarch64-elf.exp | 4 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/property-bti-pac1.d | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/property-bti-pac1.s | 37 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/property-bti-pac2.d | 12 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/property-bti-pac2.s | 50 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/property-bti-pac3.d | 12 |
8 files changed, 147 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 3722d4f..32b5387 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,14 @@ +2019-03-13 Sudakshina Das <sudi.das@arm.com> + + * NEWS: Document GNU_PROPERTY_AARCH64_FEATURE_1_BTI and + GNU_PROPERTY_AARCH64_FEATURE_1_PAC. + * testsuite/ld-aarch64/aarch64-elf.exp: Add run commands for new tests. + * testsuite/ld-aarch64/property-bti-pac1.d: New test. + * testsuite/ld-aarch64/property-bti-pac1.s: New test. + * testsuite/ld-aarch64/property-bti-pac2.d: New test. + * testsuite/ld-aarch64/property-bti-pac2.s: New test. + * testsuite/ld-aarch64/property-bti-pac3.d: New test. + 2019-03-13 H.J. Lu <hongjiu.lu@intel.com> PR ld/24322 @@ -1,5 +1,15 @@ -*- text -*- +Changes in 2.33: + +* Add target handlers for AArch64 for ELF GNU program properties. + +* Add support for GNU_PROPERTY_AARCH64_FEATURE_1_BTI in ELF GNU program + properties in the AArch64 ELF linker. + +* Add support for GNU_PROPERTY_AARCH64_FEATURE_1_PAC in ELF GNU program + properties in the AArch64 ELF linker. + Changes in 2.32: * Report property change in linker map file when merging GNU properties. diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp index 2b9fad5..c6fefbb 100644 --- a/ld/testsuite/ld-aarch64/aarch64-elf.exp +++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp @@ -371,6 +371,10 @@ run_dump_test_lp64 "rela-abs-relative-opt" run_dump_test_lp64 "pie-bind-locally" +run_dump_test "property-bti-pac1" +run_dump_test "property-bti-pac2" +run_dump_test "property-bti-pac3" + set aarch64elflinktests { {"ld-aarch64/so with global symbol" "-shared" "" "" {copy-reloc-so.s} {} "copy-reloc-so.so"} diff --git a/ld/testsuite/ld-aarch64/property-bti-pac1.d b/ld/testsuite/ld-aarch64/property-bti-pac1.d new file mode 100644 index 0000000..a681ad9 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-bti-pac1.d @@ -0,0 +1,11 @@ +#name: GNU Property (single input, combine section) +#source: property-bti-pac1.s +#as: -march=armv8.5-a -defsym __mult__=0 +#ld: -shared +#readelf: -n +#target: *linux* + +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: BTI, PAC diff --git a/ld/testsuite/ld-aarch64/property-bti-pac1.s b/ld/testsuite/ld-aarch64/property-bti-pac1.s new file mode 100644 index 0000000..414c927 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-bti-pac1.s @@ -0,0 +1,37 @@ + .text + .globl _start + .type _start,@function +_start: + mov x1, #2 +.ifndef __mult__ + bl foo +.endif + .section ".note.gnu.property", "a" + .p2align 3 + .long 1f - 0f /* name length */ + .long 5f - 2f /* data length */ + .long 5 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: + .p2align 3 +2: .long 0xc0000000 /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ +3: + .long 0x2 /* PAC. */ +4: + .p2align 3 +5: + .p2align 3 + .long 1f - 0f /* name length */ + .long 5f - 2f /* data length */ + .long 5 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: + .p2align 3 +2: .long 0xc0000000 /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ +3: + .long 0x1 /* BTI. */ +4: + .p2align 3 +5: diff --git a/ld/testsuite/ld-aarch64/property-bti-pac2.d b/ld/testsuite/ld-aarch64/property-bti-pac2.d new file mode 100644 index 0000000..bc2eaad --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-bti-pac2.d @@ -0,0 +1,12 @@ +#name: GNU Property (combine multiple with BTI) +#source: property-bti-pac1.s +#source: property-bti-pac2.s +#as: -mabi=lp64 -defsym __property_bti__=1 +#ld: -e _start +#readelf: -n +#target: *linux* + +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: BTI diff --git a/ld/testsuite/ld-aarch64/property-bti-pac2.s b/ld/testsuite/ld-aarch64/property-bti-pac2.s new file mode 100644 index 0000000..cdec8d9 --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-bti-pac2.s @@ -0,0 +1,50 @@ + .text + .global foo + .type foo, %function +foo: + sub sp, sp, #16 + mov w0, 9 + str w0, [sp, 12] + ldr w0, [sp, 12] + add w0, w0, 4 + str w0, [sp, 12] + nop + add sp, sp, 16 + ret + .size foo, .-foo + .global bar + .type bar, %function +.ifdef __property_bti__ + .section ".note.gnu.property", "a" + .p2align 3 + .long 1f - 0f /* name length */ + .long 5f - 2f /* data length */ + .long 5 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: + .p2align 3 +2: .long 0xc0000000 /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ +3: + .long 0x1 /* BTI. */ +4: + .p2align 3 +5: +.endif +.ifdef __property_pac__ + .section ".note.gnu.property", "a" + .p2align 3 + .long 1f - 0f /* name length */ + .long 5f - 2f /* data length */ + .long 5 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: + .p2align 3 +2: .long 0xc0000000 /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ +3: + .long 0x2 /* PAC. */ +4: + .p2align 3 +5: +.endif diff --git a/ld/testsuite/ld-aarch64/property-bti-pac3.d b/ld/testsuite/ld-aarch64/property-bti-pac3.d new file mode 100644 index 0000000..5290f4b --- /dev/null +++ b/ld/testsuite/ld-aarch64/property-bti-pac3.d @@ -0,0 +1,12 @@ +#name: GNU Property (combine multiple with PAC) +#source: property-bti-pac1.s +#source: property-bti-pac2.s +#as: -mabi=lp64 -defsym __property_pac__=1 +#ld: -e _start +#readelf: -n +#target: *linux* + +Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: AArch64 feature: PAC |