mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 00:04:15 +08:00
34eb62d868
because the heuristics that various linkers & compilers use to handle them (include these bits into the output image vs discarding them silently) are both highly idiosyncratic and also version dependent. Instead of this historically problematic mess, this tree by Kees Cook (et al) adds build time asserts and build time warnings if there's any orphan section in the kernel or if a section is not sized as expected. And because we relied on so many silent assumptions in this area, fix a metric ton of dependencies and some outright bugs related to this, before we can finally enable the checks on the x86, ARM and ARM64 platforms. Signed-off-by: Ingo Molnar <mingo@kernel.org> -----BEGIN PGP SIGNATURE----- iQJFBAABCgAvFiEEBpT5eoXrXCwVQwEKEnMQ0APhK1gFAl+Edv4RHG1pbmdvQGtl cm5lbC5vcmcACgkQEnMQ0APhK1hiKBAApdJEOaK7hMc3013DYNctklIxEPJL2mFJ 11YJRIh4pUJTF0TE+EHT/D+rSIuRsyuoSmOQBQ61/wVSnyG067GjjVJRqh/eYaJ1 fDhJi2FuHOjXl+CiN0KxzBjjp+V4NhF7jHT59tpQSvfZeg7FjteoxfztxaCp5ek3 S3wHB3CC4c4jE3lfjHem1E9/PwT4kwPYx1c3gAUdEqJdjkihjX9fWusfjLeqW6/d Y5VkApi6bL9XiZUZj5l0dEIweLJJ86+PkKJqpo3spxxEak1LSn1MEix+lcJ8e1Kg sb/bEEivDcmFlFWOJnn0QLquCR0Cx5bz1pwsL0tuf0yAd4+sXX5IMuGUysZlEdKM BHL9h5HbevGF4BScwZwZH7lyEg7q67s5KnRu4hxy0Swfcj7y0oT/9lXqpbpZ2DqO Hd+bRRQKIbqnTMp0hcit9LfpLp93vj0dBlaV5ocAJJlu62u9VnwGG5HQuZ5giLUr kA1SLw63Y1wopFRxgFyER8les7eLsu0zxHeK44rRVlVnfI99OMTOgVNicmDFy3Fm AfcnfJG0BqBEJGQz5es34uQQKKBwFPtC9NztopI62KiwOspYYZyrO1BNxdOc6DlS mIHrmO89HMXuid5eolvLaFqUWirHoWO8TlycgZxUWVHc2txVPjAEU/axouU/dSSU w/6GpzAa+7g= =fXAw -----END PGP SIGNATURE----- Merge tag 'core-build-2020-10-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip Pull orphan section checking from Ingo Molnar: "Orphan link sections were a long-standing source of obscure bugs, because the heuristics that various linkers & compilers use to handle them (include these bits into the output image vs discarding them silently) are both highly idiosyncratic and also version dependent. Instead of this historically problematic mess, this tree by Kees Cook (et al) adds build time asserts and build time warnings if there's any orphan section in the kernel or if a section is not sized as expected. And because we relied on so many silent assumptions in this area, fix a metric ton of dependencies and some outright bugs related to this, before we can finally enable the checks on the x86, ARM and ARM64 platforms" * tag 'core-build-2020-10-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (36 commits) x86/boot/compressed: Warn on orphan section placement x86/build: Warn on orphan section placement arm/boot: Warn on orphan section placement arm/build: Warn on orphan section placement arm64/build: Warn on orphan section placement x86/boot/compressed: Add missing debugging sections to output x86/boot/compressed: Remove, discard, or assert for unwanted sections x86/boot/compressed: Reorganize zero-size section asserts x86/build: Add asserts for unwanted sections x86/build: Enforce an empty .got.plt section x86/asm: Avoid generating unused kprobe sections arm/boot: Handle all sections explicitly arm/build: Assert for unwanted sections arm/build: Add missing sections arm/build: Explicitly keep .ARM.attributes sections arm/build: Refactor linker script headers arm64/build: Assert for unwanted sections arm64/build: Add missing DWARF sections arm64/build: Use common DISCARDS in linker script arm64/build: Remove .eh_frame* sections due to unwind tables ...
111 lines
2.2 KiB
ArmAsm
111 lines
2.2 KiB
ArmAsm
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* OpenRISC vmlinux.lds.S
|
|
*
|
|
* Linux architectural port borrowing liberally from similar works of
|
|
* others. All original copyrights apply as per the original source
|
|
* declaration.
|
|
*
|
|
* Modifications for the OpenRISC architecture:
|
|
* Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
|
|
* Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
|
|
*
|
|
* ld script for OpenRISC architecture
|
|
*/
|
|
|
|
/* TODO
|
|
* - clean up __offset & stuff
|
|
* - change all 8192 alignment to PAGE !!!
|
|
* - recheck if all alignments are really needed
|
|
*/
|
|
|
|
# define LOAD_OFFSET PAGE_OFFSET
|
|
# define LOAD_BASE PAGE_OFFSET
|
|
|
|
#include <asm/page.h>
|
|
#include <asm/cache.h>
|
|
#include <asm/thread_info.h>
|
|
#include <asm-generic/vmlinux.lds.h>
|
|
|
|
#ifdef __OR1K__
|
|
#define __OUTPUT_FORMAT "elf32-or1k"
|
|
#else
|
|
#define __OUTPUT_FORMAT "elf32-or32"
|
|
#endif
|
|
|
|
OUTPUT_FORMAT(__OUTPUT_FORMAT, __OUTPUT_FORMAT, __OUTPUT_FORMAT)
|
|
jiffies = jiffies_64 + 4;
|
|
|
|
SECTIONS
|
|
{
|
|
/* Read-only sections, merged into text segment: */
|
|
. = LOAD_BASE ;
|
|
|
|
_text = .;
|
|
|
|
/* _s_kernel_ro must be page aligned */
|
|
. = ALIGN(PAGE_SIZE);
|
|
_s_kernel_ro = .;
|
|
|
|
.text : AT(ADDR(.text) - LOAD_OFFSET)
|
|
{
|
|
_stext = .;
|
|
TEXT_TEXT
|
|
SCHED_TEXT
|
|
CPUIDLE_TEXT
|
|
LOCK_TEXT
|
|
KPROBES_TEXT
|
|
IRQENTRY_TEXT
|
|
SOFTIRQENTRY_TEXT
|
|
*(.fixup)
|
|
*(.text.__*)
|
|
_etext = .;
|
|
}
|
|
/* TODO: Check if fixup and text.__* are really necessary
|
|
* fixup is definitely necessary
|
|
*/
|
|
|
|
_sdata = .;
|
|
|
|
/* Page alignment required for RO_DATA */
|
|
RO_DATA(PAGE_SIZE)
|
|
_e_kernel_ro = .;
|
|
|
|
/* Whatever comes after _e_kernel_ro had better be page-aligend, too */
|
|
|
|
/* 32 here is cacheline size... recheck this */
|
|
RW_DATA(32, PAGE_SIZE, PAGE_SIZE)
|
|
|
|
_edata = .;
|
|
|
|
EXCEPTION_TABLE(4)
|
|
|
|
/* Init code and data */
|
|
. = ALIGN(PAGE_SIZE);
|
|
__init_begin = .;
|
|
|
|
HEAD_TEXT_SECTION
|
|
|
|
/* Page aligned */
|
|
INIT_TEXT_SECTION(PAGE_SIZE)
|
|
|
|
/* Align __setup_start on 16 byte boundary */
|
|
INIT_DATA_SECTION(16)
|
|
|
|
PERCPU_SECTION(L1_CACHE_BYTES)
|
|
|
|
__init_end = .;
|
|
|
|
BSS_SECTION(0, 0, 0x20)
|
|
|
|
_end = .;
|
|
|
|
/* Throw in the debugging sections */
|
|
STABS_DEBUG
|
|
DWARF_DEBUG
|
|
ELF_DETAILS
|
|
|
|
/* Sections to be discarded -- must be last */
|
|
DISCARDS
|
|
}
|