1/* 2 * ld script to make ARM Linux kernel 3 * taken from the i386 version by Russell King 4 * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz> 5 */ 6 7#include <asm-generic/vmlinux.lds.h> 8#include <asm/kernel-pgtable.h> 9#include <asm/thread_info.h> 10#include <asm/memory.h> 11#include <asm/page.h> 12#include <asm/pgtable.h> 13 14#include "image.h" 15 16/* .exit.text needed in case of alternative patching */ 17#define ARM_EXIT_KEEP(x) x 18#define ARM_EXIT_DISCARD(x) 19 20OUTPUT_ARCH(aarch64) 21ENTRY(_text) 22 23jiffies = jiffies_64; 24 25#define HYPERVISOR_TEXT \ 26 /* \ 27 * Align to 4 KB so that \ 28 * a) the HYP vector table is at its minimum \ 29 * alignment of 2048 bytes \ 30 * b) the HYP init code will not cross a page \ 31 * boundary if its size does not exceed \ 32 * 4 KB (see related ASSERT() below) \ 33 */ \ 34 . = ALIGN(SZ_4K); \ 35 VMLINUX_SYMBOL(__hyp_idmap_text_start) = .; \ 36 *(.hyp.idmap.text) \ 37 VMLINUX_SYMBOL(__hyp_idmap_text_end) = .; \ 38 VMLINUX_SYMBOL(__hyp_text_start) = .; \ 39 *(.hyp.text) \ 40 VMLINUX_SYMBOL(__hyp_text_end) = .; 41 42#define IDMAP_TEXT \ 43 . = ALIGN(SZ_4K); \ 44 VMLINUX_SYMBOL(__idmap_text_start) = .; \ 45 *(.idmap.text) \ 46 VMLINUX_SYMBOL(__idmap_text_end) = .; 47 48/* 49 * The size of the PE/COFF section that covers the kernel image, which 50 * runs from stext to _edata, must be a round multiple of the PE/COFF 51 * FileAlignment, which we set to its minimum value of 0x200. 'stext' 52 * itself is 4 KB aligned, so padding out _edata to a 0x200 aligned 53 * boundary should be sufficient. 54 */ 55PECOFF_FILE_ALIGNMENT = 0x200; 56 57#ifdef CONFIG_EFI 58#define PECOFF_EDATA_PADDING \ 59 .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); } 60#else 61#define PECOFF_EDATA_PADDING 62#endif 63 64#if defined(CONFIG_DEBUG_ALIGN_RODATA) 65#define ALIGN_DEBUG_RO . = ALIGN(1<<SECTION_SHIFT); 66#define ALIGN_DEBUG_RO_MIN(min) ALIGN_DEBUG_RO 67#elif defined(CONFIG_DEBUG_RODATA) 68#define ALIGN_DEBUG_RO . = ALIGN(1<<PAGE_SHIFT); 69#define ALIGN_DEBUG_RO_MIN(min) ALIGN_DEBUG_RO 70#else 71#define ALIGN_DEBUG_RO 72#define ALIGN_DEBUG_RO_MIN(min) . = ALIGN(min); 73#endif 74 75SECTIONS 76{ 77 /* 78 * XXX: The linker does not define how output sections are 79 * assigned to input sections when there are multiple statements 80 * matching the same input section name. There is no documented 81 * order of matching. 82 */ 83 /DISCARD/ : { 84 ARM_EXIT_DISCARD(EXIT_TEXT) 85 ARM_EXIT_DISCARD(EXIT_DATA) 86 EXIT_CALL 87 *(.discard) 88 *(.discard.*) 89 } 90 91 . = PAGE_OFFSET + TEXT_OFFSET; 92 93 .head.text : { 94 _text = .; 95 HEAD_TEXT 96 } 97 ALIGN_DEBUG_RO 98 .text : { /* Real text segment */ 99 _stext = .; /* Text and read-only data */ 100 __exception_text_start = .; 101 *(.exception.text) 102 __exception_text_end = .; 103 IRQENTRY_TEXT 104 TEXT_TEXT 105 SCHED_TEXT 106 LOCK_TEXT 107 HYPERVISOR_TEXT 108 IDMAP_TEXT 109 *(.fixup) 110 *(.gnu.warning) 111 . = ALIGN(16); 112 *(.got) /* Global offset table */ 113 } 114 115 ALIGN_DEBUG_RO 116 RO_DATA(PAGE_SIZE) 117 EXCEPTION_TABLE(8) 118 NOTES 119 ALIGN_DEBUG_RO 120 _etext = .; /* End of text and rodata section */ 121 122 ALIGN_DEBUG_RO_MIN(PAGE_SIZE) 123 __init_begin = .; 124 125 INIT_TEXT_SECTION(8) 126 .exit.text : { 127 ARM_EXIT_KEEP(EXIT_TEXT) 128 } 129 130 ALIGN_DEBUG_RO_MIN(16) 131 .init.data : { 132 INIT_DATA 133 INIT_SETUP(16) 134 INIT_CALLS 135 CON_INITCALL 136 SECURITY_INITCALL 137 INIT_RAM_FS 138 } 139 .exit.data : { 140 ARM_EXIT_KEEP(EXIT_DATA) 141 } 142 143 PERCPU_SECTION(64) 144 145 . = ALIGN(PAGE_SIZE); 146 __init_end = .; 147 148 . = ALIGN(4); 149 .altinstructions : { 150 __alt_instructions = .; 151 *(.altinstructions) 152 __alt_instructions_end = .; 153 } 154 .altinstr_replacement : { 155 *(.altinstr_replacement) 156 } 157 158 . = ALIGN(PAGE_SIZE); 159 _data = .; 160 _sdata = .; 161 RW_DATA_SECTION(64, PAGE_SIZE, THREAD_SIZE) 162 PECOFF_EDATA_PADDING 163 _edata = .; 164 165 BSS_SECTION(0, 0, 0) 166 167 . = ALIGN(PAGE_SIZE); 168 idmap_pg_dir = .; 169 . += IDMAP_DIR_SIZE; 170 swapper_pg_dir = .; 171 . += SWAPPER_DIR_SIZE; 172 173 _end = .; 174 175 STABS_DEBUG 176 177 HEAD_SYMBOLS 178} 179 180/* 181 * The HYP init code and ID map text can't be longer than a page each, 182 * and should not cross a page boundary. 183 */ 184ASSERT(__hyp_idmap_text_end - (__hyp_idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K, 185 "HYP init code too big or misaligned") 186ASSERT(__idmap_text_end - (__idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K, 187 "ID map text too big or misaligned") 188 189/* 190 * If padding is applied before .head.text, virt<->phys conversions will fail. 191 */ 192ASSERT(_text == (PAGE_OFFSET + TEXT_OFFSET), "HEAD is misaligned") 193