Skip to content

Commit

Permalink
vmlinux.lds.h: Provide EMIT_PT_NOTE to indicate export of .notes
Browse files Browse the repository at this point in the history
In preparation for moving NOTES into RO_DATA, provide a mechanism for
architectures that want to emit a PT_NOTE Program Header to do so.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com> # s390
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: linux-alpha@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-c6x-dev@linux-c6x.org
Cc: linux-ia64@vger.kernel.org
Cc: linux-s390@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Rick Edgecombe <rick.p.edgecombe@intel.com>
Cc: Segher Boessenkool <segher@kernel.crashing.org>
Cc: Will Deacon <will@kernel.org>
Cc: x86-ml <x86@kernel.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Link: https://lkml.kernel.org/r/20191029211351.13243-9-keescook@chromium.org
  • Loading branch information
Kees Cook authored and Borislav Petkov committed Nov 4, 2019
1 parent 7a42d41 commit 441110a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 6 deletions.
3 changes: 3 additions & 0 deletions arch/alpha/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 */

#define EMITS_PT_NOTE

#include <asm-generic/vmlinux.lds.h>
#include <asm/thread_info.h>
#include <asm/cache.h>
Expand Down
2 changes: 2 additions & 0 deletions arch/ia64/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <asm/pgtable.h>
#include <asm/thread_info.h>

#define EMITS_PT_NOTE

#include <asm-generic/vmlinux.lds.h>

OUTPUT_FORMAT("elf64-ia64-little")
Expand Down
12 changes: 6 additions & 6 deletions arch/mips/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
*/
#define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir)

/* Cavium Octeon should not have a separate PT_NOTE Program Header. */
#ifndef CONFIG_CAVIUM_OCTEON_SOC
#define EMITS_PT_NOTE
#endif

#include <asm-generic/vmlinux.lds.h>

#undef mips
Expand Down Expand Up @@ -76,12 +81,7 @@ SECTIONS
__stop___dbe_table = .;
}

#ifdef CONFIG_CAVIUM_OCTEON_SOC
#define NOTES_HEADER
#else /* CONFIG_CAVIUM_OCTEON_SOC */
#define NOTES_HEADER :note
#endif /* CONFIG_CAVIUM_OCTEON_SOC */
NOTES :text NOTES_HEADER
NOTES NOTES_HEADERS
.dummy : { *(.dummy) } :text

_sdata = .; /* Start of data section */
Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#endif

#define BSS_FIRST_SECTIONS *(.bss.prominit)
#define EMITS_PT_NOTE

#include <asm/page.h>
#include <asm-generic/vmlinux.lds.h>
Expand Down
2 changes: 2 additions & 0 deletions arch/s390/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
/* Handle ro_after_init data on our own. */
#define RO_AFTER_INIT_DATA

#define EMITS_PT_NOTE

#include <asm-generic/vmlinux.lds.h>
#include <asm/vmlinux.lds.h>

Expand Down
2 changes: 2 additions & 0 deletions arch/x86/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#define LOAD_OFFSET __START_KERNEL_map
#endif

#define EMITS_PT_NOTE

#include <asm-generic/vmlinux.lds.h>
#include <asm/asm-offsets.h>
#include <asm/thread_info.h>
Expand Down
8 changes: 8 additions & 0 deletions include/asm-generic/vmlinux.lds.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@
#define LOAD_OFFSET 0
#endif

/*
* Only some architectures want to have the .notes segment visible in
* a separate PT_NOTE ELF Program Header.
*/
#ifdef EMITS_PT_NOTE
#define NOTES_HEADERS :text :note
#endif

/* Align . to a 8 byte boundary equals to maximum function alignment. */
#define ALIGN_FUNCTION() . = ALIGN(8)

Expand Down

0 comments on commit 441110a

Please sign in to comment.