[LD, AArch64] Move ELF options behind -z

This patch moves the current AArch64 ld options of --force-bti
and --pac-plt to -z force-bti and -z pac-plt since these are
ELF specific options.

*** bfd/ChangeLog ***

2019-06-06  Sudakshina Das  <sudi.das@arm.com>

	* bfd-in.h: Change comment.
	* bfd-in2.h: Regenerate.
	* elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update warning.
	* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties):
	Likwise.

*** ld/ChangeLog ***

2019-06-06  Sudakshina Das  <sudi.das@arm.com>

	* NEWS: Update options names.
	* emultempl/aarch64elf.em (OPTION_FORCE_BTI, OPTION_PAC_PLT): Remove.
	(PARSE_AND_LIST_LONGOPTS): Remove force-bti and pac-plt.
	(PARSE_AND_LIST_OPTIONS): Update to -z.
	(PARSE_AND_LIST_ARGS_CASE_Z_AARCH64): New.
	(PARSE_AND_LIST_ARGS_CASE_Z): Add PARSE_AND_LIST_ARGS_CASE_Z_AARCH64.
	(PARSE_AND_LIST_ARGS_CASES): Move cases for these options.
	* testsuite/ld-aarch64/bti-pac-plt-1.d: Update option.
	* testsuite/ld-aarch64/bti-pac-plt-2.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-1.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-2.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-3.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-4.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-6.d: Likewise.
	* testsuite/ld-aarch64/bti-plt-7.d: Likewise.
	* testsuite/ld-aarch64/bti-warn.d: Likewise.
	* testsuite/ld-aarch64/pac-plt-1.d: Likewise.
	* testsuite/ld-aarch64/pac-plt-2.d: Likewise.
This commit is contained in:
Sudakshina Das 2019-06-06 12:21:14 +01:00
parent 811731b21b
commit 8bf6d176b0
19 changed files with 69 additions and 42 deletions

View File

@ -1,3 +1,11 @@
2019-06-06 Sudakshina Das <sudi.das@arm.com>
* bfd-in.h: Change comment.
* bfd-in2.h: Regenerate.
* elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update warning.
* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties):
Likwise.
2019-05-28 Faraz Shahbazker <fshahbazker@wavecomp.com> 2019-05-28 Faraz Shahbazker <fshahbazker@wavecomp.com>
* elfxx-mips.c (mips_elf_calculate_relocation) <R_MIPS_PCHI16>: * elfxx-mips.c (mips_elf_calculate_relocation) <R_MIPS_PCHI16>:

View File

@ -1014,7 +1014,7 @@ typedef enum
typedef enum typedef enum
{ {
BTI_NONE = 0, /* BTI is not enabled. */ BTI_NONE = 0, /* BTI is not enabled. */
BTI_WARN = 1, /* BTI is enabled with --force-bti. */ BTI_WARN = 1, /* BTI is enabled with -z force-bti. */
} aarch64_enable_bti_type; } aarch64_enable_bti_type;
/* A structure to encompass all information coming from BTI or PAC /* A structure to encompass all information coming from BTI or PAC

View File

@ -1021,7 +1021,7 @@ typedef enum
typedef enum typedef enum
{ {
BTI_NONE = 0, /* BTI is not enabled. */ BTI_NONE = 0, /* BTI is not enabled. */
BTI_WARN = 1, /* BTI is enabled with --force-bti. */ BTI_WARN = 1, /* BTI is enabled with -z force-bti. */
} aarch64_enable_bti_type; } aarch64_enable_bti_type;
/* A structure to encompass all information coming from BTI or PAC /* A structure to encompass all information coming from BTI or PAC

View File

@ -10010,14 +10010,14 @@ elfNN_aarch64_merge_gnu_properties (struct bfd_link_info *info,
if ((aprop && !(aprop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) if ((aprop && !(aprop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI))
|| !aprop) || !aprop)
{ {
_bfd_error_handler (_("%pB: warning: BTI turned on by --force-bti when " _bfd_error_handler (_("%pB: warning: BTI turned on by -z force-bti when "
"all inputs do not have BTI in NOTE section."), "all inputs do not have BTI in NOTE section."),
abfd); abfd);
} }
if ((bprop && !(bprop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) if ((bprop && !(bprop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI))
|| !bprop) || !bprop)
{ {
_bfd_error_handler (_("%pB: warning: BTI turned on by --force-bti when " _bfd_error_handler (_("%pB: warning: BTI turned on by -z force-bti when "
"all inputs do not have BTI in NOTE section."), "all inputs do not have BTI in NOTE section."),
bbfd); bbfd);
} }

View File

@ -721,7 +721,7 @@ _bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *info,
4); 4);
if (gnu_prop & GNU_PROPERTY_AARCH64_FEATURE_1_BTI if (gnu_prop & GNU_PROPERTY_AARCH64_FEATURE_1_BTI
&& !(prop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) && !(prop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI))
_bfd_error_handler (_("%pB: warning: BTI turned on by --force-bti " _bfd_error_handler (_("%pB: warning: BTI turned on by -z force-bti "
"when all inputs do not have BTI in NOTE " "when all inputs do not have BTI in NOTE "
"section."), ebfd); "section."), ebfd);
prop->u.number |= gnu_prop; prop->u.number |= gnu_prop;

View File

@ -1,3 +1,24 @@
2019-06-06 Sudakshina Das <sudi.das@arm.com>
* NEWS: Update options names.
* emultempl/aarch64elf.em (OPTION_FORCE_BTI, OPTION_PAC_PLT): Remove.
(PARSE_AND_LIST_LONGOPTS): Remove force-bti and pac-plt.
(PARSE_AND_LIST_OPTIONS): Update to -z.
(PARSE_AND_LIST_ARGS_CASE_Z_AARCH64): New.
(PARSE_AND_LIST_ARGS_CASE_Z): Add PARSE_AND_LIST_ARGS_CASE_Z_AARCH64.
(PARSE_AND_LIST_ARGS_CASES): Move cases for these options.
* testsuite/ld-aarch64/bti-pac-plt-1.d: Update option.
* testsuite/ld-aarch64/bti-pac-plt-2.d: Likewise.
* testsuite/ld-aarch64/bti-plt-1.d: Likewise.
* testsuite/ld-aarch64/bti-plt-2.d: Likewise.
* testsuite/ld-aarch64/bti-plt-3.d: Likewise.
* testsuite/ld-aarch64/bti-plt-4.d: Likewise.
* testsuite/ld-aarch64/bti-plt-6.d: Likewise.
* testsuite/ld-aarch64/bti-plt-7.d: Likewise.
* testsuite/ld-aarch64/bti-warn.d: Likewise.
* testsuite/ld-aarch64/pac-plt-1.d: Likewise.
* testsuite/ld-aarch64/pac-plt-2.d: Likewise.
2019-05-30 Nick Clifton <nickc@redhat.com> 2019-05-30 Nick Clifton <nickc@redhat.com>
PR 24627 PR 24627

View File

@ -18,11 +18,11 @@ Changes in 2.33:
* Add support for GNU_PROPERTY_AARCH64_FEATURE_1_PAC in ELF GNU program * Add support for GNU_PROPERTY_AARCH64_FEATURE_1_PAC in ELF GNU program
properties in the AArch64 ELF linker. properties in the AArch64 ELF linker.
* Add --force-bti for AArch64 to enable GNU_PROPERTY_AARCH64_FEATURE_1_BTI * Add -z force-bti for AArch64 to enable GNU_PROPERTY_AARCH64_FEATURE_1_BTI
on output while warning about missing GNU_PROPERTY_AARCH64_FEATURE_1_BTI on output while warning about missing GNU_PROPERTY_AARCH64_FEATURE_1_BTI
on inputs and use PLTs protected with BTI. on inputs and use PLTs protected with BTI.
* Add --pac-plt for AArch64 to pick PAC enabled PLTs. * Add -z pac-plt for AArch64 to pick PAC enabled PLTs.
Changes in 2.32: Changes in 2.32:

View File

@ -372,8 +372,6 @@ PARSE_AND_LIST_PROLOGUE='
#define OPTION_FIX_ERRATUM_835769 313 #define OPTION_FIX_ERRATUM_835769 313
#define OPTION_FIX_ERRATUM_843419 314 #define OPTION_FIX_ERRATUM_843419 314
#define OPTION_NO_APPLY_DYNAMIC_RELOCS 315 #define OPTION_NO_APPLY_DYNAMIC_RELOCS 315
#define OPTION_FORCE_BTI 316
#define OPTION_PAC_PLT 317
' '
PARSE_AND_LIST_SHORTOPTS=p PARSE_AND_LIST_SHORTOPTS=p
@ -387,8 +385,6 @@ PARSE_AND_LIST_LONGOPTS='
{ "fix-cortex-a53-835769", no_argument, NULL, OPTION_FIX_ERRATUM_835769}, { "fix-cortex-a53-835769", no_argument, NULL, OPTION_FIX_ERRATUM_835769},
{ "fix-cortex-a53-843419", optional_argument, NULL, OPTION_FIX_ERRATUM_843419}, { "fix-cortex-a53-843419", optional_argument, NULL, OPTION_FIX_ERRATUM_843419},
{ "no-apply-dynamic-relocs", no_argument, NULL, OPTION_NO_APPLY_DYNAMIC_RELOCS}, { "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=' PARSE_AND_LIST_OPTIONS='
@ -419,10 +415,21 @@ PARSE_AND_LIST_OPTIONS='
instruction into an ADR. As such the workaround will always use a\n\ instruction into an ADR. As such the workaround will always use a\n\
veneer and this will give you both a performance and size overhead.\n")); veneer and this will give you both a performance and size overhead.\n"));
fprintf (file, _(" --no-apply-dynamic-relocs Do not apply link-time values for dynamic relocations\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, _(" -z 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")); fprintf (file, _(" -z pac-plt Protect PLTs with Pointer Authentication.\n"));
' '
PARSE_AND_LIST_ARGS_CASE_Z_AARCH64='
else if (strcmp (optarg, "force-bti") == 0)
{
plt_type |= PLT_BTI;
bti_type = BTI_WARN;
}
else if (strcmp (optarg, "pac-plt") == 0)
plt_type |= PLT_PAC;
'
PARSE_AND_LIST_ARGS_CASE_Z="$PARSE_AND_LIST_ARGS_CASE_Z $PARSE_AND_LIST_ARGS_CASE_Z_AARCH64"
PARSE_AND_LIST_ARGS_CASES=' PARSE_AND_LIST_ARGS_CASES='
case '\'p\'': case '\'p\'':
/* Only here for backwards compatibility. */ /* Only here for backwards compatibility. */
@ -464,15 +471,6 @@ PARSE_AND_LIST_ARGS_CASES='
no_apply_dynamic_relocs = 1; no_apply_dynamic_relocs = 1;
break; break;
case OPTION_FORCE_BTI:
plt_type |= PLT_BTI;
bti_type = BTI_WARN;
break;
case OPTION_PAC_PLT:
plt_type |= PLT_PAC;
break;
case OPTION_STUBGROUP_SIZE: case OPTION_STUBGROUP_SIZE:
{ {
const char *end; const char *end;

View File

@ -1,6 +1,6 @@
#source: bti-plt-1.s #source: bti-plt-1.s
#as: -mabi=lp64 #as: -mabi=lp64
#ld: -shared --force-bti --pac-plt -T bti-plt.ld #ld: -shared -z force-bti -z pac-plt -T bti-plt.ld
#objdump: -dr -j .plt #objdump: -dr -j .plt
[^:]*: *file format elf64-.*aarch64 [^:]*: *file format elf64-.*aarch64

View File

@ -1,6 +1,6 @@
#source: bti-plt-1.s #source: bti-plt-1.s
#as: -mabi=lp64 #as: -mabi=lp64
#ld: --force-bti --pac-plt -e _start -T bti-plt.ld -L./tmpdir -lbti-plt-so #ld: -z force-bti -z pac-plt -e _start -T bti-plt.ld -L./tmpdir -lbti-plt-so
#objdump: -dr -j .plt #objdump: -dr -j .plt
[^:]*: *file format elf64-.*aarch64 [^:]*: *file format elf64-.*aarch64

View File

@ -1,7 +1,7 @@
#name: Check --force-bti emits BTI PLT (shared) #name: Check -z force-bti emits BTI PLT (shared)
#source: bti-plt-1.s #source: bti-plt-1.s
#as: -mabi=lp64 #as: -mabi=lp64
#ld: -shared --force-bti -T bti-plt.ld #ld: -shared -z force-bti -T bti-plt.ld
#objdump: -dr -j .plt #objdump: -dr -j .plt
[^:]*: *file format elf64-.*aarch64 [^:]*: *file format elf64-.*aarch64

View File

@ -1,8 +1,8 @@
#name: Check --force-bti emits BTI feature (shared) #name: Check -z force-bti emits BTI feature (shared)
#source: bti-plt-1.s #source: bti-plt-1.s
#source: bti-plt-2.s #source: bti-plt-2.s
#as: -mabi=lp64 #as: -mabi=lp64
#ld: -shared --force-bti -T bti-plt.ld #ld: -shared -z force-bti -T bti-plt.ld
#readelf: -n #readelf: -n
Displaying notes found in: .note.gnu.property Displaying notes found in: .note.gnu.property

View File

@ -1,7 +1,7 @@
#name: Check --force-bti emits BTI PLT (exec) #name: Check -z force-bti emits BTI PLT (exec)
#source: bti-plt-1.s #source: bti-plt-1.s
#as: -mabi=lp64 #as: -mabi=lp64
#ld: --force-bti -e _start -T bti-plt.ld -L./tmpdir -lbti-plt-so #ld: -z force-bti -e _start -T bti-plt.ld -L./tmpdir -lbti-plt-so
#objdump: -dr -j .plt #objdump: -dr -j .plt
[^:]*: *file format elf64-.*aarch64 [^:]*: *file format elf64-.*aarch64

View File

@ -1,7 +1,7 @@
#name: Check --force-bti emits BTI feature (exec) #name: Check -z force-bti emits BTI feature (exec)
#source: bti-plt-1.s #source: bti-plt-1.s
#as: -mabi=lp64 #as: -mabi=lp64
#ld: --force-bti -e _start -T bti-plt.ld -L./tmpdir -lbti-plt-so #ld: -z force-bti -e _start -T bti-plt.ld -L./tmpdir -lbti-plt-so
#readelf: -n #readelf: -n
Displaying notes found in: .note.gnu.property Displaying notes found in: .note.gnu.property

View File

@ -2,8 +2,8 @@
#source: property-bti-pac2.s #source: property-bti-pac2.s
#source: property-bti-pac1.s #source: property-bti-pac1.s
#as: -mabi=lp64 -defsym __property_pac__=1 #as: -mabi=lp64 -defsym __property_pac__=1
#ld: -shared --force-bti #ld: -shared -z force-bti
#warning: .*property-bti-pac2.*: warning: BTI turned on by --force-bti.*$ #warning: .*property-bti-pac2.*: warning: BTI turned on by -z force-bti.*$
#readelf: -n #readelf: -n
# Should warn about the missing input BTI NOTE but should # Should warn about the missing input BTI NOTE but should

View File

@ -2,9 +2,9 @@
#source: property-bti-pac2.s #source: property-bti-pac2.s
#source: plt_mapping_symbol.s #source: plt_mapping_symbol.s
#as: -mabi=lp64 #as: -mabi=lp64
#ld: -shared --force-bti #ld: -shared -z force-bti
#warning: .*plt_mapping_symbol.*: warning: BTI turned on by --force-bti.* #warning: .*plt_mapping_symbol.*: warning: BTI turned on by -z force-bti.*
#warning: .*property-bti-pac2.*: warning: BTI turned on by --force-bti.* #warning: .*property-bti-pac2.*: warning: BTI turned on by -z force-bti.*
#readelf: -n #readelf: -n
# Should warn about the missing input BTI NOTE but should # Should warn about the missing input BTI NOTE but should

View File

@ -2,9 +2,9 @@
#source: property-bti-pac2.s #source: property-bti-pac2.s
#source: bti-plt-1.s #source: bti-plt-1.s
#as: -mabi=lp64 --defsym __guard_property_bti__=1 --defsym __property_pac__=1 #as: -mabi=lp64 --defsym __guard_property_bti__=1 --defsym __property_pac__=1
#ld: -shared --force-bti #ld: -shared -z force-bti
#warning: .*property-bti-pac2.*: warning: BTI turned on by --force-bti.* #warning: .*property-bti-pac2.*: warning: BTI turned on by -z force-bti.*
#warning: .*bti-plt-1.*: warning: BTI turned on by --force-bti.* #warning: .*bti-plt-1.*: warning: BTI turned on by -z force-bti.*
#readelf: -n #readelf: -n
# Should warn about the missing input BTI NOTE but should # Should warn about the missing input BTI NOTE but should

View File

@ -1,6 +1,6 @@
#source: bti-plt-1.s #source: bti-plt-1.s
#as: -mabi=lp64 --defsym __guard_property_bti__=1 #as: -mabi=lp64 --defsym __guard_property_bti__=1
#ld: -shared --pac-plt -T bti-plt.ld #ld: -shared -z pac-plt -T bti-plt.ld
#objdump: -dr -j .plt #objdump: -dr -j .plt
[^:]*: *file format elf64-.*aarch64 [^:]*: *file format elf64-.*aarch64

View File

@ -1,5 +1,5 @@
#source: tls-desc-ie.s #source: tls-desc-ie.s
#ld: -shared --pac-plt -T bti-plt.ld #ld: -shared -z pac-plt -T bti-plt.ld
#objdump: -dr -j .plt #objdump: -dr -j .plt
#... #...
Disassembly of section .plt: Disassembly of section .plt: