2020-01-24 21:00:18

by H.J. Lu

[permalink] [raw]
Subject: [PATCH 0/2] x86: Discard .note.gnu.property sections

With the command-line option, -mx86-used-note=yes, the x86 assembler
in binutils 2.32 and above generates a program property note in a note
section, .note.gnu.property, to encode used x86 ISAs and features. But
x86 kernel vmlinux and vDSO linker scripts only contain a signle NOTE
segment which may not be incompatible with note.gnu.property sections.
Since note.gnu.property section from kernel are unused, they should be
discarded by adding

/DISCARD/ : {
*(.note.gnu.property)
}

before .notes sections.

H.J. Lu (2):
x86: Discard .note.gnu.property sections in vDSO
x86: Discard .note.gnu.property sections in vmlinux

arch/x86/entry/vdso/vdso-layout.lds.S | 4 ++++
arch/x86/kernel/vmlinux.lds.S | 11 +++++++++++
2 files changed, 15 insertions(+)

--
2.24.1


2020-01-24 21:00:21

by H.J. Lu

[permalink] [raw]
Subject: [PATCH 1/2] x86: Discard .note.gnu.property sections in vDSO

With the command-line option, -mx86-used-note=yes, the x86 assembler
in binutils 2.32 and above generates a program property note in a note
section, .note.gnu.property, to encode used x86 ISAs and features. X86
kernel vDSO linker script only contains a signle NOTE segment:

PHDRS
{
text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
note PT_NOTE FLAGS(4); /* PF_R */
eh_frame_hdr 0x6474e550;
}

which may not be incompatible with note.gnu.property sections. Since
note.gnu.property section in vDSO is not used by dynamic linker, this
patch discards .note.gnu.property sections in vDSO by adding

/DISCARD/ : {
*(.note.gnu.property)
}

before .notes sections.

Signed-off-by: H.J. Lu <[email protected]>
Signed-off-by: Yu-cheng Yu <[email protected]>
---
arch/x86/entry/vdso/vdso-layout.lds.S | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/x86/entry/vdso/vdso-layout.lds.S b/arch/x86/entry/vdso/vdso-layout.lds.S
index 93c6dc7812d0..b604da6cc024 100644
--- a/arch/x86/entry/vdso/vdso-layout.lds.S
+++ b/arch/x86/entry/vdso/vdso-layout.lds.S
@@ -52,6 +52,10 @@ SECTIONS
*(.gnu.linkonce.b.*)
} :text

+ /* .note.gnu.property sections should be discarded */
+ /DISCARD/ : {
+ *(.note.gnu.property)
+ }
.note : { *(.note.*) } :text :note

.eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
--
2.24.1