cd702818c6
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.
51 lines
901 B
ArmAsm
51 lines
901 B
ArmAsm
.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
|