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

H.J. Lu
2020-01-24T18:18:32Z

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 <hjl.tools@gmail.com>
Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
---
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