[LD, AArch64] Move ELF options behind -z
authorSudakshina Das <sudi.das@arm.com>
Thu, 6 Jun 2019 11:21:14 +0000 (12:21 +0100)
committerSudakshina Das <sudi.das@arm.com>
Thu, 6 Jun 2019 11:21:14 +0000 (12:21 +0100)
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.

19 files changed:
bfd/ChangeLog
bfd/bfd-in.h
bfd/bfd-in2.h
bfd/elfnn-aarch64.c
bfd/elfxx-aarch64.c
ld/ChangeLog
ld/NEWS
ld/emultempl/aarch64elf.em
ld/testsuite/ld-aarch64/bti-pac-plt-1.d
ld/testsuite/ld-aarch64/bti-pac-plt-2.d
ld/testsuite/ld-aarch64/bti-plt-1.d
ld/testsuite/ld-aarch64/bti-plt-2.d
ld/testsuite/ld-aarch64/bti-plt-3.d
ld/testsuite/ld-aarch64/bti-plt-4.d
ld/testsuite/ld-aarch64/bti-plt-6.d
ld/testsuite/ld-aarch64/bti-plt-7.d
ld/testsuite/ld-aarch64/bti-warn.d
ld/testsuite/ld-aarch64/pac-plt-1.d
ld/testsuite/ld-aarch64/pac-plt-2.d

index a6157a4..69624fe 100644 (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>
 
        * elfxx-mips.c (mips_elf_calculate_relocation) <R_MIPS_PCHI16>:
index 890a79d..a5e95d1 100644 (file)
@@ -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 -force-bti.  */
 } aarch64_enable_bti_type;
 
 /* A structure to encompass all information coming from BTI or PAC
index 450c7b7..05e3219 100644 (file)
@@ -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 -force-bti.  */
 } aarch64_enable_bti_type;
 
 /* A structure to encompass all information coming from BTI or PAC
index 761e6b9..282418d 100644 (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))
           || !aprop)
        {
-         _bfd_error_handler (_("%pB: warning: BTI turned on by --force-bti when "
+         _bfd_error_handler (_("%pB: warning: BTI turned on by -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 -force-bti when "
                                "all inputs do not have BTI in NOTE section."),
                              bbfd);
        }
index d16f2ec..1249008 100644 (file)
@@ -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 -force-bti "
                                  "when all inputs do not have BTI in NOTE "
                                  "section."), ebfd);
       prop->u.number |= gnu_prop;
index 70e7241..4d747af 100644 (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>
 
        PR 24627
diff --git a/ld/NEWS b/ld/NEWS
index 3a41e9f..f66b35a 100644 (file)
--- 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 -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 -pac-plt for AArch64 to pick PAC enabled PLTs.
 
 Changes in 2.32:
 
index b59623e..4c13f26 100644 (file)
@@ -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, _("  -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_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;
index 1ac2806..e1c6eb7 100644 (file)
@@ -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
index e0ac1df..0c67615 100644 (file)
@@ -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
index 618a6a9..f8414a0 100644 (file)
@@ -1,7 +1,7 @@
-#name: Check --force-bti emits BTI PLT (shared)
+#name: Check -force-bti emits BTI PLT (shared)
 #source: bti-plt-1.s
 #as: -mabi=lp64
-#ld: -shared --force-bti -T bti-plt.ld
+#ld: -shared -force-bti -T bti-plt.ld
 #objdump: -dr -j .plt
 
 [^:]*: *file format elf64-.*aarch64
index c26e47a..bddefe9 100644 (file)
@@ -1,8 +1,8 @@
-#name: Check --force-bti emits BTI feature (shared)
+#name: Check -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 -force-bti -T bti-plt.ld
 #readelf: -n
 
 Displaying notes found in: .note.gnu.property
index 08914de..82f08a9 100644 (file)
@@ -1,7 +1,7 @@
-#name: Check --force-bti emits BTI PLT (exec)
+#name: Check -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: -force-bti -e _start -T bti-plt.ld -L./tmpdir -lbti-plt-so
 #objdump: -dr -j .plt
 
 [^:]*: *file format elf64-.*aarch64
index 90aeed2..936c24d 100644 (file)
@@ -1,7 +1,7 @@
-#name: Check --force-bti emits BTI feature (exec)
+#name: Check -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: -force-bti -e _start -T bti-plt.ld -L./tmpdir -lbti-plt-so
 #readelf: -n
 
 Displaying notes found in: .note.gnu.property
index 30d225d..27958c5 100644 (file)
@@ -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 -force-bti
+#warning: .*property-bti-pac2.*: warning: BTI turned on by -force-bti.*$
 #readelf: -n
 
 # Should warn about the missing input BTI NOTE but should
index e8fa0d3..644290a 100644 (file)
@@ -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 -force-bti
+#warning: .*plt_mapping_symbol.*: warning: BTI turned on by -force-bti.*
+#warning: .*property-bti-pac2.*: warning: BTI turned on by -force-bti.*
 #readelf: -n
 
 # Should warn about the missing input BTI NOTE but should
index c2edccf..f22fd60 100644 (file)
@@ -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 -force-bti
+#warning: .*property-bti-pac2.*: warning: BTI turned on by -force-bti.*
+#warning: .*bti-plt-1.*: warning: BTI turned on by -force-bti.*
 #readelf: -n
 
 # Should warn about the missing input BTI NOTE but should
index 9c4a676..06278ef 100644 (file)
@@ -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 -pac-plt -T bti-plt.ld
 #objdump: -dr -j .plt
 
 [^:]*: *file format elf64-.*aarch64
index 7ebc81d..b5cf43d 100644 (file)
@@ -1,5 +1,5 @@
 #source: tls-desc-ie.s
-#ld: -shared --pac-plt -T bti-plt.ld
+#ld: -shared -pac-plt -T bti-plt.ld
 #objdump: -dr -j .plt
 #...
 Disassembly of section .plt: