blob: b38dcef907560beff1bfe77b31fba470cef13511 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Copyright (C) 2000 Russell King
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
Nicolas Pitre33656d52014-06-02 17:32:25 +01008
9#ifdef CONFIG_CPU_ENDIAN_BE8
10#define ZIMAGE_MAGIC(x) ( (((x) >> 24) & 0x000000ff) | \
11 (((x) >> 8) & 0x0000ff00) | \
12 (((x) << 8) & 0x00ff0000) | \
13 (((x) << 24) & 0xff000000) )
14#else
15#define ZIMAGE_MAGIC(x) (x)
16#endif
17
Linus Torvalds1da177e2005-04-16 15:20:36 -070018OUTPUT_ARCH(arm)
19ENTRY(_start)
20SECTIONS
21{
Catalin Marinasbff595c2009-02-16 11:41:36 +010022 /DISCARD/ : {
23 *(.ARM.exidx*)
24 *(.ARM.extab*)
Russell King5de813b2010-02-25 12:14:40 +000025 /*
26 * Discard any r/w data - this produces a link error if we have any,
27 * which is required for PIC decompression. Local data generates
28 * GOTOFF relocations, which prevents it being relocated independently
29 * of the text/got segments.
30 */
31 *(.data)
Catalin Marinasbff595c2009-02-16 11:41:36 +010032 }
33
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 . = TEXT_START;
35 _text = .;
36
37 .text : {
38 _start = .;
39 *(.start)
40 *(.text)
Russell Kingc5b8ef62006-04-09 19:08:42 +010041 *(.text.*)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 *(.fixup)
43 *(.gnu.warning)
Russell King3002b412011-05-26 11:40:54 +010044 *(.glue_7t)
45 *(.glue_7)
46 }
Russell Kingc7725682017-09-21 18:10:19 +010047 .table : ALIGN(4) {
48 _table_start = .;
49 LONG(ZIMAGE_MAGIC(2))
50 LONG(ZIMAGE_MAGIC(0x5a534c4b))
51 LONG(ZIMAGE_MAGIC(__piggy_size_addr - _start))
52 LONG(ZIMAGE_MAGIC(_kernel_bss_size))
53 LONG(0)
54 _table_end = .;
55 }
Russell King3002b412011-05-26 11:40:54 +010056 .rodata : {
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 *(.rodata)
58 *(.rodata.*)
Russell King3002b412011-05-26 11:40:54 +010059 }
60 .piggydata : {
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 *(.piggydata)
Russell Kingc7725682017-09-21 18:10:19 +010062 __piggy_size_addr = . - 4;
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 }
64
Russell King3002b412011-05-26 11:40:54 +010065 . = ALIGN(4);
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 _etext = .;
67
Russell King3002b412011-05-26 11:40:54 +010068 .got.plt : { *(.got.plt) }
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 _got_start = .;
70 .got : { *(.got) }
71 _got_end = .;
Nicolas Pitre72bf0bc2011-05-27 22:25:26 -040072
73 /* ensure the zImage file size is always a multiple of 64 bits */
74 /* (without a dummy byte, ld just ignores the empty section) */
75 .pad : { BYTE(0); . = ALIGN(8); }
Ard Biesheuvele4bae4d2017-08-18 20:49:44 +010076
77#ifdef CONFIG_EFI_STUB
78 .data : ALIGN(4096) {
79 __pecoff_data_start = .;
80 /*
81 * The EFI stub always executes from RAM, and runs strictly before the
82 * decompressor, so we can make an exception for its r/w data, and keep it
83 */
84 *(.data.efistub)
85 __pecoff_data_end = .;
86
87 /*
88 * PE/COFF mandates a file size which is a multiple of 512 bytes if the
89 * section size equals or exceeds 4 KB
90 */
91 . = ALIGN(512);
92 }
93 __pecoff_data_rawsize = . - ADDR(.data);
94#endif
95
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 _edata = .;
97
Nicolas Pitre33656d52014-06-02 17:32:25 +010098 _magic_sig = ZIMAGE_MAGIC(0x016f2818);
99 _magic_start = ZIMAGE_MAGIC(_start);
100 _magic_end = ZIMAGE_MAGIC(_edata);
Russell Kingc7725682017-09-21 18:10:19 +0100101 _magic_table = ZIMAGE_MAGIC(_table_start - _start);
Nicolas Pitre33656d52014-06-02 17:32:25 +0100102
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 . = BSS_START;
104 __bss_start = .;
105 .bss : { *(.bss) }
106 _end = .;
107
Nicolas Pitre3bd2cbb2011-04-21 21:45:08 -0400108 . = ALIGN(8); /* the stack must be 64-bit aligned */
Russell Kingb0c4d4e2010-11-22 12:00:59 +0000109 .stack : { *(.stack) }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110
Ard Biesheuvele4bae4d2017-08-18 20:49:44 +0100111 PROVIDE(__pecoff_data_size = ALIGN(512) - ADDR(.data));
112 PROVIDE(__pecoff_end = ALIGN(512));
113
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 .stab 0 : { *(.stab) }
115 .stabstr 0 : { *(.stabstr) }
116 .stab.excl 0 : { *(.stab.excl) }
117 .stab.exclstr 0 : { *(.stab.exclstr) }
118 .stab.index 0 : { *(.stab.index) }
119 .stab.indexstr 0 : { *(.stab.indexstr) }
120 .comment 0 : { *(.comment) }
121}