summaryrefslogtreecommitdiff
path: root/packages/binutils/2.37/0017-gold-place-note-gnu-property-section-before-other-note-sections.patch
blob: 0063e0da4e7e8a70b0a83fd948ddb959d30c9a22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
From bd711d6329ebb9328a99bd4be501932082248e44 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 25 Oct 2021 08:42:24 -0700
Subject: [PATCH] gold: Place .note.gnu.property section before other note
 sections

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.

(cherry picked from commit f85dcfc3af9cf7c2859241253f1d37b1133abea2)
---
 gold/layout.cc |    3 ++-
 gold/layout.h  |    9 +++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -3245,7 +3245,8 @@
   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,
--- a/gold/layout.h
+++ b/gold/layout.h
@@ -399,8 +399,13 @@
   // 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