2017-11-01 15:07:57 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2012-04-20 14:45:54 +01:00
|
|
|
/*
|
|
|
|
|
* ld script to make ARM Linux kernel
|
|
|
|
|
* taken from the i386 version by Russell King
|
|
|
|
|
* Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <asm-generic/vmlinux.lds.h>
|
2015-12-01 13:20:40 +01:00
|
|
|
#include <asm/cache.h>
|
2015-10-19 14:19:27 +01:00
|
|
|
#include <asm/kernel-pgtable.h>
|
2012-04-20 14:45:54 +01:00
|
|
|
#include <asm/thread_info.h>
|
|
|
|
|
#include <asm/memory.h>
|
|
|
|
|
#include <asm/page.h>
|
2015-01-21 17:36:06 -08:00
|
|
|
#include <asm/pgtable.h>
|
2012-04-20 14:45:54 +01:00
|
|
|
|
2014-06-24 16:51:36 +01:00
|
|
|
#include "image.h"
|
|
|
|
|
|
2014-11-25 15:26:13 +00:00
|
|
|
/* .exit.text needed in case of alternative patching */
|
|
|
|
|
#define ARM_EXIT_KEEP(x) x
|
|
|
|
|
#define ARM_EXIT_DISCARD(x)
|
2012-04-20 14:45:54 +01:00
|
|
|
|
|
|
|
|
OUTPUT_ARCH(aarch64)
|
2014-05-16 18:26:01 +01:00
|
|
|
ENTRY(_text)
|
2012-04-20 14:45:54 +01:00
|
|
|
|
|
|
|
|
jiffies = jiffies_64;
|
|
|
|
|
|
2012-12-07 18:40:43 +00:00
|
|
|
#define HYPERVISOR_TEXT \
|
|
|
|
|
/* \
|
2015-03-19 16:42:26 +00:00
|
|
|
* Align to 4 KB so that \
|
|
|
|
|
* a) the HYP vector table is at its minimum \
|
|
|
|
|
* alignment of 2048 bytes \
|
|
|
|
|
* b) the HYP init code will not cross a page \
|
|
|
|
|
* boundary if its size does not exceed \
|
|
|
|
|
* 4 KB (see related ASSERT() below) \
|
2012-12-07 18:40:43 +00:00
|
|
|
*/ \
|
2015-03-19 16:42:26 +00:00
|
|
|
. = ALIGN(SZ_4K); \
|
2012-12-07 18:40:43 +00:00
|
|
|
VMLINUX_SYMBOL(__hyp_idmap_text_start) = .; \
|
|
|
|
|
*(.hyp.idmap.text) \
|
|
|
|
|
VMLINUX_SYMBOL(__hyp_idmap_text_end) = .; \
|
|
|
|
|
VMLINUX_SYMBOL(__hyp_text_start) = .; \
|
|
|
|
|
*(.hyp.text) \
|
|
|
|
|
VMLINUX_SYMBOL(__hyp_text_end) = .;
|
|
|
|
|
|
2015-06-01 13:40:33 +02:00
|
|
|
#define IDMAP_TEXT \
|
|
|
|
|
. = ALIGN(SZ_4K); \
|
|
|
|
|
VMLINUX_SYMBOL(__idmap_text_start) = .; \
|
|
|
|
|
*(.idmap.text) \
|
|
|
|
|
VMLINUX_SYMBOL(__idmap_text_end) = .;
|
|
|
|
|
|
2016-04-27 17:47:12 +01:00
|
|
|
#ifdef CONFIG_HIBERNATION
|
|
|
|
|
#define HIBERNATE_TEXT \
|
|
|
|
|
. = ALIGN(SZ_4K); \
|
|
|
|
|
VMLINUX_SYMBOL(__hibernate_exit_text_start) = .;\
|
|
|
|
|
*(.hibernate_exit.text) \
|
|
|
|
|
VMLINUX_SYMBOL(__hibernate_exit_text_end) = .;
|
|
|
|
|
#else
|
|
|
|
|
#define HIBERNATE_TEXT
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-11-14 14:07:40 +00:00
|
|
|
#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
|
|
|
|
|
#define TRAMP_TEXT \
|
|
|
|
|
. = ALIGN(PAGE_SIZE); \
|
|
|
|
|
VMLINUX_SYMBOL(__entry_tramp_text_start) = .; \
|
|
|
|
|
*(.entry.tramp.text) \
|
|
|
|
|
. = ALIGN(PAGE_SIZE); \
|
|
|
|
|
VMLINUX_SYMBOL(__entry_tramp_text_end) = .;
|
|
|
|
|
#else
|
|
|
|
|
#define TRAMP_TEXT
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-10-10 18:42:55 +02:00
|
|
|
/*
|
|
|
|
|
* The size of the PE/COFF section that covers the kernel image, which
|
|
|
|
|
* runs from stext to _edata, must be a round multiple of the PE/COFF
|
|
|
|
|
* FileAlignment, which we set to its minimum value of 0x200. 'stext'
|
|
|
|
|
* itself is 4 KB aligned, so padding out _edata to a 0x200 aligned
|
|
|
|
|
* boundary should be sufficient.
|
|
|
|
|
*/
|
|
|
|
|
PECOFF_FILE_ALIGNMENT = 0x200;
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_EFI
|
|
|
|
|
#define PECOFF_EDATA_PADDING \
|
|
|
|
|
.pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
|
|
|
|
|
#else
|
|
|
|
|
#define PECOFF_EDATA_PADDING
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-04-20 14:45:54 +01:00
|
|
|
SECTIONS
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* XXX: The linker does not define how output sections are
|
|
|
|
|
* assigned to input sections when there are multiple statements
|
|
|
|
|
* matching the same input section name. There is no documented
|
|
|
|
|
* order of matching.
|
|
|
|
|
*/
|
|
|
|
|
/DISCARD/ : {
|
|
|
|
|
ARM_EXIT_DISCARD(EXIT_TEXT)
|
|
|
|
|
ARM_EXIT_DISCARD(EXIT_DATA)
|
|
|
|
|
EXIT_CALL
|
|
|
|
|
*(.discard)
|
|
|
|
|
*(.discard.*)
|
2016-01-26 09:13:44 +01:00
|
|
|
*(.interp .dynamic)
|
2016-07-24 14:00:13 +02:00
|
|
|
*(.dynsym .dynstr .hash)
|
2012-04-20 14:45:54 +01:00
|
|
|
}
|
|
|
|
|
|
2016-02-16 13:52:36 +01:00
|
|
|
. = KIMAGE_VADDR + TEXT_OFFSET;
|
2012-04-20 14:45:54 +01:00
|
|
|
|
|
|
|
|
.head.text : {
|
|
|
|
|
_text = .;
|
|
|
|
|
HEAD_TEXT
|
|
|
|
|
}
|
|
|
|
|
.text : { /* Real text segment */
|
|
|
|
|
_stext = .; /* Text and read-only data */
|
|
|
|
|
__exception_text_start = .;
|
|
|
|
|
*(.exception.text)
|
|
|
|
|
__exception_text_end = .;
|
|
|
|
|
IRQENTRY_TEXT
|
2016-03-25 14:22:05 -07:00
|
|
|
SOFTIRQENTRY_TEXT
|
2016-07-08 12:35:50 -04:00
|
|
|
ENTRY_TEXT
|
2012-04-20 14:45:54 +01:00
|
|
|
TEXT_TEXT
|
|
|
|
|
SCHED_TEXT
|
2016-10-07 17:02:55 -07:00
|
|
|
CPUIDLE_TEXT
|
2012-04-20 14:45:54 +01:00
|
|
|
LOCK_TEXT
|
2016-07-08 12:35:48 -04:00
|
|
|
KPROBES_TEXT
|
2012-12-07 18:40:43 +00:00
|
|
|
HYPERVISOR_TEXT
|
2015-06-01 13:40:33 +02:00
|
|
|
IDMAP_TEXT
|
2016-04-27 17:47:12 +01:00
|
|
|
HIBERNATE_TEXT
|
2017-11-14 14:07:40 +00:00
|
|
|
TRAMP_TEXT
|
2012-04-20 14:45:54 +01:00
|
|
|
*(.fixup)
|
|
|
|
|
*(.gnu.warning)
|
|
|
|
|
. = ALIGN(16);
|
|
|
|
|
*(.got) /* Global offset table */
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-30 17:43:09 +02:00
|
|
|
. = ALIGN(SEGMENT_ALIGN);
|
2016-06-23 15:53:17 +02:00
|
|
|
_etext = .; /* End of text section */
|
|
|
|
|
|
|
|
|
|
RO_DATA(PAGE_SIZE) /* everything from this point to */
|
|
|
|
|
EXCEPTION_TABLE(8) /* __init_begin will be marked RO NX */
|
2013-08-23 16:16:42 +01:00
|
|
|
NOTES
|
2012-04-20 14:45:54 +01:00
|
|
|
|
2016-03-30 17:43:09 +02:00
|
|
|
. = ALIGN(SEGMENT_ALIGN);
|
2012-04-20 14:45:54 +01:00
|
|
|
__init_begin = .;
|
2017-03-09 21:52:03 +01:00
|
|
|
__inittext_begin = .;
|
2012-04-20 14:45:54 +01:00
|
|
|
|
|
|
|
|
INIT_TEXT_SECTION(8)
|
|
|
|
|
.exit.text : {
|
|
|
|
|
ARM_EXIT_KEEP(EXIT_TEXT)
|
|
|
|
|
}
|
2015-01-21 17:36:06 -08:00
|
|
|
|
2017-03-09 21:52:03 +01:00
|
|
|
. = ALIGN(4);
|
|
|
|
|
.altinstructions : {
|
|
|
|
|
__alt_instructions = .;
|
|
|
|
|
*(.altinstructions)
|
|
|
|
|
__alt_instructions_end = .;
|
|
|
|
|
}
|
|
|
|
|
.altinstr_replacement : {
|
|
|
|
|
*(.altinstr_replacement)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
. = ALIGN(PAGE_SIZE);
|
|
|
|
|
__inittext_end = .;
|
|
|
|
|
__initdata_begin = .;
|
|
|
|
|
|
2012-04-20 14:45:54 +01:00
|
|
|
.init.data : {
|
|
|
|
|
INIT_DATA
|
|
|
|
|
INIT_SETUP(16)
|
|
|
|
|
INIT_CALLS
|
|
|
|
|
CON_INITCALL
|
|
|
|
|
SECURITY_INITCALL
|
|
|
|
|
INIT_RAM_FS
|
2016-02-17 12:35:58 +00:00
|
|
|
*(.init.rodata.* .init.bss) /* from the EFI stub */
|
2012-04-20 14:45:54 +01:00
|
|
|
}
|
|
|
|
|
.exit.data : {
|
|
|
|
|
ARM_EXIT_KEEP(EXIT_DATA)
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-01 13:20:40 +01:00
|
|
|
PERCPU_SECTION(L1_CACHE_BYTES)
|
2012-04-20 14:45:54 +01:00
|
|
|
|
2016-01-26 09:13:44 +01:00
|
|
|
.rela : ALIGN(8) {
|
|
|
|
|
*(.rela .rela*)
|
|
|
|
|
}
|
2014-11-14 15:54:08 +00:00
|
|
|
|
2016-07-28 16:15:14 +02:00
|
|
|
__rela_offset = ABSOLUTE(ADDR(.rela) - KIMAGE_VADDR);
|
2016-04-18 17:09:43 +02:00
|
|
|
__rela_size = SIZEOF(.rela);
|
|
|
|
|
|
2016-03-30 17:43:09 +02:00
|
|
|
. = ALIGN(SEGMENT_ALIGN);
|
2017-03-09 21:52:03 +01:00
|
|
|
__initdata_end = .;
|
2015-12-09 12:44:38 +00:00
|
|
|
__init_end = .;
|
|
|
|
|
|
2013-11-04 16:38:47 +00:00
|
|
|
_data = .;
|
|
|
|
|
_sdata = .;
|
2017-07-21 14:25:33 +01:00
|
|
|
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN)
|
2016-08-24 18:27:29 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Data written with the MMU off but read with the MMU on requires
|
|
|
|
|
* cache lines to be invalidated, discarding up to a Cache Writeback
|
|
|
|
|
* Granule (CWG) of data from the cache. Keep the section that
|
|
|
|
|
* requires this type of maintenance to be in its own Cache Writeback
|
|
|
|
|
* Granule (CWG) area so the cache maintenance operations don't
|
|
|
|
|
* interfere with adjacent data.
|
|
|
|
|
*/
|
|
|
|
|
.mmuoff.data.write : ALIGN(SZ_2K) {
|
|
|
|
|
__mmuoff_data_start = .;
|
|
|
|
|
*(.mmuoff.data.write)
|
|
|
|
|
}
|
|
|
|
|
. = ALIGN(SZ_2K);
|
|
|
|
|
.mmuoff.data.read : {
|
|
|
|
|
*(.mmuoff.data.read)
|
|
|
|
|
__mmuoff_data_end = .;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-10 18:42:55 +02:00
|
|
|
PECOFF_EDATA_PADDING
|
2017-03-23 19:00:51 +00:00
|
|
|
__pecoff_data_rawsize = ABSOLUTE(. - __initdata_begin);
|
2013-11-04 16:38:47 +00:00
|
|
|
_edata = .;
|
2012-04-20 14:45:54 +01:00
|
|
|
|
|
|
|
|
BSS_SECTION(0, 0, 0)
|
2014-06-24 16:51:35 +01:00
|
|
|
|
|
|
|
|
. = ALIGN(PAGE_SIZE);
|
|
|
|
|
idmap_pg_dir = .;
|
|
|
|
|
. += IDMAP_DIR_SIZE;
|
2018-01-11 10:11:58 +00:00
|
|
|
|
|
|
|
|
#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
|
|
|
|
|
tramp_pg_dir = .;
|
|
|
|
|
. += PAGE_SIZE;
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-07-01 16:53:00 +01:00
|
|
|
#ifdef CONFIG_ARM64_SW_TTBR0_PAN
|
|
|
|
|
reserved_ttbr0 = .;
|
|
|
|
|
. += RESERVED_TTBR0_SIZE;
|
|
|
|
|
#endif
|
2018-01-11 10:11:57 +00:00
|
|
|
swapper_pg_dir = .;
|
|
|
|
|
. += SWAPPER_DIR_SIZE;
|
2018-01-11 10:11:59 +00:00
|
|
|
swapper_pg_end = .;
|
2016-07-01 16:53:00 +01:00
|
|
|
|
2017-03-23 19:00:51 +00:00
|
|
|
__pecoff_data_size = ABSOLUTE(. - __initdata_begin);
|
2012-04-20 14:45:54 +01:00
|
|
|
_end = .;
|
|
|
|
|
|
|
|
|
|
STABS_DEBUG
|
2014-06-24 16:51:36 +01:00
|
|
|
|
|
|
|
|
HEAD_SYMBOLS
|
2012-04-20 14:45:54 +01:00
|
|
|
}
|
2012-12-07 18:40:43 +00:00
|
|
|
|
|
|
|
|
/*
|
2015-06-01 13:40:33 +02:00
|
|
|
* The HYP init code and ID map text can't be longer than a page each,
|
2015-03-19 16:42:26 +00:00
|
|
|
* and should not cross a page boundary.
|
2012-12-07 18:40:43 +00:00
|
|
|
*/
|
2015-03-19 16:42:26 +00:00
|
|
|
ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K,
|
|
|
|
|
"HYP init code too big or misaligned")
|
2015-06-01 13:40:33 +02:00
|
|
|
ASSERT(__idmap_text_end - (__idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K,
|
|
|
|
|
"ID map text too big or misaligned")
|
2016-04-27 17:47:12 +01:00
|
|
|
#ifdef CONFIG_HIBERNATION
|
|
|
|
|
ASSERT(__hibernate_exit_text_end - (__hibernate_exit_text_start & ~(SZ_4K - 1))
|
|
|
|
|
<= SZ_4K, "Hibernate exit text too big or misaligned")
|
|
|
|
|
#endif
|
2017-12-06 11:24:02 +00:00
|
|
|
#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
|
|
|
|
|
ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == PAGE_SIZE,
|
|
|
|
|
"Entry trampoline text too big")
|
|
|
|
|
#endif
|
2014-06-24 16:51:37 +01:00
|
|
|
/*
|
|
|
|
|
* If padding is applied before .head.text, virt<->phys conversions will fail.
|
|
|
|
|
*/
|
2016-02-16 13:52:36 +01:00
|
|
|
ASSERT(_text == (KIMAGE_VADDR + TEXT_OFFSET), "HEAD is misaligned")
|