diff options
author | Sudakshina Das <sudi.das@arm.com> | 2019-03-13 11:09:10 +0000 |
---|---|---|
committer | Sudakshina Das <sudi.das@arm.com> | 2019-03-13 11:47:33 +0000 |
commit | 1dbade7441b9f32d6ba9aa1d44da5f28c44282fa (patch) | |
tree | dcf3b55249f9b6eafdd883ecf134ccc87dba800b /ld | |
parent | 37c18eedffe3926a330149ca93e7407917e2be38 (diff) | |
download | gdb-1dbade7441b9f32d6ba9aa1d44da5f28c44282fa.zip gdb-1dbade7441b9f32d6ba9aa1d44da5f28c44282fa.tar.gz gdb-1dbade7441b9f32d6ba9aa1d44da5f28c44282fa.tar.bz2 |
[BFD, LD, AArch64, 3/3] Add --pac-plt to enable PLTs protected with PAC.
This is part of the patch series to add support for BTI and
PAC in AArch64 linker.
1) This patch adds new definitions of PAC enabled PLTs
and both BTI and PAC enabled PLTs.
2) It also defines the new dynamic tag DT_AARCH64_PAC_PLT
for the PAC enabled PLTs.
3) This patch adds a new ld command line option: --pac-plt.
In the presence of this option, the linker uses the PAC
enabled PLTs and marks with DT_AARCH64_PAC_PLT.
4) In case both BTI and PAC are enabled the linker should
pick PLTs enabled with both and also use dynamic tags for both.
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>
* elfnn-aarch64.c (PLT_PAC_ENTRY_SIZE, PLT_PAC_SMALL_ENTRY_SIZE): New.
(PLT_BTI_PAC_ENTRY_SIZE, PLT_BTI_PAC_SMALL_ENTRY_SIZE): New.
(setup_plt_values): Account for PAC or PAC and BTI enabled PLTs.
(elfNN_aarch64_size_dynamic_sections): Add checks for PLT_BTI_PAC
and PLT_PAC_PLT.
(elfNN_aarch64_finish_dynamic_sections): Account for PLT_BTI_PAC.
(get_plt_type): Add case for DT_AARCH64_PAC_PLT.
(elfNN_aarch64_plt_sym_val): Add cases for PLT_BTI_PAC and PLT_PAC.
*** binutils/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
* readelf.c (get_aarch64_dynamic_type): Add case for
DT_AARCH64_PAC_PLT.
(dynamic_section_aarch64_val): Likewise.
*** include/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
* elf/aarch64.h (DT_AARCH64_PAC_PLT): New.
*** ld/ChangeLog ***
2019-03-13 Sudakshina Das <sudi.das@arm.com>
* NEWS: Document --pac-plt.
* emultempl/aarch64elf.em (OPTION_PAC_PLT): New.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add pac-plt.
(PARSE_AND_LIST_ARGS_CASES): Handle OPTION_PAC_PLT.
* testsuite/ld-aarch64/aarch64-elf.exp: Add the following tests.
* testsuite/ld-aarch64/bti-pac-plt-1.d: New test.
* testsuite/ld-aarch64/bti-pac-plt-2.d: New test.
* testsuite/ld-aarch64/pac-plt-1.d: New test.
* testsuite/ld-aarch64/pac-plt-2.d: New test.
* testsuite/ld-aarch64/bti-plt-1.s: Add .ifndef directive.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 13 | ||||
-rw-r--r-- | ld/NEWS | 2 | ||||
-rw-r--r-- | ld/emultempl/aarch64elf.em | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/aarch64-elf.exp | 5 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/bti-pac-plt-1.d | 34 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/bti-pac-plt-2.d | 36 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/bti-plt-1.s | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/pac-plt-1.d | 33 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/pac-plt-2.d | 24 |
9 files changed, 156 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 151877d..d37865b 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,4 +1,17 @@ 2019-03-13 Sudakshina Das <sudi.das@arm.com> + + * NEWS: Document --pac-plt. + * emultempl/aarch64elf.em (OPTION_PAC_PLT): New. + (PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS): Add pac-plt. + (PARSE_AND_LIST_ARGS_CASES): Handle OPTION_PAC_PLT. + * testsuite/ld-aarch64/aarch64-elf.exp: Add the following tests. + * testsuite/ld-aarch64/bti-pac-plt-1.d: New test. + * testsuite/ld-aarch64/bti-pac-plt-2.d: New test. + * testsuite/ld-aarch64/pac-plt-1.d: New test. + * testsuite/ld-aarch64/pac-plt-2.d: New test. + * testsuite/ld-aarch64/bti-plt-1.s: Add .ifndef directive. + +2019-03-13 Sudakshina Das <sudi.das@arm.com> Szabolcs Nagy <szabolcs.nagy@arm.com> * NEWS: Document --force-bti. @@ -14,6 +14,8 @@ Changes in 2.33: on output while warning about missing GNU_PROPERTY_AARCH64_FEATURE_1_BTI on inputs and use PLTs protected with BTI. +* Add --pac-plt for AArch64 to pick PAC enabled PLTs. + Changes in 2.32: * Report property change in linker map file when merging GNU properties. diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em index 02243d9..bfe8d1b 100644 --- a/ld/emultempl/aarch64elf.em +++ b/ld/emultempl/aarch64elf.em @@ -373,6 +373,7 @@ PARSE_AND_LIST_PROLOGUE=' #define OPTION_FIX_ERRATUM_843419 314 #define OPTION_NO_APPLY_DYNAMIC_RELOCS 315 #define OPTION_FORCE_BTI 316 +#define OPTION_PAC_PLT 317 ' PARSE_AND_LIST_SHORTOPTS=p @@ -387,6 +388,7 @@ PARSE_AND_LIST_LONGOPTS=' { "fix-cortex-a53-843419", no_argument, NULL, OPTION_FIX_ERRATUM_843419}, { "no-apply-dynamic-relocs", no_argument, NULL, OPTION_NO_APPLY_DYNAMIC_RELOCS}, { "force-bti", no_argument, NULL, OPTION_FORCE_BTI}, + { "pac-plt", no_argument, NULL, OPTION_PAC_PLT}, ' PARSE_AND_LIST_OPTIONS=' @@ -408,6 +410,7 @@ PARSE_AND_LIST_OPTIONS=' fprintf (file, _(" --fix-cortex-a53-843419 Fix erratum 843419\n")); fprintf (file, _(" --no-apply-dynamic-relocs Do not apply link-time values for dynamic relocations\n")); fprintf (file, _(" --force-bti Turn on Branch Target Identification mechanism and generate PLTs with BTI. Generate warnings for missing BTI on inputs\n")); + fprintf (file, _(" --pac-plt Protect PLTs with Pointer Authentication.\n")); ' PARSE_AND_LIST_ARGS_CASES=' @@ -444,6 +447,10 @@ PARSE_AND_LIST_ARGS_CASES=' bti_type = BTI_WARN; break; + case OPTION_PAC_PLT: + plt_type |= PLT_PAC; + break; + case OPTION_STUBGROUP_SIZE: { const char *end; diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp index 906534b..12c2d97 100644 --- a/ld/testsuite/ld-aarch64/aarch64-elf.exp +++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp @@ -402,3 +402,8 @@ run_dump_test "bti-plt-4" run_dump_test "bti-plt-5" run_dump_test "bti-plt-6" run_dump_test "bti-plt-7" + +run_dump_test "pac-plt-1" +run_dump_test "pac-plt-2" +run_dump_test "bti-pac-plt-1" +run_dump_test "bti-pac-plt-2" diff --git a/ld/testsuite/ld-aarch64/bti-pac-plt-1.d b/ld/testsuite/ld-aarch64/bti-pac-plt-1.d new file mode 100644 index 0000000..8d780ca --- /dev/null +++ b/ld/testsuite/ld-aarch64/bti-pac-plt-1.d @@ -0,0 +1,34 @@ +#source: bti-plt-1.s +#as: -mabi=lp64 +#ld: -shared --force-bti --pac-plt -T bti-plt.ld +#objdump: -dr -j .plt + +[^:]*: *file format elf64-.*aarch64 + +Disassembly of section \.plt: + +[0-9a-f]+ <.*>: +.*: d503245f bti c +.*: a9bf7bf0 stp x16, x30, \[sp, #-16\]! +.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_> +.*: f9400e11 ldr x17, \[x16, #24\] +.*: 91006210 add x16, x16, #0x18 +.*: d503219f autia1716 +.*: d61f0220 br x17 +.*: d503201f nop +.*: d503201f nop +.*: d503201f nop + +[0-9a-f]+ <.*>: +.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_> +.*: f9401211 ldr x17, \[x16, #32\] +.*: 91008210 add x16, x16, #0x20 +.*: d503219f autia1716 +.*: d61f0220 br x17 + +[0-9a-f]+ <.*>: +.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_> +.*: f9401611 ldr x17, \[x16, #40\] +.*: 9100a210 add x16, x16, #0x28 +.*: d503219f autia1716 +.*: d61f0220 br x17 diff --git a/ld/testsuite/ld-aarch64/bti-pac-plt-2.d b/ld/testsuite/ld-aarch64/bti-pac-plt-2.d new file mode 100644 index 0000000..d1264ea --- /dev/null +++ b/ld/testsuite/ld-aarch64/bti-pac-plt-2.d @@ -0,0 +1,36 @@ +#source: bti-plt-1.s +#as: -mabi=lp64 +#ld: --force-bti --pac-plt -e _start -T bti-plt.ld -L./tmpdir -lbti-plt-so +#objdump: -dr -j .plt + +[^:]*: *file format elf64-.*aarch64 + +Disassembly of section \.plt: + +[0-9]+ <.*>: +.*: d503245f bti c +.*: a9bf7bf0 stp x16, x30, \[sp, #-16\]! +.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_> +.*: f9400e11 ldr x17, \[x16, #24\] +.*: 91006210 add x16, x16, #0x18 +.*: d503219f autia1716 +.*: d61f0220 br x17 +.*: d503201f nop +.*: d503201f nop +.*: d503201f nop + +[0-9]+ <.*>: +.*: d503245f bti c +.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_> +.*: f9401211 ldr x17, \[x16, #32\] +.*: 91008210 add x16, x16, #0x20 +.*: d503219f autia1716 +.*: d61f0220 br x17 + +[0-9]+ <.*>: +.*: d503245f bti c +.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_> +.*: f9401611 ldr x17, \[x16, #40\] +.*: 9100a210 add x16, x16, #0x28 +.*: d503219f autia1716 +.*: d61f0220 br x17 diff --git a/ld/testsuite/ld-aarch64/bti-plt-1.s b/ld/testsuite/ld-aarch64/bti-plt-1.s index 78e1aaa..b798ca4 100644 --- a/ld/testsuite/ld-aarch64/bti-plt-1.s +++ b/ld/testsuite/ld-aarch64/bti-plt-1.s @@ -4,6 +4,7 @@ _start: bl foo bl bar +.ifndef __guard_property_bti__ .section ".note.gnu.property", "a" .p2align 3 .long 1f - 0f /* name length */ @@ -19,3 +20,4 @@ _start: 4: .p2align 3 5: +.endif diff --git a/ld/testsuite/ld-aarch64/pac-plt-1.d b/ld/testsuite/ld-aarch64/pac-plt-1.d new file mode 100644 index 0000000..47be949 --- /dev/null +++ b/ld/testsuite/ld-aarch64/pac-plt-1.d @@ -0,0 +1,33 @@ +#source: bti-plt-1.s +#as: -mabi=lp64 --defsym __guard_property_bti__=1 +#ld: -shared --pac-plt -T bti-plt.ld +#objdump: -dr -j .plt + +[^:]*: *file format elf64-.*aarch64 + +Disassembly of section \.plt: + +[0-9]+ <.*>: +.*: a9bf7bf0 stp x16, x30, \[sp, #-16\]! +.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_> +.*: f9400e11 ldr x17, \[x16, #24\] +.*: 91006210 add x16, x16, #0x18 +.*: d503219f autia1716 +.*: d61f0220 br x17 +.*: d503201f nop +.*: d503201f nop +.*: d503201f nop + +[0-9]+ <.*>: +.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_> +.*: f9401211 ldr x17, \[x16, #32\] +.*: 91008210 add x16, x16, #0x20 +.*: d503219f autia1716 +.*: d61f0220 br x17 + +[0-9]+ <.*>: +.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_> +.*: f9401611 ldr x17, \[x16, #40\] +.*: 9100a210 add x16, x16, #0x28 +.*: d503219f autia1716 +.*: d61f0220 br x17 diff --git a/ld/testsuite/ld-aarch64/pac-plt-2.d b/ld/testsuite/ld-aarch64/pac-plt-2.d new file mode 100644 index 0000000..42bfdca --- /dev/null +++ b/ld/testsuite/ld-aarch64/pac-plt-2.d @@ -0,0 +1,24 @@ +#source: tls-desc-ie.s +#ld: -shared --pac-plt -T bti-plt.ld +#objdump: -dr -j .plt +#... +Disassembly of section .plt: + +0000000000018000 \<.plt\>: +.*: a9bf7bf0 stp x16, x30, \[sp, #-16\]! +.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_> +.*: f9401a11 ldr x17, \[x16, #48\] +.*: 9100c210 add x16, x16, #0x30 +.*: d503219f autia1716 +.*: d61f0220 br x17 +.*: d503201f nop +.*: d503201f nop +.*: d503201f nop + + +0000000000018024 \<__tls_get_addr@plt\>: +.*: 90000090 adrp x16, 28000 <_GLOBAL_OFFSET_TABLE_> +.*: f9401e11 ldr x17, \[x16, #56\] +.*: 9100e210 add x16, x16, #0x38 +.*: d503219f autia1716 +.*: d61f0220 br x17 |