public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, BFD, AArch64, x86] Improve warning for --force-bti.
@ 2019-03-20 13:30 Sudakshina Das
  2019-03-21 15:14 ` Nick Clifton
  0 siblings, 1 reply; 9+ messages in thread
From: Sudakshina Das @ 2019-03-20 13:30 UTC (permalink / raw)
  To: binutils; +Cc: nd, nickc, Ramana Radhakrishnan, Richard Earnshaw

[-- Attachment #1: Type: text/plain, Size: 1706 bytes --]

Hi

The AArch64 linker option to turn on BTI (--force-bti) warns in case 
there are input objects which have a missing GNU NOTE section for BTI. 
This patch is trying to improve the warnings that come out.

In order to do so, I propose adding a new argument to 
elf_merge_gnu_properties and the backend function merge_gnu_properties. 
This new argument makes sure that we now pass both the objects along 
with the properties to which they belong to. The x86 backend function 
has also been updated to match this
change.

Builds and regression tested on aarch64-none-linux-gnu and 
x86_64-pc-linux-gnu.

Is this ok for trunk?

Sudi

*** bfd/ChangeLog ***

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

	* elf-bfd.h (struct elf_backend_data): Add argument to
	merge_gnu_properties.
	* elf-properties.c (elf_merge_gnu_properties): Add argument to
	itself and while calling bed->merge_gnu_properties.
	(elf_merge_gnu_property_list): Update the calls for
	elf_merge_gnu_properties.
	* elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update handling
	of --force-bti warning and add argument.
	* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Add
	warning.
	* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Add argument.
	* elfxx-x86.h (_bfd_x86_elf_merge_gnu_properties): Likewise in
	declaration.

*** ld/ChangeLog ***

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

	* testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
	* testsuite/ld-aarch64/bti-plt-1.s: Add .ifdef for PAC note section.
	* testsuite/ld-aarch64/bti-plt-6.d: Update warning.
	* testsuite/ld-aarch64/bti-plt-7.d: Likewise.
	* testsuite/ld-aarch64/bti-warn.d: New test.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: rb10814.patch --]
[-- Type: text/x-patch; name="rb10814.patch", Size: 9899 bytes --]

diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 56cddda6417b80ff6959505e8561389e243114c7..0d12f4533acec02d57cfe51cd3c8912dfb33fecd 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -1473,7 +1473,7 @@ struct elf_backend_data
 						  unsigned int);
 
   /* Merge GNU properties.  Return TRUE if property is updated.  */
-  bfd_boolean (*merge_gnu_properties) (struct bfd_link_info *, bfd *,
+  bfd_boolean (*merge_gnu_properties) (struct bfd_link_info *, bfd *, bfd *,
 				       elf_property *, elf_property *);
 
   /* Set up GNU properties.  */
diff --git a/bfd/elf-properties.c b/bfd/elf-properties.c
index 0c3f19ce56a36bb18d9afd2e140d735eeaf9c6a9..94ef2351cb632828c66127907137e7d523cb719d 100644
--- a/bfd/elf-properties.c
+++ b/bfd/elf-properties.c
@@ -198,7 +198,7 @@ next:
    with ABFD.  */
 
 static bfd_boolean
-elf_merge_gnu_properties (struct bfd_link_info *info, bfd *abfd,
+elf_merge_gnu_properties (struct bfd_link_info *info, bfd *abfd, bfd *bbfd,
 			  elf_property *aprop, elf_property *bprop)
 {
   const struct elf_backend_data *bed = get_elf_backend_data (abfd);
@@ -207,7 +207,7 @@ elf_merge_gnu_properties (struct bfd_link_info *info, bfd *abfd,
   if (bed->merge_gnu_properties != NULL
       && pr_type >= GNU_PROPERTY_LOPROC
       && pr_type < GNU_PROPERTY_LOUSER)
-    return bed->merge_gnu_properties (info, abfd, aprop, bprop);
+    return bed->merge_gnu_properties (info, abfd, bbfd, aprop, bprop);
 
   switch (pr_type)
     {
@@ -289,7 +289,7 @@ elf_merge_gnu_property_list (struct bfd_link_info *info, bfd *first_pbfd,
 					   TRUE);
 	/* Pass NULL to elf_merge_gnu_properties for the property which
 	   isn't on *LISTP.  */
-	elf_merge_gnu_properties (info, first_pbfd, &p->property, pr);
+	elf_merge_gnu_properties (info, first_pbfd, abfd, &p->property, pr);
 	if (p->property.pr_kind == property_remove)
 	  {
 	    if (info->has_map_file)
@@ -365,7 +365,7 @@ elf_merge_gnu_property_list (struct bfd_link_info *info, bfd *first_pbfd,
       else
 	number_p = FALSE;
 
-      if (elf_merge_gnu_properties (info, first_pbfd, NULL, &p->property))
+      if (elf_merge_gnu_properties (info, first_pbfd, abfd, NULL, &p->property))
 	{
 	  if (p->property.pr_type == GNU_PROPERTY_NO_COPY_ON_PROTECTED)
 	    elf_has_no_copy_on_protected (first_pbfd) = TRUE;
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 50541f05a8babac3178e8c5d3dfac5c19e075ff9..57a723d547734b4a4b5074fb7c90811e9bd56184 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -9968,7 +9968,7 @@ elfNN_aarch64_link_setup_gnu_properties (struct bfd_link_info *info)
    for the effect of GNU properties of the output_bfd.  */
 static bfd_boolean
 elfNN_aarch64_merge_gnu_properties (struct bfd_link_info *info,
-				       bfd *abfd,
+				       bfd *abfd, bfd *bbfd,
 				       elf_property *aprop,
 				       elf_property *bprop)
 {
@@ -9977,17 +9977,26 @@ elfNN_aarch64_merge_gnu_properties (struct bfd_link_info *info,
 
   /* If output has been marked with BTI using command line argument, give out
      warning if necessary.  */
-  if ((prop & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)
+  /* Properties are merged per type, hence only check for warnings when merging
+     GNU_PROPERTY_AARCH64_FEATURE_1_AND.  */
+  if (((aprop && aprop->pr_type == GNU_PROPERTY_AARCH64_FEATURE_1_AND)
+	|| (bprop && bprop->pr_type == GNU_PROPERTY_AARCH64_FEATURE_1_AND))
+      && (prop & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)
       && (!elf_aarch64_tdata (info->output_bfd)->no_bti_warn))
     {
       if ((aprop && !(aprop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI))
-	  || (bprop && !(bprop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI))
-	  /* If either property is NULL, it means its bfd did not have any
-	     property.  */
-	  || !aprop || !bprop)
+	   || !aprop)
 	{
-	  _bfd_error_handler (_("warning: BTI turned on by --force-bti when "
-				"all inputs do not have BTI in NOTE section."));
+	  _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 "
+				"all inputs do not have BTI in NOTE section."),
+			      bbfd);
 	}
     }
 
diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c
index aa1c67ec4bfc46722540774dedb810b225b64cb6..1d26d848019a59625e221e4966d7c38631be4998 100644
--- a/bfd/elfxx-aarch64.c
+++ b/bfd/elfxx-aarch64.c
@@ -719,6 +719,11 @@ _bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *info,
       prop = _bfd_elf_get_property (ebfd,
 				    GNU_PROPERTY_AARCH64_FEATURE_1_AND,
 				    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 "
+				  "when all inputs do not have BTI in NOTE "
+				  "section."), ebfd);
       prop->u.number |= gnu_prop;
       prop->pr_kind = property_number;
 
diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h
index 28d540b83b3fb9dbb6a6980b5c67cdd7998b4e00..4df2173a5842f92b691e4680156bad70e2043507 100644
--- a/bfd/elfxx-x86.h
+++ b/bfd/elfxx-x86.h
@@ -691,7 +691,7 @@ extern enum elf_property_kind _bfd_x86_elf_parse_gnu_properties
   (bfd *, unsigned int, bfd_byte *, unsigned int);
 
 extern bfd_boolean _bfd_x86_elf_merge_gnu_properties
-  (struct bfd_link_info *, bfd *, elf_property *, elf_property *);
+  (struct bfd_link_info *, bfd *, bfd *, elf_property *, elf_property *);
 
 extern void _bfd_x86_elf_link_fixup_gnu_properties
   (struct bfd_link_info *, elf_property_list **);
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index 584a75f996054f30a93b0c3f5449ae39f36bbfdf..5703b5f389a0fafd4a086c22c357d060a6c042a1 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -2401,6 +2401,7 @@ _bfd_x86_elf_parse_gnu_properties (bfd *abfd, unsigned int type,
 bfd_boolean
 _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info,
 				   bfd *abfd ATTRIBUTE_UNUSED,
+				   bfd *bbfd ATTRIBUTE_UNUSED,
 				   elf_property *aprop,
 				   elf_property *bprop)
 {
diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp
index 12c2d97d53770e886bb913e19aef996a64fc1805..ba3ce36191f49b2ce25880b7a61408b6e8875884 100644
--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp
+++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp
@@ -407,3 +407,5 @@ 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"
+
+run_dump_test "bti-warn"
diff --git a/ld/testsuite/ld-aarch64/bti-plt-1.s b/ld/testsuite/ld-aarch64/bti-plt-1.s
index b798ca4e8ceeb192f6cf67a21be2eb5337a70fee..8bb39c44f8de4d2f7a24172e730b36742cb9b926 100644
--- a/ld/testsuite/ld-aarch64/bti-plt-1.s
+++ b/ld/testsuite/ld-aarch64/bti-plt-1.s
@@ -21,3 +21,20 @@ _start:
 	.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
diff --git a/ld/testsuite/ld-aarch64/bti-plt-6.d b/ld/testsuite/ld-aarch64/bti-plt-6.d
index c7d5169e810e635ff787503e96e27c1fe4a12731..30d225d4dec80ab454da15787023a1096c73606b 100644
--- a/ld/testsuite/ld-aarch64/bti-plt-6.d
+++ b/ld/testsuite/ld-aarch64/bti-plt-6.d
@@ -1,9 +1,9 @@
 #name: Warn with one missing GNU NOTE BTI input
-#source: property-bti-pac1.s
 #source: property-bti-pac2.s
+#source: property-bti-pac1.s
 #as: -mabi=lp64 -defsym __property_pac__=1
 #ld: -shared --force-bti
-#warning: .*: 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
diff --git a/ld/testsuite/ld-aarch64/bti-plt-7.d b/ld/testsuite/ld-aarch64/bti-plt-7.d
index 625f2847b0c9564ef7af7a2b95ea3e368ddf8b08..e8fa0d3a09163bae08d87620c718b5c765462b32 100644
--- a/ld/testsuite/ld-aarch64/bti-plt-7.d
+++ b/ld/testsuite/ld-aarch64/bti-plt-7.d
@@ -1,9 +1,10 @@
 #name: Warn when neither inputs has GNU NOTE BTI
-#source: property-bti-pac1.s
+#source: property-bti-pac2.s
 #source: plt_mapping_symbol.s
 #as: -mabi=lp64
 #ld: -shared --force-bti
-#warning: .*: warning: BTI turned on by --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
diff --git a/ld/testsuite/ld-aarch64/bti-warn.d b/ld/testsuite/ld-aarch64/bti-warn.d
new file mode 100644
index 0000000000000000000000000000000000000000..c2edccf15f11ee06c09143b763837dbb950ba946
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/bti-warn.d
@@ -0,0 +1,16 @@
+#name: Warn when both have GNU prop but neither BTI
+#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.*
+#readelf: -n
+
+# Should warn about the missing input BTI NOTE but should
+# still mark output as BTI
+
+Displaying notes found in: .note.gnu.property
+  Owner                 Data size	Description
+  GNU                  0x00000010	NT_GNU_PROPERTY_TYPE_0
+      Properties: AArch64 feature: BTI, PAC

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH, BFD, AArch64, x86] Improve warning for --force-bti.
  2019-03-20 13:30 [PATCH, BFD, AArch64, x86] Improve warning for --force-bti Sudakshina Das
@ 2019-03-21 15:14 ` Nick Clifton
  2019-03-21 16:24   ` Sudakshina Das
  0 siblings, 1 reply; 9+ messages in thread
From: Nick Clifton @ 2019-03-21 15:14 UTC (permalink / raw)
  To: Sudakshina Das, binutils; +Cc: nd, Ramana Radhakrishnan, Richard Earnshaw

Hi Sudi,

> *** bfd/ChangeLog ***
> 
> 2019-xx-xx  Sudakshina Das  <sudi.das@arm.com>
> 
> 	* elf-bfd.h (struct elf_backend_data): Add argument to
> 	merge_gnu_properties.
> 	* elf-properties.c (elf_merge_gnu_properties): Add argument to
> 	itself and while calling bed->merge_gnu_properties.
> 	(elf_merge_gnu_property_list): Update the calls for
> 	elf_merge_gnu_properties.
> 	* elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update handling
> 	of --force-bti warning and add argument.
> 	* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Add
> 	warning.
> 	* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Add argument.
> 	* elfxx-x86.h (_bfd_x86_elf_merge_gnu_properties): Likewise in
> 	declaration.
> 
> *** ld/ChangeLog ***
> 
> 2019-xx-xx  Sudakshina Das  <sudi.das@arm.com>
> 
> 	* testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
> 	* testsuite/ld-aarch64/bti-plt-1.s: Add .ifdef for PAC note section.
> 	* testsuite/ld-aarch64/bti-plt-6.d: Update warning.
> 	* testsuite/ld-aarch64/bti-plt-7.d: Likewise.
> 	* testsuite/ld-aarch64/bti-warn.d: New test.

Approved - please apply.

Cheers
  Nick


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH, BFD, AArch64, x86] Improve warning for --force-bti.
  2019-03-21 15:14 ` Nick Clifton
@ 2019-03-21 16:24   ` Sudakshina Das
  2019-03-21 22:57     ` H.J. Lu
  2019-04-01 19:27     ` H.J. Lu
  0 siblings, 2 replies; 9+ messages in thread
From: Sudakshina Das @ 2019-03-21 16:24 UTC (permalink / raw)
  To: nickc, binutils; +Cc: nd, Ramana Radhakrishnan, Richard Earnshaw

Hi Nick

On 21/03/2019 15:14, Nick Clifton wrote:
> Hi Sudi,
> 
>> *** bfd/ChangeLog ***
>>
>> 2019-xx-xx  Sudakshina Das  <sudi.das@arm.com>
>>
>> 	* elf-bfd.h (struct elf_backend_data): Add argument to
>> 	merge_gnu_properties.
>> 	* elf-properties.c (elf_merge_gnu_properties): Add argument to
>> 	itself and while calling bed->merge_gnu_properties.
>> 	(elf_merge_gnu_property_list): Update the calls for
>> 	elf_merge_gnu_properties.
>> 	* elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update handling
>> 	of --force-bti warning and add argument.
>> 	* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Add
>> 	warning.
>> 	* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Add argument.
>> 	* elfxx-x86.h (_bfd_x86_elf_merge_gnu_properties): Likewise in
>> 	declaration.
>>
>> *** ld/ChangeLog ***
>>
>> 2019-xx-xx  Sudakshina Das  <sudi.das@arm.com>
>>
>> 	* testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
>> 	* testsuite/ld-aarch64/bti-plt-1.s: Add .ifdef for PAC note section.
>> 	* testsuite/ld-aarch64/bti-plt-6.d: Update warning.
>> 	* testsuite/ld-aarch64/bti-plt-7.d: Likewise.
>> 	* testsuite/ld-aarch64/bti-warn.d: New test.
> 
> Approved - please apply.

Thanks for the approval. Committed as 
4e5391148d51c58785aad637f1a92d47b91b3ae6

Sudi

> 
> Cheers
>    Nick
> 
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH, BFD, AArch64, x86] Improve warning for --force-bti.
  2019-03-21 16:24   ` Sudakshina Das
@ 2019-03-21 22:57     ` H.J. Lu
  2019-04-01 19:27     ` H.J. Lu
  1 sibling, 0 replies; 9+ messages in thread
From: H.J. Lu @ 2019-03-21 22:57 UTC (permalink / raw)
  To: Sudakshina Das
  Cc: Nick Clifton, Binutils, nd, Ramana Radhakrishnan, Richard Earnshaw

Isn't this command line option ELF only? Why not use "-z"?

On Fri, Mar 22, 2019, 12:25 AM Sudakshina Das <Sudi.Das@arm.com> wrote:

> Hi Nick
>
> On 21/03/2019 15:14, Nick Clifton wrote:
> > Hi Sudi,
> >
> >> *** bfd/ChangeLog ***
> >>
> >> 2019-xx-xx  Sudakshina Das  <sudi.das@arm.com>
> >>
> >>      * elf-bfd.h (struct elf_backend_data): Add argument to
> >>      merge_gnu_properties.
> >>      * elf-properties.c (elf_merge_gnu_properties): Add argument to
> >>      itself and while calling bed->merge_gnu_properties.
> >>      (elf_merge_gnu_property_list): Update the calls for
> >>      elf_merge_gnu_properties.
> >>      * elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update
> handling
> >>      of --force-bti warning and add argument.
> >>      * elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Add
> >>      warning.
> >>      * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Add argument.
> >>      * elfxx-x86.h (_bfd_x86_elf_merge_gnu_properties): Likewise in
> >>      declaration.
> >>
> >> *** ld/ChangeLog ***
> >>
> >> 2019-xx-xx  Sudakshina Das  <sudi.das@arm.com>
> >>
> >>      * testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
> >>      * testsuite/ld-aarch64/bti-plt-1.s: Add .ifdef for PAC note
> section.
> >>      * testsuite/ld-aarch64/bti-plt-6.d: Update warning.
> >>      * testsuite/ld-aarch64/bti-plt-7.d: Likewise.
> >>      * testsuite/ld-aarch64/bti-warn.d: New test.
> >
> > Approved - please apply.
>
> Thanks for the approval. Committed as
> 4e5391148d51c58785aad637f1a92d47b91b3ae6
>
> Sudi
>
> >
> > Cheers
> >    Nick
> >
> >
>
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH, BFD, AArch64, x86] Improve warning for --force-bti.
  2019-03-21 16:24   ` Sudakshina Das
  2019-03-21 22:57     ` H.J. Lu
@ 2019-04-01 19:27     ` H.J. Lu
  2019-04-02  9:05       ` Sudakshina Das
  1 sibling, 1 reply; 9+ messages in thread
From: H.J. Lu @ 2019-04-01 19:27 UTC (permalink / raw)
  To: Sudakshina Das
  Cc: nickc, binutils, nd, Ramana Radhakrishnan, Richard Earnshaw

On Thu, Mar 21, 2019 at 9:25 AM Sudakshina Das <Sudi.Das@arm.com> wrote:
>
> Hi Nick
>
> On 21/03/2019 15:14, Nick Clifton wrote:
> > Hi Sudi,
> >
> >> *** bfd/ChangeLog ***
> >>
> >> 2019-xx-xx  Sudakshina Das  <sudi.das@arm.com>
> >>
> >>      * elf-bfd.h (struct elf_backend_data): Add argument to
> >>      merge_gnu_properties.
> >>      * elf-properties.c (elf_merge_gnu_properties): Add argument to
> >>      itself and while calling bed->merge_gnu_properties.
> >>      (elf_merge_gnu_property_list): Update the calls for
> >>      elf_merge_gnu_properties.
> >>      * elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update handling
> >>      of --force-bti warning and add argument.
> >>      * elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Add
> >>      warning.
> >>      * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Add argument.
> >>      * elfxx-x86.h (_bfd_x86_elf_merge_gnu_properties): Likewise in
> >>      declaration.
> >>
> >> *** ld/ChangeLog ***
> >>
> >> 2019-xx-xx  Sudakshina Das  <sudi.das@arm.com>
> >>
> >>      * testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
> >>      * testsuite/ld-aarch64/bti-plt-1.s: Add .ifdef for PAC note section.
> >>      * testsuite/ld-aarch64/bti-plt-6.d: Update warning.
> >>      * testsuite/ld-aarch64/bti-plt-7.d: Likewise.
> >>      * testsuite/ld-aarch64/bti-warn.d: New test.
> >
> > Approved - please apply.
>
> Thanks for the approval. Committed as
> 4e5391148d51c58785aad637f1a92d47b91b3ae6
>
> Sudi
>

Isn't  --force-bti for ELF only? Shouldn't it use "-z force-bti"?

-- 
H.J.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH, BFD, AArch64, x86] Improve warning for --force-bti.
  2019-04-01 19:27     ` H.J. Lu
@ 2019-04-02  9:05       ` Sudakshina Das
  2019-04-02 12:32         ` H.J. Lu
  0 siblings, 1 reply; 9+ messages in thread
From: Sudakshina Das @ 2019-04-02  9:05 UTC (permalink / raw)
  To: H.J. Lu; +Cc: nickc, binutils, nd, Ramana Radhakrishnan, Richard Earnshaw

Hi HJ

On 01/04/2019 20:26, H.J. Lu wrote:
> On Thu, Mar 21, 2019 at 9:25 AM Sudakshina Das <Sudi.Das@arm.com> wrote:
>>
>> Hi Nick
>>
>> On 21/03/2019 15:14, Nick Clifton wrote:
>>> Hi Sudi,
>>>
>>>> *** bfd/ChangeLog ***
>>>>
>>>> 2019-xx-xx  Sudakshina Das  <sudi.das@arm.com>
>>>>
>>>>       * elf-bfd.h (struct elf_backend_data): Add argument to
>>>>       merge_gnu_properties.
>>>>       * elf-properties.c (elf_merge_gnu_properties): Add argument to
>>>>       itself and while calling bed->merge_gnu_properties.
>>>>       (elf_merge_gnu_property_list): Update the calls for
>>>>       elf_merge_gnu_properties.
>>>>       * elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update handling
>>>>       of --force-bti warning and add argument.
>>>>       * elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Add
>>>>       warning.
>>>>       * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Add argument.
>>>>       * elfxx-x86.h (_bfd_x86_elf_merge_gnu_properties): Likewise in
>>>>       declaration.
>>>>
>>>> *** ld/ChangeLog ***
>>>>
>>>> 2019-xx-xx  Sudakshina Das  <sudi.das@arm.com>
>>>>
>>>>       * testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
>>>>       * testsuite/ld-aarch64/bti-plt-1.s: Add .ifdef for PAC note section.
>>>>       * testsuite/ld-aarch64/bti-plt-6.d: Update warning.
>>>>       * testsuite/ld-aarch64/bti-plt-7.d: Likewise.
>>>>       * testsuite/ld-aarch64/bti-warn.d: New test.
>>>
>>> Approved - please apply.
>>
>> Thanks for the approval. Committed as
>> 4e5391148d51c58785aad637f1a92d47b91b3ae6
>>
>> Sudi
>>
> 
> Isn't  --force-bti for ELF only? Shouldn't it use "-z force-bti"?

Sorry I was not aware of any elf specific meaning given to -z. Is this a 
convention? I can not seem to find any particular documentation for it.

Thanks
Sudi
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH, BFD, AArch64, x86] Improve warning for --force-bti.
  2019-04-02  9:05       ` Sudakshina Das
@ 2019-04-02 12:32         ` H.J. Lu
  2019-04-03 14:36           ` Sudakshina Das
  0 siblings, 1 reply; 9+ messages in thread
From: H.J. Lu @ 2019-04-02 12:32 UTC (permalink / raw)
  To: Sudakshina Das
  Cc: nickc, binutils, nd, Ramana Radhakrishnan, Richard Earnshaw

On Tue, Apr 2, 2019 at 2:05 AM Sudakshina Das <Sudi.Das@arm.com> wrote:
>
> Hi HJ
>
> On 01/04/2019 20:26, H.J. Lu wrote:
> > On Thu, Mar 21, 2019 at 9:25 AM Sudakshina Das <Sudi.Das@arm.com> wrote:
> >>
> >> Hi Nick
> >>
> >> On 21/03/2019 15:14, Nick Clifton wrote:
> >>> Hi Sudi,
> >>>
> >>>> *** bfd/ChangeLog ***
> >>>>
> >>>> 2019-xx-xx  Sudakshina Das  <sudi.das@arm.com>
> >>>>
> >>>>       * elf-bfd.h (struct elf_backend_data): Add argument to
> >>>>       merge_gnu_properties.
> >>>>       * elf-properties.c (elf_merge_gnu_properties): Add argument to
> >>>>       itself and while calling bed->merge_gnu_properties.
> >>>>       (elf_merge_gnu_property_list): Update the calls for
> >>>>       elf_merge_gnu_properties.
> >>>>       * elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update handling
> >>>>       of --force-bti warning and add argument.
> >>>>       * elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Add
> >>>>       warning.
> >>>>       * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Add argument.
> >>>>       * elfxx-x86.h (_bfd_x86_elf_merge_gnu_properties): Likewise in
> >>>>       declaration.
> >>>>
> >>>> *** ld/ChangeLog ***
> >>>>
> >>>> 2019-xx-xx  Sudakshina Das  <sudi.das@arm.com>
> >>>>
> >>>>       * testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
> >>>>       * testsuite/ld-aarch64/bti-plt-1.s: Add .ifdef for PAC note section.
> >>>>       * testsuite/ld-aarch64/bti-plt-6.d: Update warning.
> >>>>       * testsuite/ld-aarch64/bti-plt-7.d: Likewise.
> >>>>       * testsuite/ld-aarch64/bti-warn.d: New test.
> >>>
> >>> Approved - please apply.
> >>
> >> Thanks for the approval. Committed as
> >> 4e5391148d51c58785aad637f1a92d47b91b3ae6
> >>
> >> Sudi
> >>
> >
> > Isn't  --force-bti for ELF only? Shouldn't it use "-z force-bti"?
>
> Sorry I was not aware of any elf specific meaning given to -z. Is this a
> convention? I can not seem to find any particular documentation for it.
>

This is the convention.  See how PARSE_AND_LIST_ARGS_CASE_Z
is used.  You can also define PARSE_AND_LIST_OPTIONS to update
"ld --help".

-- 
H.J.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH, BFD, AArch64, x86] Improve warning for --force-bti.
  2019-04-02 12:32         ` H.J. Lu
@ 2019-04-03 14:36           ` Sudakshina Das
  2019-04-12 14:42             ` Sudakshina Das
  0 siblings, 1 reply; 9+ messages in thread
From: Sudakshina Das @ 2019-04-03 14:36 UTC (permalink / raw)
  To: H.J. Lu, nickc, Ramana Radhakrishnan, Richard Earnshaw; +Cc: binutils, nd

Hi HJ

On 02/04/2019 13:31, H.J. Lu wrote:
> On Tue, Apr 2, 2019 at 2:05 AM Sudakshina Das <Sudi.Das@arm.com> wrote:
>>
>> Hi HJ
>>
>> On 01/04/2019 20:26, H.J. Lu wrote:
>>> On Thu, Mar 21, 2019 at 9:25 AM Sudakshina Das <Sudi.Das@arm.com> wrote:
>>>>
>>>> Hi Nick
>>>>
>>>> On 21/03/2019 15:14, Nick Clifton wrote:
>>>>> Hi Sudi,
>>>>>
>>>>>> *** bfd/ChangeLog ***
>>>>>>
>>>>>> 2019-xx-xx  Sudakshina Das  <sudi.das@arm.com>
>>>>>>
>>>>>>        * elf-bfd.h (struct elf_backend_data): Add argument to
>>>>>>        merge_gnu_properties.
>>>>>>        * elf-properties.c (elf_merge_gnu_properties): Add argument to
>>>>>>        itself and while calling bed->merge_gnu_properties.
>>>>>>        (elf_merge_gnu_property_list): Update the calls for
>>>>>>        elf_merge_gnu_properties.
>>>>>>        * elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update handling
>>>>>>        of --force-bti warning and add argument.
>>>>>>        * elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Add
>>>>>>        warning.
>>>>>>        * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Add argument.
>>>>>>        * elfxx-x86.h (_bfd_x86_elf_merge_gnu_properties): Likewise in
>>>>>>        declaration.
>>>>>>
>>>>>> *** ld/ChangeLog ***
>>>>>>
>>>>>> 2019-xx-xx  Sudakshina Das  <sudi.das@arm.com>
>>>>>>
>>>>>>        * testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
>>>>>>        * testsuite/ld-aarch64/bti-plt-1.s: Add .ifdef for PAC note section.
>>>>>>        * testsuite/ld-aarch64/bti-plt-6.d: Update warning.
>>>>>>        * testsuite/ld-aarch64/bti-plt-7.d: Likewise.
>>>>>>        * testsuite/ld-aarch64/bti-warn.d: New test.
>>>>>
>>>>> Approved - please apply.
>>>>
>>>> Thanks for the approval. Committed as
>>>> 4e5391148d51c58785aad637f1a92d47b91b3ae6
>>>>
>>>> Sudi
>>>>
>>>
>>> Isn't  --force-bti for ELF only? Shouldn't it use "-z force-bti"?
>>
>> Sorry I was not aware of any elf specific meaning given to -z. Is this a
>> convention? I can not seem to find any particular documentation for it.
>>
> 
> This is the convention.  See how PARSE_AND_LIST_ARGS_CASE_Z
> is used.  You can also define PARSE_AND_LIST_OPTIONS to update
> "ld --help".

The current options that are defined for bti and pac are defined in 
ld/emultempl/aarch64elf.em which "is sourced from elf32.em, and defines 
extra aarch64-elf specific routines". They do appear 
PARSE_AND_LIST_OPTIONS and hence appear in ld --help.

Example

aarch64elf:
   --no-enum-size-warning      Don't warn about objects with incompatible
                                 enum sizes
   --no-wchar-size-warning     Don't warn about objects with incompatible
                                 wchar_t sizes
   --pic-veneer                Always generate PIC interworking veneers
   --stub-group-size=N         Maximum size of a group of input sections 
that
                                 can be handled by one stub section.  A 
negative
                                 value locates all stubs after their 
branches
                                 (with a group size of -N), while a positive
                                 value allows two groups of input 
sections, one
                                 before, and one after each stub section.
                                 Values of +/-1 indicate the linker should
                                 choose suitable defaults.
   --fix-cortex-a53-835769      Fix erratum 835769
   --fix-cortex-a53-843419      Fix erratum 843419
   --no-apply-dynamic-relocs    Do not apply link-time values for 
dynamic relocations
   --force-bti                  Turn on Branch Target Identification 
mechanism and generate PLTs with BTI. Generate warnings for missing BTI 
on inputs
   --pac-plt                    Protect PLTs with Pointer Authentication.

 From what I can see in the Arm or AArch64 backend, none of the the 
target specific options are defined using the -z option. Though I have 
to admit I don not know if those options are all generic to the target 
rather than being ELF only.

I would like to gather opinions of other port maintainers before I move 
these to -z.

Thanks
Sudi
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH, BFD, AArch64, x86] Improve warning for --force-bti.
  2019-04-03 14:36           ` Sudakshina Das
@ 2019-04-12 14:42             ` Sudakshina Das
  0 siblings, 0 replies; 9+ messages in thread
From: Sudakshina Das @ 2019-04-12 14:42 UTC (permalink / raw)
  To: H.J. Lu, nickc, Ramana Radhakrishnan, Richard Earnshaw; +Cc: binutils, nd

Hi

On 03/04/2019 15:36, Sudakshina Das wrote:
> Hi HJ
> 
> On 02/04/2019 13:31, H.J. Lu wrote:
>> On Tue, Apr 2, 2019 at 2:05 AM Sudakshina Das <Sudi.Das@arm.com> wrote:
>>>
>>> Hi HJ
>>>
>>> On 01/04/2019 20:26, H.J. Lu wrote:
>>>> On Thu, Mar 21, 2019 at 9:25 AM Sudakshina Das <Sudi.Das@arm.com> 
>>>> wrote:
>>>>>
>>>>> Hi Nick
>>>>>
>>>>> On 21/03/2019 15:14, Nick Clifton wrote:
>>>>>> Hi Sudi,
>>>>>>
>>>>>>> *** bfd/ChangeLog ***
>>>>>>>
>>>>>>> 2019-xx-xx  Sudakshina Das  <sudi.das@arm.com>
>>>>>>>
>>>>>>>        * elf-bfd.h (struct elf_backend_data): Add argument to
>>>>>>>        merge_gnu_properties.
>>>>>>>        * elf-properties.c (elf_merge_gnu_properties): Add 
>>>>>>> argument to
>>>>>>>        itself and while calling bed->merge_gnu_properties.
>>>>>>>        (elf_merge_gnu_property_list): Update the calls for
>>>>>>>        elf_merge_gnu_properties.
>>>>>>>        * elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): 
>>>>>>> Update handling
>>>>>>>        of --force-bti warning and add argument.
>>>>>>>        * elfxx-aarch64.c 
>>>>>>> (_bfd_aarch64_elf_link_setup_gnu_properties): Add
>>>>>>>        warning.
>>>>>>>        * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Add 
>>>>>>> argument.
>>>>>>>        * elfxx-x86.h (_bfd_x86_elf_merge_gnu_properties): 
>>>>>>> Likewise in
>>>>>>>        declaration.
>>>>>>>
>>>>>>> *** ld/ChangeLog ***
>>>>>>>
>>>>>>> 2019-xx-xx  Sudakshina Das  <sudi.das@arm.com>
>>>>>>>
>>>>>>>        * testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
>>>>>>>        * testsuite/ld-aarch64/bti-plt-1.s: Add .ifdef for PAC 
>>>>>>> note section.
>>>>>>>        * testsuite/ld-aarch64/bti-plt-6.d: Update warning.
>>>>>>>        * testsuite/ld-aarch64/bti-plt-7.d: Likewise.
>>>>>>>        * testsuite/ld-aarch64/bti-warn.d: New test.
>>>>>>
>>>>>> Approved - please apply.
>>>>>
>>>>> Thanks for the approval. Committed as
>>>>> 4e5391148d51c58785aad637f1a92d47b91b3ae6
>>>>>
>>>>> Sudi
>>>>>
>>>>
>>>> Isn't  --force-bti for ELF only? Shouldn't it use "-z force-bti"?
>>>
>>> Sorry I was not aware of any elf specific meaning given to -z. Is this a
>>> convention? I can not seem to find any particular documentation for it.
>>>
>>
>> This is the convention.  See how PARSE_AND_LIST_ARGS_CASE_Z
>> is used.  You can also define PARSE_AND_LIST_OPTIONS to update
>> "ld --help".
> 
> The current options that are defined for bti and pac are defined in 
> ld/emultempl/aarch64elf.em which "is sourced from elf32.em, and defines 
> extra aarch64-elf specific routines". They do appear 
> PARSE_AND_LIST_OPTIONS and hence appear in ld --help.
> 
> Example
> 
> aarch64elf:
>    --no-enum-size-warning      Don't warn about objects with incompatible
>                                  enum sizes
>    --no-wchar-size-warning     Don't warn about objects with incompatible
>                                  wchar_t sizes
>    --pic-veneer                Always generate PIC interworking veneers
>    --stub-group-size=N         Maximum size of a group of input sections 
> that
>                                  can be handled by one stub section.  A 
> negative
>                                  value locates all stubs after their 
> branches
>                                  (with a group size of -N), while a 
> positive
>                                  value allows two groups of input 
> sections, one
>                                  before, and one after each stub section.
>                                  Values of +/-1 indicate the linker should
>                                  choose suitable defaults.
>    --fix-cortex-a53-835769      Fix erratum 835769
>    --fix-cortex-a53-843419      Fix erratum 843419
>    --no-apply-dynamic-relocs    Do not apply link-time values for 
> dynamic relocations
>    --force-bti                  Turn on Branch Target Identification 
> mechanism and generate PLTs with BTI. Generate warnings for missing BTI 
> on inputs
>    --pac-plt                    Protect PLTs with Pointer Authentication.
> 
>  From what I can see in the Arm or AArch64 backend, none of the the 
> target specific options are defined using the -z option. Though I have 
> to admit I don not know if those options are all generic to the target 
> rather than being ELF only.
> 
> I would like to gather opinions of other port maintainers before I move 
> these to -z.
> 
As discussed I will post a patch to move the command line option behind 
-z soon :)

Thanks
Sudi

> Thanks
> Sudi
>>
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-04-12 14:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-20 13:30 [PATCH, BFD, AArch64, x86] Improve warning for --force-bti Sudakshina Das
2019-03-21 15:14 ` Nick Clifton
2019-03-21 16:24   ` Sudakshina Das
2019-03-21 22:57     ` H.J. Lu
2019-04-01 19:27     ` H.J. Lu
2019-04-02  9:05       ` Sudakshina Das
2019-04-02 12:32         ` H.J. Lu
2019-04-03 14:36           ` Sudakshina Das
2019-04-12 14:42             ` Sudakshina Das

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).