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