blob: 5d9d2dca530d97a7039789bf76efed5ea4e030a1 [file] [log] [blame]
Catalin Marinas8c2c3df2012-04-20 14:45:54 +01001/*
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 Abbottda141702015-01-21 17:36:06 -080011#include <asm/pgtable.h>
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010012
Mark Rutlanda2c1d732014-06-24 16:51:36 +010013#include "image.h"
14
Will Deacon07c802b2014-11-25 15:26:13 +000015/* .exit.text needed in case of alternative patching */
16#define ARM_EXIT_KEEP(x) x
17#define ARM_EXIT_DISCARD(x)
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010018
19OUTPUT_ARCH(aarch64)
Geoff Levandaf885f42014-05-16 18:26:01 +010020ENTRY(_text)
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010021
22jiffies = jiffies_64;
23
Marc Zyngier2240bbb2012-12-07 18:40:43 +000024#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 Biesheuvela352ea32014-10-10 18:42:55 +020037/*
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 */
44PECOFF_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 Abbottda141702015-01-21 17:36:06 -080053#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 Marinas8c2c3df2012-04-20 14:45:54 +010061SECTIONS
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 Abbottda141702015-01-21 17:36:06 -080083 ALIGN_DEBUG_RO
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010084 .text : { /* Real text segment */
85 _stext = .; /* Text and read-only data */
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010086 __exception_text_start = .;
87 *(.exception.text)
88 __exception_text_end = .;
89 IRQENTRY_TEXT
90 TEXT_TEXT
91 SCHED_TEXT
92 LOCK_TEXT
Marc Zyngier2240bbb2012-12-07 18:40:43 +000093 HYPERVISOR_TEXT
Catalin Marinas8c2c3df2012-04-20 14:45:54 +010094 *(.fixup)
95 *(.gnu.warning)
96 . = ALIGN(16);
97 *(.got) /* Global offset table */
98 }
99
Laura Abbottda141702015-01-21 17:36:06 -0800100 ALIGN_DEBUG_RO
Catalin Marinas8c2c3df2012-04-20 14:45:54 +0100101 RO_DATA(PAGE_SIZE)
Will Deaconadace892013-05-08 17:29:24 +0100102 EXCEPTION_TABLE(8)
Mark Salterc80b7ee2013-08-23 16:16:42 +0100103 NOTES
Laura Abbottda141702015-01-21 17:36:06 -0800104 ALIGN_DEBUG_RO
Catalin Marinas8c2c3df2012-04-20 14:45:54 +0100105 _etext = .; /* End of text and rodata section */
106
Laura Abbottda141702015-01-21 17:36:06 -0800107 ALIGN_DEBUG_RO_MIN(PAGE_SIZE)
Catalin Marinas8c2c3df2012-04-20 14:45:54 +0100108 __init_begin = .;
109
110 INIT_TEXT_SECTION(8)
111 .exit.text : {
112 ARM_EXIT_KEEP(EXIT_TEXT)
113 }
Laura Abbottda141702015-01-21 17:36:06 -0800114
115 ALIGN_DEBUG_RO_MIN(16)
Catalin Marinas8c2c3df2012-04-20 14:45:54 +0100116 .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 Wang562c85c2014-09-26 03:30:59 +0100130 . = ALIGN(PAGE_SIZE);
Catalin Marinas8c2c3df2012-04-20 14:45:54 +0100131 __init_end = .;
Catalin Marinas8c2c3df2012-04-20 14:45:54 +0100132
Andre Przywarae039ee42014-11-14 15:54:08 +0000133 . = 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 Salter3c620622013-11-04 16:38:47 +0000144 _data = .;
Mark Salter3c620622013-11-04 16:38:47 +0000145 _sdata = .;
146 RW_DATA_SECTION(64, PAGE_SIZE, THREAD_SIZE)
Ard Biesheuvela352ea32014-10-10 18:42:55 +0200147 PECOFF_EDATA_PADDING
Mark Salter3c620622013-11-04 16:38:47 +0000148 _edata = .;
Catalin Marinas8c2c3df2012-04-20 14:45:54 +0100149
Catalin Marinas8c2c3df2012-04-20 14:45:54 +0100150 BSS_SECTION(0, 0, 0)
Mark Rutlandbd00cd5f2014-06-24 16:51:35 +0100151
152 . = ALIGN(PAGE_SIZE);
153 idmap_pg_dir = .;
154 . += IDMAP_DIR_SIZE;
155 swapper_pg_dir = .;
156 . += SWAPPER_DIR_SIZE;
157
Catalin Marinas8c2c3df2012-04-20 14:45:54 +0100158 _end = .;
159
160 STABS_DEBUG
Mark Rutlanda2c1d732014-06-24 16:51:36 +0100161
162 HEAD_SYMBOLS
Catalin Marinas8c2c3df2012-04-20 14:45:54 +0100163}
Marc Zyngier2240bbb2012-12-07 18:40:43 +0000164
165/*
166 * The HYP init code can't be more than a page long.
167 */
168ASSERT(((__hyp_idmap_text_start + PAGE_SIZE) > __hyp_idmap_text_end),
169 "HYP init code too big")
Mark Rutlandda57a362014-06-24 16:51:37 +0100170
171/*
172 * If padding is applied before .head.text, virt<->phys conversions will fail.
173 */
174ASSERT(_text == (PAGE_OFFSET + TEXT_OFFSET), "HEAD is misaligned")