[binutils-gdb] [LD, AArch64] Move ELF options behind -z

Sudakshina Das sudi@sourceware.org
Thu Jun 6 11:30:00 GMT 2019


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8bf6d176b0a442a8091d338d4af971591d19922c

commit 8bf6d176b0a442a8091d338d4af971591d19922c
Author: Sudakshina Das <sudi.das@arm.com>
Date:   Thu Jun 6 12:21:14 2019 +0100

    [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.

Diff:
---
 bfd/ChangeLog                           |  8 ++++++++
 bfd/bfd-in.h                            |  2 +-
 bfd/bfd-in2.h                           |  2 +-
 bfd/elfnn-aarch64.c                     |  4 ++--
 bfd/elfxx-aarch64.c                     |  2 +-
 ld/ChangeLog                            | 21 +++++++++++++++++++++
 ld/NEWS                                 |  4 ++--
 ld/emultempl/aarch64elf.em              | 28 +++++++++++++---------------
 ld/testsuite/ld-aarch64/bti-pac-plt-1.d |  2 +-
 ld/testsuite/ld-aarch64/bti-pac-plt-2.d |  2 +-
 ld/testsuite/ld-aarch64/bti-plt-1.d     |  4 ++--
 ld/testsuite/ld-aarch64/bti-plt-2.d     |  4 ++--
 ld/testsuite/ld-aarch64/bti-plt-3.d     |  4 ++--
 ld/testsuite/ld-aarch64/bti-plt-4.d     |  4 ++--
 ld/testsuite/ld-aarch64/bti-plt-6.d     |  4 ++--
 ld/testsuite/ld-aarch64/bti-plt-7.d     |  6 +++---
 ld/testsuite/ld-aarch64/bti-warn.d      |  6 +++---
 ld/testsuite/ld-aarch64/pac-plt-1.d     |  2 +-
 ld/testsuite/ld-aarch64/pac-plt-2.d     |  2 +-
 19 files changed, 69 insertions(+), 42 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index a6157a4..69624fe 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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>
 
 	* elfxx-mips.c (mips_elf_calculate_relocation) <R_MIPS_PCHI16>:
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index 890a79d..a5e95d1 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -1014,7 +1014,7 @@ typedef enum
 typedef enum
 {
   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;
 
 /* A structure to encompass all information coming from BTI or PAC
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 450c7b7..05e3219 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -1021,7 +1021,7 @@ typedef enum
 typedef enum
 {
   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;
 
 /* A structure to encompass all information coming from BTI or PAC
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 761e6b9..282418d 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -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))
 	   || !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."),
 			      abfd);
 	}
       if ((bprop && !(bprop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI))
 	   || !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."),
 			      bbfd);
 	}
diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c
index d16f2ec..1249008 100644
--- a/bfd/elfxx-aarch64.c
+++ b/bfd/elfxx-aarch64.c
@@ -721,7 +721,7 @@ _bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *info,
 				    4);
       if (gnu_prop & 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 "
 				  "section."), ebfd);
       prop->u.number |= gnu_prop;
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 70e7241..4d747af 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -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>
 
 	PR 24627
diff --git a/ld/NEWS b/ld/NEWS
index 3a41e9f..f66b35a 100644
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -18,11 +18,11 @@ Changes in 2.33:
 * Add support for GNU_PROPERTY_AARCH64_FEATURE_1_PAC in ELF GNU program
   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 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:
 
diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em
index b59623e..4c13f26 100644
--- a/ld/emultempl/aarch64elf.em
+++ b/ld/emultempl/aarch64elf.em
@@ -372,8 +372,6 @@ PARSE_AND_LIST_PROLOGUE='
 #define OPTION_FIX_ERRATUM_835769	313
 #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,8 +385,6 @@ PARSE_AND_LIST_LONGOPTS='
   { "fix-cortex-a53-835769", no_argument, NULL, OPTION_FIX_ERRATUM_835769},
   { "fix-cortex-a53-843419", optional_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='
@@ -419,10 +415,21 @@ PARSE_AND_LIST_OPTIONS='
                                                  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"));
   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"));
+  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, _("  -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='
     case '\'p\'':
       /* Only here for backwards compatibility.  */
@@ -464,15 +471,6 @@ PARSE_AND_LIST_ARGS_CASES='
       no_apply_dynamic_relocs = 1;
       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:
       {
 	const char *end;
diff --git a/ld/testsuite/ld-aarch64/bti-pac-plt-1.d b/ld/testsuite/ld-aarch64/bti-pac-plt-1.d
index 1ac2806..e1c6eb7 100644
--- a/ld/testsuite/ld-aarch64/bti-pac-plt-1.d
+++ b/ld/testsuite/ld-aarch64/bti-pac-plt-1.d
@@ -1,6 +1,6 @@
 #source: bti-plt-1.s
 #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
 
 [^:]*: *file format elf64-.*aarch64
diff --git a/ld/testsuite/ld-aarch64/bti-pac-plt-2.d b/ld/testsuite/ld-aarch64/bti-pac-plt-2.d
index e0ac1df1..0c67615 100644
--- a/ld/testsuite/ld-aarch64/bti-pac-plt-2.d
+++ b/ld/testsuite/ld-aarch64/bti-pac-plt-2.d
@@ -1,6 +1,6 @@
 #source: bti-plt-1.s
 #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
 
 [^:]*: *file format elf64-.*aarch64
diff --git a/ld/testsuite/ld-aarch64/bti-plt-1.d b/ld/testsuite/ld-aarch64/bti-plt-1.d
index 618a6a9..f8414a0 100644
--- a/ld/testsuite/ld-aarch64/bti-plt-1.d
+++ b/ld/testsuite/ld-aarch64/bti-plt-1.d
@@ -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
 #as: -mabi=lp64
-#ld: -shared --force-bti -T bti-plt.ld
+#ld: -shared -z force-bti -T bti-plt.ld
 #objdump: -dr -j .plt
 
 [^:]*: *file format elf64-.*aarch64
diff --git a/ld/testsuite/ld-aarch64/bti-plt-2.d b/ld/testsuite/ld-aarch64/bti-plt-2.d
index c26e47a..bddefe9 100644
--- a/ld/testsuite/ld-aarch64/bti-plt-2.d
+++ b/ld/testsuite/ld-aarch64/bti-plt-2.d
@@ -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-2.s
 #as: -mabi=lp64
-#ld: -shared --force-bti -T bti-plt.ld
+#ld: -shared -z force-bti -T bti-plt.ld
 #readelf: -n
 
 Displaying notes found in: .note.gnu.property
diff --git a/ld/testsuite/ld-aarch64/bti-plt-3.d b/ld/testsuite/ld-aarch64/bti-plt-3.d
index 08914de..82f08a9 100644
--- a/ld/testsuite/ld-aarch64/bti-plt-3.d
+++ b/ld/testsuite/ld-aarch64/bti-plt-3.d
@@ -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
 #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
 
 [^:]*: *file format elf64-.*aarch64
diff --git a/ld/testsuite/ld-aarch64/bti-plt-4.d b/ld/testsuite/ld-aarch64/bti-plt-4.d
index 90aeed2..936c24d 100644
--- a/ld/testsuite/ld-aarch64/bti-plt-4.d
+++ b/ld/testsuite/ld-aarch64/bti-plt-4.d
@@ -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
 #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
 
 Displaying notes found in: .note.gnu.property
diff --git a/ld/testsuite/ld-aarch64/bti-plt-6.d b/ld/testsuite/ld-aarch64/bti-plt-6.d
index 30d225d..27958c5 100644
--- a/ld/testsuite/ld-aarch64/bti-plt-6.d
+++ b/ld/testsuite/ld-aarch64/bti-plt-6.d
@@ -2,8 +2,8 @@
 #source: property-bti-pac2.s
 #source: property-bti-pac1.s
 #as: -mabi=lp64 -defsym __property_pac__=1
-#ld: -shared --force-bti
-#warning: .*property-bti-pac2.*: warning: BTI turned on by --force-bti.*$
+#ld: -shared -z force-bti
+#warning: .*property-bti-pac2.*: warning: BTI turned on by -z force-bti.*$
 #readelf: -n
 
 # Should warn about the missing input BTI NOTE but should
diff --git a/ld/testsuite/ld-aarch64/bti-plt-7.d b/ld/testsuite/ld-aarch64/bti-plt-7.d
index e8fa0d3..644290a 100644
--- a/ld/testsuite/ld-aarch64/bti-plt-7.d
+++ b/ld/testsuite/ld-aarch64/bti-plt-7.d
@@ -2,9 +2,9 @@
 #source: property-bti-pac2.s
 #source: plt_mapping_symbol.s
 #as: -mabi=lp64
-#ld: -shared --force-bti
-#warning: .*plt_mapping_symbol.*: warning: BTI turned on by --force-bti.*
-#warning: .*property-bti-pac2.*: warning: BTI turned on by --force-bti.*
+#ld: -shared -z force-bti
+#warning: .*plt_mapping_symbol.*: warning: BTI turned on by -z force-bti.*
+#warning: .*property-bti-pac2.*: warning: BTI turned on by -z force-bti.*
 #readelf: -n
 
 # Should warn about the missing input BTI NOTE but should
diff --git a/ld/testsuite/ld-aarch64/bti-warn.d b/ld/testsuite/ld-aarch64/bti-warn.d
index c2edccf..f22fd60 100644
--- a/ld/testsuite/ld-aarch64/bti-warn.d
+++ b/ld/testsuite/ld-aarch64/bti-warn.d
@@ -2,9 +2,9 @@
 #source: property-bti-pac2.s
 #source: bti-plt-1.s
 #as: -mabi=lp64 --defsym __guard_property_bti__=1 --defsym __property_pac__=1
-#ld: -shared --force-bti
-#warning: .*property-bti-pac2.*: warning: BTI turned on by --force-bti.*
-#warning: .*bti-plt-1.*: warning: BTI turned on by --force-bti.*
+#ld: -shared -z force-bti
+#warning: .*property-bti-pac2.*: warning: BTI turned on by -z force-bti.*
+#warning: .*bti-plt-1.*: warning: BTI turned on by -z force-bti.*
 #readelf: -n
 
 # Should warn about the missing input BTI NOTE but should
diff --git a/ld/testsuite/ld-aarch64/pac-plt-1.d b/ld/testsuite/ld-aarch64/pac-plt-1.d
index 9c4a676..06278ef 100644
--- a/ld/testsuite/ld-aarch64/pac-plt-1.d
+++ b/ld/testsuite/ld-aarch64/pac-plt-1.d
@@ -1,6 +1,6 @@
 #source: bti-plt-1.s
 #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
 
 [^:]*: *file format elf64-.*aarch64
diff --git a/ld/testsuite/ld-aarch64/pac-plt-2.d b/ld/testsuite/ld-aarch64/pac-plt-2.d
index 7ebc81d..b5cf43d 100644
--- a/ld/testsuite/ld-aarch64/pac-plt-2.d
+++ b/ld/testsuite/ld-aarch64/pac-plt-2.d
@@ -1,5 +1,5 @@
 #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
 #...
 Disassembly of section .plt:



More information about the Binutils-cvs mailing list