public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gold: Place .note.gnu.property section before other note sections
@ 2021-10-25 15:51 H.J. Lu
  2021-10-25 20:53 ` Fangrui Song
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: H.J. Lu @ 2021-10-25 15:51 UTC (permalink / raw)
  To: binutils; +Cc: Nick Clifton, Cary Coutant, Mark Wielaard

Place the .note.gnu.property section before all other note sections to
avoid being placed between other note sections with different alignments.

	PR gold/28494
	* layout.cc (Layout::create_note): Set order to ORDER_PROPERTY_NOTE
	for the .note.gnu.property section.
	* layout.h (Output_section_order): Add ORDER_PROPERTY_NOTE.
---
 gold/layout.cc | 3 ++-
 gold/layout.h  | 9 +++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/gold/layout.cc b/gold/layout.cc
index a27cb071c75..38e9bceec7e 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -3245,7 +3245,8 @@ Layout::create_note(const char* name, int note_type,
   if (allocate)
     {
       flags = elfcpp::SHF_ALLOC;
-      order = ORDER_RO_NOTE;
+      order = (note_type == elfcpp::NT_GNU_PROPERTY_TYPE_0
+	       ?  ORDER_PROPERTY_NOTE : ORDER_RO_NOTE);
     }
   Output_section* os = this->choose_output_section(NULL, section_name,
 						   elfcpp::SHT_NOTE,
diff --git a/gold/layout.h b/gold/layout.h
index 0b378003679..05c31714e47 100644
--- a/gold/layout.h
+++ b/gold/layout.h
@@ -399,8 +399,13 @@ enum Output_section_order
   // linker can pick it up quickly.
   ORDER_INTERP,
 
-  // Loadable read-only note sections come next so that the PT_NOTE
-  // segment is on the first page of the executable.
+  // The .note.gnu.property section comes next so that the PT_NOTE
+  // segment is on the first page of the executable and it won't be
+  // placed between other note sections with different alignments.
+  ORDER_PROPERTY_NOTE,
+
+  // Loadable read-only note sections come after the .note.gnu.property
+  // section.
   ORDER_RO_NOTE,
 
   // Put read-only sections used by the dynamic linker early in the
-- 
2.32.0


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

end of thread, other threads:[~2022-01-23 21:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25 15:51 [PATCH] gold: Place .note.gnu.property section before other note sections H.J. Lu
2021-10-25 20:53 ` Fangrui Song
     [not found] ` <MWHPR1201MB011014CB376FA8247963A2C6CB839@MWHPR1201MB0110.namprd12.prod.outlook.com>
2021-10-25 22:28   ` H.J. Lu
2021-10-26 23:08 ` Cary Coutant
2021-10-26 23:40   ` Cary Coutant
2021-10-26 23:42     ` H.J. Lu
2021-11-11 17:50       ` H.J. Lu
2022-01-23 21:05   ` Ian Lance Taylor

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