Merge branch 'x86/build' into x86/asm, to pick up completed topic branch

Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
Ingo Molnar 2019-11-25 09:05:09 +01:00
commit f01ec4fca8
38 changed files with 163 additions and 179 deletions

View file

@ -1,4 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0 */ /* SPDX-License-Identifier: GPL-2.0 */
#define EMITS_PT_NOTE
#define RO_EXCEPTION_TABLE_ALIGN 16
#include <asm-generic/vmlinux.lds.h> #include <asm-generic/vmlinux.lds.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
#include <asm/cache.h> #include <asm/cache.h>
@ -8,7 +12,7 @@
OUTPUT_FORMAT("elf64-alpha") OUTPUT_FORMAT("elf64-alpha")
OUTPUT_ARCH(alpha) OUTPUT_ARCH(alpha)
ENTRY(__start) ENTRY(__start)
PHDRS { kernel PT_LOAD; note PT_NOTE; } PHDRS { text PT_LOAD; note PT_NOTE; }
jiffies = jiffies_64; jiffies = jiffies_64;
SECTIONS SECTIONS
{ {
@ -27,17 +31,11 @@ SECTIONS
LOCK_TEXT LOCK_TEXT
*(.fixup) *(.fixup)
*(.gnu.warning) *(.gnu.warning)
} :kernel } :text
swapper_pg_dir = SWAPPER_PGD; swapper_pg_dir = SWAPPER_PGD;
_etext = .; /* End of text section */ _etext = .; /* End of text section */
NOTES :kernel :note RO_DATA(4096)
.dummy : {
*(.dummy)
} :kernel
RODATA
EXCEPTION_TABLE(16)
/* Will be freed after init */ /* Will be freed after init */
__init_begin = ALIGN(PAGE_SIZE); __init_begin = ALIGN(PAGE_SIZE);
@ -52,7 +50,7 @@ SECTIONS
_sdata = .; /* Start of rw data section */ _sdata = .; /* Start of rw data section */
_data = .; _data = .;
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE) RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
.got : { .got : {
*(.got) *(.got)

View file

@ -95,13 +95,13 @@ SECTIONS
_etext = .; _etext = .;
_sdata = .; _sdata = .;
RO_DATA_SECTION(PAGE_SIZE) RO_DATA(PAGE_SIZE)
/* /*
* 1. this is .data essentially * 1. this is .data essentially
* 2. THREAD_SIZE for init.task, must be kernel-stk sz aligned * 2. THREAD_SIZE for init.task, must be kernel-stk sz aligned
*/ */
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE) RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
_edata = .; _edata = .;
@ -118,8 +118,6 @@ SECTIONS
/DISCARD/ : { *(.eh_frame) } /DISCARD/ : { *(.eh_frame) }
#endif #endif
NOTES
. = ALIGN(PAGE_SIZE); . = ALIGN(PAGE_SIZE);
_end = . ; _end = . ;

View file

@ -70,8 +70,6 @@ SECTIONS
ARM_UNWIND_SECTIONS ARM_UNWIND_SECTIONS
#endif #endif
NOTES
_etext = .; /* End of text and rodata section */ _etext = .; /* End of text and rodata section */
ARM_VECTORS ARM_VECTORS
@ -114,7 +112,7 @@ SECTIONS
. = ALIGN(THREAD_SIZE); . = ALIGN(THREAD_SIZE);
_sdata = .; _sdata = .;
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE) RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
.data.ro_after_init : AT(ADDR(.data.ro_after_init) - LOAD_OFFSET) { .data.ro_after_init : AT(ADDR(.data.ro_after_init) - LOAD_OFFSET) {
*(.data..ro_after_init) *(.data..ro_after_init)
} }

View file

@ -81,8 +81,6 @@ SECTIONS
ARM_UNWIND_SECTIONS ARM_UNWIND_SECTIONS
#endif #endif
NOTES
#ifdef CONFIG_STRICT_KERNEL_RWX #ifdef CONFIG_STRICT_KERNEL_RWX
. = ALIGN(1<<SECTION_SHIFT); . = ALIGN(1<<SECTION_SHIFT);
#else #else
@ -143,7 +141,7 @@ SECTIONS
__init_end = .; __init_end = .;
_sdata = .; _sdata = .;
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE) RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
_edata = .; _edata = .;
BSS_SECTION(0, 0, 0) BSS_SECTION(0, 0, 0)

View file

@ -5,6 +5,8 @@
* Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz> * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
*/ */
#define RO_EXCEPTION_TABLE_ALIGN 8
#include <asm-generic/vmlinux.lds.h> #include <asm-generic/vmlinux.lds.h>
#include <asm/cache.h> #include <asm/cache.h>
#include <asm/kernel-pgtable.h> #include <asm/kernel-pgtable.h>
@ -135,11 +137,9 @@ SECTIONS
. = ALIGN(SEGMENT_ALIGN); . = ALIGN(SEGMENT_ALIGN);
_etext = .; /* End of text section */ _etext = .; /* End of text section */
RO_DATA(PAGE_SIZE) /* everything from this point to */ /* everything from this point to __init_begin will be marked RO NX */
EXCEPTION_TABLE(8) /* __init_begin will be marked RO NX */ RO_DATA(PAGE_SIZE)
NOTES
. = ALIGN(PAGE_SIZE);
idmap_pg_dir = .; idmap_pg_dir = .;
. += IDMAP_DIR_SIZE; . += IDMAP_DIR_SIZE;
@ -215,7 +215,7 @@ SECTIONS
_data = .; _data = .;
_sdata = .; _sdata = .;
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN) RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN)
/* /*
* Data written with the MMU off but read with the MMU on requires * Data written with the MMU off but read with the MMU on requires

View file

@ -5,6 +5,9 @@
* Copyright (C) 2010, 2011 Texas Instruments Incorporated * Copyright (C) 2010, 2011 Texas Instruments Incorporated
* Mark Salter <msalter@redhat.com> * Mark Salter <msalter@redhat.com>
*/ */
#define RO_EXCEPTION_TABLE_ALIGN 16
#include <asm-generic/vmlinux.lds.h> #include <asm-generic/vmlinux.lds.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
#include <asm/page.h> #include <asm/page.h>
@ -80,10 +83,7 @@ SECTIONS
*(.gnu.warning) *(.gnu.warning)
} }
EXCEPTION_TABLE(16) RO_DATA(PAGE_SIZE)
NOTES
RO_DATA_SECTION(PAGE_SIZE)
.const : .const :
{ {
*(.const .const.* .gnu.linkonce.r.*) *(.const .const.* .gnu.linkonce.r.*)

View file

@ -49,11 +49,10 @@ SECTIONS
_sdata = .; _sdata = .;
RO_DATA_SECTION(PAGE_SIZE) RO_DATA(PAGE_SIZE)
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE) RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
_edata = .; _edata = .;
NOTES
EXCEPTION_TABLE(L1_CACHE_BYTES) EXCEPTION_TABLE(L1_CACHE_BYTES)
BSS_SECTION(L1_CACHE_BYTES, PAGE_SIZE, L1_CACHE_BYTES) BSS_SECTION(L1_CACHE_BYTES, PAGE_SIZE, L1_CACHE_BYTES)
VBR_BASE VBR_BASE

View file

@ -1,4 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 */ /* SPDX-License-Identifier: GPL-2.0 */
#define RO_EXCEPTION_TABLE_ALIGN 16
#include <asm-generic/vmlinux.lds.h> #include <asm-generic/vmlinux.lds.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
@ -37,9 +40,7 @@ SECTIONS
#endif #endif
_etext = . ; _etext = . ;
} }
EXCEPTION_TABLE(16) RO_DATA(4)
NOTES
RO_DATA_SECTION(4)
ROMEND = .; ROMEND = .;
#if defined(CONFIG_ROMKERNEL) #if defined(CONFIG_ROMKERNEL)
. = RAMTOP; . = RAMTOP;
@ -48,7 +49,7 @@ SECTIONS
#endif #endif
_sdata = . ; _sdata = . ;
__data_start = . ; __data_start = . ;
RW_DATA_SECTION(0, PAGE_SIZE, THREAD_SIZE) RW_DATA(0, PAGE_SIZE, THREAD_SIZE)
#if defined(CONFIG_ROMKERNEL) #if defined(CONFIG_ROMKERNEL)
#undef ADDR #undef ADDR
#endif #endif

View file

@ -49,12 +49,11 @@ SECTIONS
INIT_DATA_SECTION(PAGE_SIZE) INIT_DATA_SECTION(PAGE_SIZE)
_sdata = .; _sdata = .;
RW_DATA_SECTION(32,PAGE_SIZE,_THREAD_SIZE) RW_DATA(32,PAGE_SIZE,_THREAD_SIZE)
RO_DATA_SECTION(PAGE_SIZE) RO_DATA(PAGE_SIZE)
_edata = .; _edata = .;
EXCEPTION_TABLE(16) EXCEPTION_TABLE(16)
NOTES
BSS_SECTION(_PAGE_SIZE, _PAGE_SIZE, _PAGE_SIZE) BSS_SECTION(_PAGE_SIZE, _PAGE_SIZE, _PAGE_SIZE)

View file

@ -5,6 +5,9 @@
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
#define EMITS_PT_NOTE
#define RO_EXCEPTION_TABLE_ALIGN 16
#include <asm-generic/vmlinux.lds.h> #include <asm-generic/vmlinux.lds.h>
OUTPUT_FORMAT("elf64-ia64-little") OUTPUT_FORMAT("elf64-ia64-little")
@ -13,7 +16,7 @@ ENTRY(phys_start)
jiffies = jiffies_64; jiffies = jiffies_64;
PHDRS { PHDRS {
code PT_LOAD; text PT_LOAD;
percpu PT_LOAD; percpu PT_LOAD;
data PT_LOAD; data PT_LOAD;
note PT_NOTE; note PT_NOTE;
@ -36,7 +39,7 @@ SECTIONS {
phys_start = _start - LOAD_OFFSET; phys_start = _start - LOAD_OFFSET;
code : { code : {
} :code } :text
. = KERNEL_START; . = KERNEL_START;
_text = .; _text = .;
@ -68,11 +71,6 @@ SECTIONS {
/* /*
* Read-only data * Read-only data
*/ */
NOTES :code :note /* put .notes in text and mark in PT_NOTE */
code_continues : {
} : code /* switch back to regular program... */
EXCEPTION_TABLE(16)
/* MCA table */ /* MCA table */
. = ALIGN(16); . = ALIGN(16);
@ -102,11 +100,11 @@ SECTIONS {
__start_unwind = .; __start_unwind = .;
*(.IA_64.unwind*) *(.IA_64.unwind*)
__end_unwind = .; __end_unwind = .;
} :code :unwind } :text :unwind
code_continues2 : { code_continues2 : {
} : code } :text
RODATA RO_DATA(4096)
.opd : AT(ADDR(.opd) - LOAD_OFFSET) { .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
__start_opd = .; __start_opd = .;
@ -214,7 +212,7 @@ SECTIONS {
_end = .; _end = .;
code : { code : {
} :code } :text
STABS_DEBUG STABS_DEBUG
DWARF_DEBUG DWARF_DEBUG

View file

@ -60,8 +60,8 @@ SECTIONS {
#endif #endif
_sdata = .; _sdata = .;
RO_DATA_SECTION(PAGE_SIZE) RO_DATA(PAGE_SIZE)
RW_DATA_SECTION(16, PAGE_SIZE, THREAD_SIZE) RW_DATA(16, PAGE_SIZE, THREAD_SIZE)
_edata = .; _edata = .;
EXCEPTION_TABLE(16) EXCEPTION_TABLE(16)

View file

@ -31,9 +31,9 @@ SECTIONS
_sdata = .; /* Start of data section */ _sdata = .; /* Start of data section */
RODATA RO_DATA(4096)
RW_DATA_SECTION(16, PAGE_SIZE, THREAD_SIZE) RW_DATA(16, PAGE_SIZE, THREAD_SIZE)
BSS_SECTION(0, 0, 0) BSS_SECTION(0, 0, 0)

View file

@ -24,13 +24,13 @@ SECTIONS
*(.fixup) *(.fixup)
*(.gnu.warning) *(.gnu.warning)
} :text = 0x4e75 } :text = 0x4e75
RODATA RO_DATA(4096)
_etext = .; /* End of text section */ _etext = .; /* End of text section */
EXCEPTION_TABLE(16) :data EXCEPTION_TABLE(16) :data
_sdata = .; /* Start of rw data section */ _sdata = .; /* Start of rw data section */
RW_DATA_SECTION(16, PAGE_SIZE, THREAD_SIZE) :data RW_DATA(16, PAGE_SIZE, THREAD_SIZE) :data
/* End of data goes *here* so that freeing init code works properly. */ /* End of data goes *here* so that freeing init code works properly. */
_edata = .; _edata = .;
NOTES NOTES

View file

@ -11,6 +11,8 @@
OUTPUT_ARCH(microblaze) OUTPUT_ARCH(microblaze)
ENTRY(microblaze_start) ENTRY(microblaze_start)
#define RO_EXCEPTION_TABLE_ALIGN 16
#include <asm/page.h> #include <asm/page.h>
#include <asm-generic/vmlinux.lds.h> #include <asm-generic/vmlinux.lds.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
@ -51,9 +53,7 @@ SECTIONS {
} }
. = ALIGN(16); . = ALIGN(16);
RODATA RO_DATA(4096)
EXCEPTION_TABLE(16)
NOTES
/* /*
* sdata2 section can go anywhere, but must be word aligned * sdata2 section can go anywhere, but must be word aligned
@ -70,7 +70,7 @@ SECTIONS {
} }
_sdata = . ; _sdata = . ;
RW_DATA_SECTION(32, PAGE_SIZE, THREAD_SIZE) RW_DATA(32, PAGE_SIZE, THREAD_SIZE)
_edata = . ; _edata = . ;
/* Under the microblaze ABI, .sdata and .sbss must be contiguous */ /* Under the microblaze ABI, .sdata and .sbss must be contiguous */

View file

@ -10,6 +10,11 @@
*/ */
#define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir) #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> #include <asm-generic/vmlinux.lds.h>
#undef mips #undef mips
@ -76,16 +81,8 @@ SECTIONS
__stop___dbe_table = .; __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
.dummy : { *(.dummy) } :text
_sdata = .; /* Start of data section */ _sdata = .; /* Start of data section */
RODATA RO_DATA(4096)
/* writeable */ /* writeable */
.data : { /* Data */ .data : { /* Data */

View file

@ -53,12 +53,11 @@ SECTIONS
_etext = .; /* End of text and rodata section */ _etext = .; /* End of text and rodata section */
_sdata = .; _sdata = .;
RO_DATA_SECTION(PAGE_SIZE) RO_DATA(PAGE_SIZE)
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE) RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
_edata = .; _edata = .;
EXCEPTION_TABLE(16) EXCEPTION_TABLE(16)
NOTES
BSS_SECTION(4, 4, 4) BSS_SECTION(4, 4, 4)
_end = .; _end = .;

View file

@ -49,8 +49,8 @@ SECTIONS
__init_end = .; __init_end = .;
_sdata = .; _sdata = .;
RO_DATA_SECTION(PAGE_SIZE) RO_DATA(PAGE_SIZE)
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE) RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
_edata = .; _edata = .;
BSS_SECTION(0, 0, 0) BSS_SECTION(0, 0, 0)
@ -58,7 +58,6 @@ SECTIONS
STABS_DEBUG STABS_DEBUG
DWARF_DEBUG DWARF_DEBUG
NOTES
DISCARDS DISCARDS
} }

View file

@ -67,19 +67,18 @@ SECTIONS
_sdata = .; _sdata = .;
/* Page alignment required for RO_DATA_SECTION */ /* Page alignment required for RO_DATA */
RO_DATA_SECTION(PAGE_SIZE) RO_DATA(PAGE_SIZE)
_e_kernel_ro = .; _e_kernel_ro = .;
/* Whatever comes after _e_kernel_ro had better be page-aligend, too */ /* Whatever comes after _e_kernel_ro had better be page-aligend, too */
/* 32 here is cacheline size... recheck this */ /* 32 here is cacheline size... recheck this */
RW_DATA_SECTION(32, PAGE_SIZE, PAGE_SIZE) RW_DATA(32, PAGE_SIZE, PAGE_SIZE)
_edata = .; _edata = .;
EXCEPTION_TABLE(4) EXCEPTION_TABLE(4)
NOTES
/* Init code and data */ /* Init code and data */
. = ALIGN(PAGE_SIZE); . = ALIGN(PAGE_SIZE);

View file

@ -19,6 +19,7 @@
*(.data..vm0.pte) *(.data..vm0.pte)
#define CC_USING_PATCHABLE_FUNCTION_ENTRY #define CC_USING_PATCHABLE_FUNCTION_ENTRY
#define RO_EXCEPTION_TABLE_ALIGN 8
#include <asm-generic/vmlinux.lds.h> #include <asm-generic/vmlinux.lds.h>
@ -109,7 +110,7 @@ SECTIONS
_sdata = .; _sdata = .;
/* Architecturally we need to keep __gp below 0x1000000 and thus /* Architecturally we need to keep __gp below 0x1000000 and thus
* in front of RO_DATA_SECTION() which stores lots of tracepoint * in front of RO_DATA() which stores lots of tracepoint
* and ftrace symbols. */ * and ftrace symbols. */
#ifdef CONFIG_64BIT #ifdef CONFIG_64BIT
. = ALIGN(16); . = ALIGN(16);
@ -127,11 +128,7 @@ SECTIONS
} }
#endif #endif
RO_DATA_SECTION(8) RO_DATA(8)
/* RO because of BUILDTIME_EXTABLE_SORT */
EXCEPTION_TABLE(8)
NOTES
/* unwind info */ /* unwind info */
.PARISC.unwind : { .PARISC.unwind : {
@ -149,7 +146,7 @@ SECTIONS
data_start = .; data_start = .;
/* Data */ /* Data */
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, PAGE_SIZE) RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, PAGE_SIZE)
/* PA-RISC locks requires 16-byte alignment */ /* PA-RISC locks requires 16-byte alignment */
. = ALIGN(16); . = ALIGN(16);

View file

@ -6,6 +6,8 @@
#endif #endif
#define BSS_FIRST_SECTIONS *(.bss.prominit) #define BSS_FIRST_SECTIONS *(.bss.prominit)
#define EMITS_PT_NOTE
#define RO_EXCEPTION_TABLE_ALIGN 0
#include <asm/page.h> #include <asm/page.h>
#include <asm-generic/vmlinux.lds.h> #include <asm-generic/vmlinux.lds.h>
@ -18,22 +20,8 @@
ENTRY(_stext) ENTRY(_stext)
PHDRS { PHDRS {
kernel PT_LOAD FLAGS(7); /* RWX */ text PT_LOAD FLAGS(7); /* RWX */
notes PT_NOTE FLAGS(0); note PT_NOTE FLAGS(0);
dummy PT_NOTE FLAGS(0);
/* binutils < 2.18 has a bug that makes it misbehave when taking an
ELF file with all segments at load address 0 as input. This
happens when running "strip" on vmlinux, because of the AT() magic
in this linker script. People using GCC >= 4.2 won't run into
this problem, because the "build-id" support will put some data
into the "notes" segment (at a non-zero load address).
To work around this, we force some data into both the "dummy"
segment and the kernel segment, so the dummy segment will get a
non-zero load address. It's not enough to always create the
"notes" segment, since if nothing gets assigned to it, its load
address will be zero. */
} }
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
@ -77,7 +65,7 @@ SECTIONS
#else /* !CONFIG_PPC64 */ #else /* !CONFIG_PPC64 */
HEAD_TEXT HEAD_TEXT
#endif #endif
} :kernel } :text
__head_end = .; __head_end = .;
@ -126,7 +114,7 @@ SECTIONS
__got2_end = .; __got2_end = .;
#endif /* CONFIG_PPC32 */ #endif /* CONFIG_PPC32 */
} :kernel } :text
. = ALIGN(ETEXT_ALIGN_SIZE); . = ALIGN(ETEXT_ALIGN_SIZE);
_etext = .; _etext = .;
@ -175,17 +163,6 @@ SECTIONS
__stop__btb_flush_fixup = .; __stop__btb_flush_fixup = .;
} }
#endif #endif
EXCEPTION_TABLE(0)
NOTES :kernel :notes
/* The dummy segment contents for the bug workaround mentioned above
near PHDRS. */
.dummy : AT(ADDR(.dummy) - LOAD_OFFSET) {
LONG(0)
LONG(0)
LONG(0)
} :kernel :dummy
/* /*
* Init sections discarded at runtime * Init sections discarded at runtime
@ -200,7 +177,7 @@ SECTIONS
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
*(.tramp.ftrace.init); *(.tramp.ftrace.init);
#endif #endif
} :kernel } :text
/* .exit.text is discarded at runtime, not link time, /* .exit.text is discarded at runtime, not link time,
* to deal with references from __bug_table * to deal with references from __bug_table

View file

@ -52,12 +52,12 @@ SECTIONS
/* Start of data section */ /* Start of data section */
_sdata = .; _sdata = .;
RO_DATA_SECTION(L1_CACHE_BYTES) RO_DATA(L1_CACHE_BYTES)
.srodata : { .srodata : {
*(.srodata*) *(.srodata*)
} }
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE) RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
.sdata : { .sdata : {
__global_pointer$ = . + 0x800; __global_pointer$ = . + 0x800;
*(.sdata*) *(.sdata*)
@ -69,7 +69,6 @@ SECTIONS
BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0) BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0)
EXCEPTION_TABLE(0x10) EXCEPTION_TABLE(0x10)
NOTES
.rel.dyn : { .rel.dyn : {
*(.rel.dyn*) *(.rel.dyn*)

View file

@ -15,6 +15,8 @@
/* Handle ro_after_init data on our own. */ /* Handle ro_after_init data on our own. */
#define RO_AFTER_INIT_DATA #define RO_AFTER_INIT_DATA
#define EMITS_PT_NOTE
#include <asm-generic/vmlinux.lds.h> #include <asm-generic/vmlinux.lds.h>
#include <asm/vmlinux.lds.h> #include <asm/vmlinux.lds.h>
@ -50,11 +52,7 @@ SECTIONS
_etext = .; /* End of text section */ _etext = .; /* End of text section */
} :text = 0x0700 } :text = 0x0700
NOTES :text :note RO_DATA(PAGE_SIZE)
.dummy : { *(.dummy) } :data
RO_DATA_SECTION(PAGE_SIZE)
. = ALIGN(PAGE_SIZE); . = ALIGN(PAGE_SIZE);
_sdata = .; /* Start of data section */ _sdata = .; /* Start of data section */
@ -64,12 +62,12 @@ SECTIONS
.data..ro_after_init : { .data..ro_after_init : {
*(.data..ro_after_init) *(.data..ro_after_init)
JUMP_TABLE_DATA JUMP_TABLE_DATA
} } :data
EXCEPTION_TABLE(16) EXCEPTION_TABLE(16)
. = ALIGN(PAGE_SIZE); . = ALIGN(PAGE_SIZE);
__end_ro_after_init = .; __end_ro_after_init = .;
RW_DATA_SECTION(0x100, PAGE_SIZE, THREAD_SIZE) RW_DATA(0x100, PAGE_SIZE, THREAD_SIZE)
BOOT_DATA_PRESERVED BOOT_DATA_PRESERVED
_edata = .; /* End of data section */ _edata = .; /* End of data section */

View file

@ -48,11 +48,10 @@ SECTIONS
} = 0x0009 } = 0x0009
EXCEPTION_TABLE(16) EXCEPTION_TABLE(16)
NOTES
_sdata = .; _sdata = .;
RO_DATA(PAGE_SIZE) RO_DATA(PAGE_SIZE)
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE) RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
_edata = .; _edata = .;
DWARF_EH_FRAME DWARF_EH_FRAME

View file

@ -67,7 +67,7 @@ SECTIONS
.data1 : { .data1 : {
*(.data1) *(.data1)
} }
RW_DATA_SECTION(SMP_CACHE_BYTES, 0, THREAD_SIZE) RW_DATA(SMP_CACHE_BYTES, 0, THREAD_SIZE)
/* End of data section */ /* End of data section */
_edata = .; _edata = .;
@ -78,7 +78,6 @@ SECTIONS
__stop___fixup = .; __stop___fixup = .;
} }
EXCEPTION_TABLE(16) EXCEPTION_TABLE(16)
NOTES
. = ALIGN(PAGE_SIZE); . = ALIGN(PAGE_SIZE);
__init_begin = ALIGN(PAGE_SIZE); __init_begin = ALIGN(PAGE_SIZE);

View file

@ -9,14 +9,13 @@
_sdata = .; _sdata = .;
PROVIDE (sdata = .); PROVIDE (sdata = .);
RODATA RO_DATA(4096)
.unprotected : { *(.unprotected) } .unprotected : { *(.unprotected) }
. = ALIGN(4096); . = ALIGN(4096);
PROVIDE (_unprotected_end = .); PROVIDE (_unprotected_end = .);
. = ALIGN(4096); . = ALIGN(4096);
NOTES
EXCEPTION_TABLE(0) EXCEPTION_TABLE(0)
BUG_TABLE BUG_TABLE

View file

@ -43,12 +43,11 @@ SECTIONS
_etext = .; _etext = .;
_sdata = .; _sdata = .;
RO_DATA_SECTION(PAGE_SIZE) RO_DATA(PAGE_SIZE)
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE) RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
_edata = .; _edata = .;
EXCEPTION_TABLE(L1_CACHE_BYTES) EXCEPTION_TABLE(L1_CACHE_BYTES)
NOTES
BSS_SECTION(0, 0, 0) BSS_SECTION(0, 0, 0)
_end = .; _end = .;

View file

@ -67,6 +67,7 @@ clean-files += cpustr.h
KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
GCOV_PROFILE := n GCOV_PROFILE := n
UBSAN_SANITIZE := n UBSAN_SANITIZE := n

View file

@ -38,6 +38,7 @@ KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
KBUILD_CFLAGS += $(call cc-disable-warning, gnu) KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
KBUILD_CFLAGS += -Wno-pointer-sign KBUILD_CFLAGS += -Wno-pointer-sign
KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
GCOV_PROFILE := n GCOV_PROFILE := n

View file

@ -87,11 +87,9 @@ $(vobjs): KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CFLAGS
# #
# vDSO code runs in userspace and -pg doesn't help with profiling anyway. # vDSO code runs in userspace and -pg doesn't help with profiling anyway.
# #
CFLAGS_REMOVE_vdso-note.o = -pg
CFLAGS_REMOVE_vclock_gettime.o = -pg CFLAGS_REMOVE_vclock_gettime.o = -pg
CFLAGS_REMOVE_vdso32/vclock_gettime.o = -pg CFLAGS_REMOVE_vdso32/vclock_gettime.o = -pg
CFLAGS_REMOVE_vgetcpu.o = -pg CFLAGS_REMOVE_vgetcpu.o = -pg
CFLAGS_REMOVE_vvar.o = -pg
# #
# X32 processes use x32 vDSO to access 64bit kernel data. # X32 processes use x32 vDSO to access 64bit kernel data.

View file

@ -958,7 +958,7 @@ static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
extern unsigned long arch_align_stack(unsigned long sp); extern unsigned long arch_align_stack(unsigned long sp);
void free_init_pages(const char *what, unsigned long begin, unsigned long end); void free_init_pages(const char *what, unsigned long begin, unsigned long end);
extern void free_kernel_image_pages(void *begin, void *end); extern void free_kernel_image_pages(const char *what, void *begin, void *end);
void default_idle(void); void default_idle(void);
#ifdef CONFIG_XEN #ifdef CONFIG_XEN

View file

@ -6,7 +6,6 @@
#include <asm/extable.h> #include <asm/extable.h>
extern char __brk_base[], __brk_limit[]; extern char __brk_base[], __brk_limit[];
extern struct exception_table_entry __stop___ex_table[];
extern char __end_rodata_aligned[]; extern char __end_rodata_aligned[];
#if defined(CONFIG_X86_64) #if defined(CONFIG_X86_64)

View file

@ -143,6 +143,13 @@ struct boot_params boot_params;
/* /*
* Machine setup.. * Machine setup..
*/ */
static struct resource rodata_resource = {
.name = "Kernel rodata",
.start = 0,
.end = 0,
.flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM
};
static struct resource data_resource = { static struct resource data_resource = {
.name = "Kernel data", .name = "Kernel data",
.start = 0, .start = 0,
@ -951,7 +958,9 @@ void __init setup_arch(char **cmdline_p)
code_resource.start = __pa_symbol(_text); code_resource.start = __pa_symbol(_text);
code_resource.end = __pa_symbol(_etext)-1; code_resource.end = __pa_symbol(_etext)-1;
data_resource.start = __pa_symbol(_etext); rodata_resource.start = __pa_symbol(__start_rodata);
rodata_resource.end = __pa_symbol(__end_rodata)-1;
data_resource.start = __pa_symbol(_sdata);
data_resource.end = __pa_symbol(_edata)-1; data_resource.end = __pa_symbol(_edata)-1;
bss_resource.start = __pa_symbol(__bss_start); bss_resource.start = __pa_symbol(__bss_start);
bss_resource.end = __pa_symbol(__bss_stop)-1; bss_resource.end = __pa_symbol(__bss_stop)-1;
@ -1040,6 +1049,7 @@ void __init setup_arch(char **cmdline_p)
/* after parse_early_param, so could debug it */ /* after parse_early_param, so could debug it */
insert_resource(&iomem_resource, &code_resource); insert_resource(&iomem_resource, &code_resource);
insert_resource(&iomem_resource, &rodata_resource);
insert_resource(&iomem_resource, &data_resource); insert_resource(&iomem_resource, &data_resource);
insert_resource(&iomem_resource, &bss_resource); insert_resource(&iomem_resource, &bss_resource);

View file

@ -21,6 +21,9 @@
#define LOAD_OFFSET __START_KERNEL_map #define LOAD_OFFSET __START_KERNEL_map
#endif #endif
#define EMITS_PT_NOTE
#define RO_EXCEPTION_TABLE_ALIGN 16
#include <asm-generic/vmlinux.lds.h> #include <asm-generic/vmlinux.lds.h>
#include <asm/asm-offsets.h> #include <asm/asm-offsets.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
@ -141,17 +144,12 @@ SECTIONS
*(.text.__x86.indirect_thunk) *(.text.__x86.indirect_thunk)
__indirect_thunk_end = .; __indirect_thunk_end = .;
#endif #endif
} :text =0xcccc
/* End of text section */ /* End of text section, which should occupy whole number of pages */
_etext = .; _etext = .;
} :text = 0x9090
NOTES :text :note
EXCEPTION_TABLE(16) :text = 0x9090
/* .text should occupy whole number of pages */
. = ALIGN(PAGE_SIZE); . = ALIGN(PAGE_SIZE);
X86_ALIGN_RODATA_BEGIN X86_ALIGN_RODATA_BEGIN
RO_DATA(PAGE_SIZE) RO_DATA(PAGE_SIZE)
X86_ALIGN_RODATA_END X86_ALIGN_RODATA_END

View file

@ -829,14 +829,13 @@ void free_init_pages(const char *what, unsigned long begin, unsigned long end)
* used for the kernel image only. free_init_pages() will do the * used for the kernel image only. free_init_pages() will do the
* right thing for either kind of address. * right thing for either kind of address.
*/ */
void free_kernel_image_pages(void *begin, void *end) void free_kernel_image_pages(const char *what, void *begin, void *end)
{ {
unsigned long begin_ul = (unsigned long)begin; unsigned long begin_ul = (unsigned long)begin;
unsigned long end_ul = (unsigned long)end; unsigned long end_ul = (unsigned long)end;
unsigned long len_pages = (end_ul - begin_ul) >> PAGE_SHIFT; unsigned long len_pages = (end_ul - begin_ul) >> PAGE_SHIFT;
free_init_pages(what, begin_ul, end_ul);
free_init_pages("unused kernel image", begin_ul, end_ul);
/* /*
* PTI maps some of the kernel into userspace. For performance, * PTI maps some of the kernel into userspace. For performance,
@ -865,7 +864,8 @@ void __ref free_initmem(void)
mem_encrypt_free_decrypted_mem(); mem_encrypt_free_decrypted_mem();
free_kernel_image_pages(&__init_begin, &__init_end); free_kernel_image_pages("unused kernel image (initmem)",
&__init_begin, &__init_end);
} }
#ifdef CONFIG_BLK_DEV_INITRD #ifdef CONFIG_BLK_DEV_INITRD

View file

@ -1263,7 +1263,7 @@ int kernel_set_to_readonly;
void set_kernel_text_rw(void) void set_kernel_text_rw(void)
{ {
unsigned long start = PFN_ALIGN(_text); unsigned long start = PFN_ALIGN(_text);
unsigned long end = PFN_ALIGN(__stop___ex_table); unsigned long end = PFN_ALIGN(_etext);
if (!kernel_set_to_readonly) if (!kernel_set_to_readonly)
return; return;
@ -1282,7 +1282,7 @@ void set_kernel_text_rw(void)
void set_kernel_text_ro(void) void set_kernel_text_ro(void)
{ {
unsigned long start = PFN_ALIGN(_text); unsigned long start = PFN_ALIGN(_text);
unsigned long end = PFN_ALIGN(__stop___ex_table); unsigned long end = PFN_ALIGN(_etext);
if (!kernel_set_to_readonly) if (!kernel_set_to_readonly)
return; return;
@ -1300,9 +1300,9 @@ void mark_rodata_ro(void)
{ {
unsigned long start = PFN_ALIGN(_text); unsigned long start = PFN_ALIGN(_text);
unsigned long rodata_start = PFN_ALIGN(__start_rodata); unsigned long rodata_start = PFN_ALIGN(__start_rodata);
unsigned long end = (unsigned long) &__end_rodata_hpage_align; unsigned long end = (unsigned long)__end_rodata_hpage_align;
unsigned long text_end = PFN_ALIGN(&__stop___ex_table); unsigned long text_end = PFN_ALIGN(_etext);
unsigned long rodata_end = PFN_ALIGN(&__end_rodata); unsigned long rodata_end = PFN_ALIGN(__end_rodata);
unsigned long all_end; unsigned long all_end;
printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n", printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n",
@ -1334,8 +1334,10 @@ void mark_rodata_ro(void)
set_memory_ro(start, (end-start) >> PAGE_SHIFT); set_memory_ro(start, (end-start) >> PAGE_SHIFT);
#endif #endif
free_kernel_image_pages((void *)text_end, (void *)rodata_start); free_kernel_image_pages("unused kernel image (text/rodata gap)",
free_kernel_image_pages((void *)rodata_end, (void *)_sdata); (void *)text_end, (void *)rodata_start);
free_kernel_image_pages("unused kernel image (rodata/data gap)",
(void *)rodata_end, (void *)_sdata);
debug_checkwx(); debug_checkwx();
} }

View file

@ -574,7 +574,7 @@ static void pti_clone_kernel_text(void)
*/ */
unsigned long start = PFN_ALIGN(_text); unsigned long start = PFN_ALIGN(_text);
unsigned long end_clone = (unsigned long)__end_rodata_aligned; unsigned long end_clone = (unsigned long)__end_rodata_aligned;
unsigned long end_global = PFN_ALIGN((unsigned long)__stop___ex_table); unsigned long end_global = PFN_ALIGN((unsigned long)_etext);
if (!pti_kernel_image_global_ok()) if (!pti_kernel_image_global_ok())
return; return;

View file

@ -14,6 +14,8 @@
* Joe Taylor <joe@tensilica.com, joetylr@yahoo.com> * Joe Taylor <joe@tensilica.com, joetylr@yahoo.com>
*/ */
#define RO_EXCEPTION_TABLE_ALIGN 16
#include <asm-generic/vmlinux.lds.h> #include <asm-generic/vmlinux.lds.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
@ -124,18 +126,16 @@ SECTIONS
. = ALIGN(16); . = ALIGN(16);
RODATA RO_DATA(4096)
/* Relocation table */ /* Relocation table */
.fixup : { *(.fixup) } .fixup : { *(.fixup) }
EXCEPTION_TABLE(16)
NOTES
/* Data section */ /* Data section */
_sdata = .; _sdata = .;
RW_DATA_SECTION(XCHAL_ICACHE_LINESIZE, PAGE_SIZE, THREAD_SIZE) RW_DATA(XCHAL_ICACHE_LINESIZE, PAGE_SIZE, THREAD_SIZE)
_edata = .; _edata = .;
/* Initialization code and data: */ /* Initialization code and data: */

View file

@ -23,12 +23,11 @@
* _etext = .; * _etext = .;
* *
* _sdata = .; * _sdata = .;
* RO_DATA_SECTION(PAGE_SIZE) * RO_DATA(PAGE_SIZE)
* RW_DATA_SECTION(...) * RW_DATA(...)
* _edata = .; * _edata = .;
* *
* EXCEPTION_TABLE(...) * EXCEPTION_TABLE(...)
* NOTES
* *
* BSS_SECTION(0, 0, 0) * BSS_SECTION(0, 0, 0)
* _end = .; * _end = .;
@ -54,6 +53,33 @@
#define LOAD_OFFSET 0 #define LOAD_OFFSET 0
#endif #endif
/*
* Only some architectures want to have the .notes segment visible in
* a separate PT_NOTE ELF Program Header. When this happens, it needs
* to be visible in both the kernel text's PT_LOAD and the PT_NOTE
* Program Headers. In this case, though, the PT_LOAD needs to be made
* the default again so that all the following sections don't also end
* up in the PT_NOTE Program Header.
*/
#ifdef EMITS_PT_NOTE
#define NOTES_HEADERS :text :note
#define NOTES_HEADERS_RESTORE __restore_ph : { *(.__restore_ph) } :text
#else
#define NOTES_HEADERS
#define NOTES_HEADERS_RESTORE
#endif
/*
* Some architectures have non-executable read-only exception tables.
* They can be added to the RO_DATA segment by specifying their desired
* alignment.
*/
#ifdef RO_EXCEPTION_TABLE_ALIGN
#define RO_EXCEPTION_TABLE EXCEPTION_TABLE(RO_EXCEPTION_TABLE_ALIGN)
#else
#define RO_EXCEPTION_TABLE
#endif
/* Align . to a 8 byte boundary equals to maximum function alignment. */ /* Align . to a 8 byte boundary equals to maximum function alignment. */
#define ALIGN_FUNCTION() . = ALIGN(8) #define ALIGN_FUNCTION() . = ALIGN(8)
@ -348,7 +374,7 @@
/* /*
* Read only Data * Read only Data
*/ */
#define RO_DATA_SECTION(align) \ #define RO_DATA(align) \
. = ALIGN((align)); \ . = ALIGN((align)); \
.rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \ .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
__start_rodata = .; \ __start_rodata = .; \
@ -496,15 +522,13 @@
__start___modver = .; \ __start___modver = .; \
KEEP(*(__modver)) \ KEEP(*(__modver)) \
__stop___modver = .; \ __stop___modver = .; \
. = ALIGN((align)); \
__end_rodata = .; \
} \ } \
. = ALIGN((align)); \
RO_EXCEPTION_TABLE \
/* RODATA & RO_DATA provided for backward compatibility. NOTES \
* All archs are supposed to use RO_DATA() */ \
#define RODATA RO_DATA_SECTION(4096) . = ALIGN((align)); \
#define RO_DATA(align) RO_DATA_SECTION(align) __end_rodata = .;
/* /*
* .text section. Map to function alignment to avoid address changes * .text section. Map to function alignment to avoid address changes
@ -790,7 +814,8 @@
__start_notes = .; \ __start_notes = .; \
KEEP(*(.note.*)) \ KEEP(*(.note.*)) \
__stop_notes = .; \ __stop_notes = .; \
} } NOTES_HEADERS \
NOTES_HEADERS_RESTORE
#define INIT_SETUP(initsetup_align) \ #define INIT_SETUP(initsetup_align) \
. = ALIGN(initsetup_align); \ . = ALIGN(initsetup_align); \
@ -962,7 +987,7 @@
* matches the requirement of PAGE_ALIGNED_DATA. * matches the requirement of PAGE_ALIGNED_DATA.
* *
* use 0 as page_align if page_aligned data is not used */ * use 0 as page_align if page_aligned data is not used */
#define RW_DATA_SECTION(cacheline, pagealigned, inittask) \ #define RW_DATA(cacheline, pagealigned, inittask) \
. = ALIGN(PAGE_SIZE); \ . = ALIGN(PAGE_SIZE); \
.data : AT(ADDR(.data) - LOAD_OFFSET) { \ .data : AT(ADDR(.data) - LOAD_OFFSET) { \
INIT_TASK_DATA(inittask) \ INIT_TASK_DATA(inittask) \