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