Loading...
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2000 Russell King
4 */
5#include <asm/vmlinux.lds.h>
6
7#ifdef CONFIG_CPU_ENDIAN_BE8
8#define ZIMAGE_MAGIC(x) ( (((x) >> 24) & 0x000000ff) | \
9 (((x) >> 8) & 0x0000ff00) | \
10 (((x) << 8) & 0x00ff0000) | \
11 (((x) << 24) & 0xff000000) )
12#else
13#define ZIMAGE_MAGIC(x) (x)
14#endif
15
16OUTPUT_ARCH(arm)
17ENTRY(_start)
18SECTIONS
19{
20 /DISCARD/ : {
21 COMMON_DISCARDS
22 *(.ARM.exidx*)
23 *(.ARM.extab*)
24 *(.note.*)
25 *(.rel.*)
26 *(.printk_index)
27 /*
28 * Discard any r/w data - this produces a link error if we have any,
29 * which is required for PIC decompression. Local data generates
30 * GOTOFF relocations, which prevents it being relocated independently
31 * of the text/got segments.
32 */
33 *(.data)
34 }
35
36 . = TEXT_START;
37 _text = .;
38
39 .text : {
40 _start = .;
41 *(.start)
42 *(.text)
43 *(.text.*)
44 ARM_STUBS_TEXT
45 }
46 .table : ALIGN(4) {
47 _table_start = .;
48 LONG(ZIMAGE_MAGIC(6))
49 LONG(ZIMAGE_MAGIC(0x5a534c4b))
50 LONG(ZIMAGE_MAGIC(__piggy_size_addr - _start))
51 LONG(ZIMAGE_MAGIC(_kernel_bss_size))
52 LONG(ZIMAGE_MAGIC(TEXT_OFFSET))
53 LONG(ZIMAGE_MAGIC(MALLOC_SIZE))
54 LONG(0)
55 _table_end = .;
56 }
57 .rodata : {
58 *(.rodata)
59 *(.rodata.*)
60 *(.data.rel.ro)
61 *(.data.rel.ro.*)
62 }
63 .piggydata : {
64 *(.piggydata)
65 __piggy_size_addr = . - 4;
66 }
67
68 . = ALIGN(4);
69 _etext = .;
70
71 .got.plt : { *(.got.plt) }
72#ifndef CONFIG_EFI_STUB
73 _got_start = .;
74 .got : { *(.got) }
75 _got_end = .;
76#endif
77
78 /* ensure the zImage file size is always a multiple of 64 bits */
79 /* (without a dummy byte, ld just ignores the empty section) */
80 .pad : { BYTE(0); . = ALIGN(8); }
81
82#ifdef CONFIG_EFI_STUB
83 .data : ALIGN(4096) {
84 __pecoff_data_start = .;
85 _got_start = .;
86 *(.got)
87 _got_end = .;
88 /*
89 * The EFI stub always executes from RAM, and runs strictly before the
90 * decompressor, so we can make an exception for its r/w data, and keep it
91 */
92 *(.data.efistub .bss.efistub)
93 __pecoff_data_end = .;
94
95 /*
96 * PE/COFF mandates a file size which is a multiple of 512 bytes if the
97 * section size equals or exceeds 4 KB
98 */
99 . = ALIGN(512);
100 }
101 __pecoff_data_rawsize = . - ADDR(.data);
102#endif
103
104 _edata = .;
105
106 /*
107 * The image_end section appears after any additional loadable sections
108 * that the linker may decide to insert in the binary image. Having
109 * this symbol allows further debug in the near future.
110 */
111 .image_end (NOLOAD) : {
112 /*
113 * EFI requires that the image is aligned to 512 bytes, and appended
114 * DTB requires that we know where the end of the image is. Ensure
115 * that both are satisfied by ensuring that there are no additional
116 * sections emitted into the decompressor image.
117 */
118 _edata_real = .;
119 }
120
121 _magic_sig = ZIMAGE_MAGIC(0x016f2818);
122 _magic_start = ZIMAGE_MAGIC(_start);
123 _magic_end = ZIMAGE_MAGIC(_edata);
124 _magic_table = ZIMAGE_MAGIC(_table_start - _start);
125
126 . = BSS_START;
127 __bss_start = .;
128 .bss : { *(.bss .bss.*) }
129 _end = .;
130
131 . = ALIGN(8); /* the stack must be 64-bit aligned */
132 .stack : { *(.stack) }
133
134 PROVIDE(__pecoff_data_size = ALIGN(512) - ADDR(.data));
135 PROVIDE(__pecoff_end = ALIGN(512));
136
137 STABS_DEBUG
138 DWARF_DEBUG
139 ARM_DETAILS
140
141 ARM_ASSERTS
142}
143ASSERT(_edata_real == _edata, "error: zImage file size is incorrect");
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2000 Russell King
4 */
5
6#ifdef CONFIG_CPU_ENDIAN_BE8
7#define ZIMAGE_MAGIC(x) ( (((x) >> 24) & 0x000000ff) | \
8 (((x) >> 8) & 0x0000ff00) | \
9 (((x) << 8) & 0x00ff0000) | \
10 (((x) << 24) & 0xff000000) )
11#else
12#define ZIMAGE_MAGIC(x) (x)
13#endif
14
15OUTPUT_ARCH(arm)
16ENTRY(_start)
17SECTIONS
18{
19 /DISCARD/ : {
20 *(.ARM.exidx*)
21 *(.ARM.extab*)
22 /*
23 * Discard any r/w data - this produces a link error if we have any,
24 * which is required for PIC decompression. Local data generates
25 * GOTOFF relocations, which prevents it being relocated independently
26 * of the text/got segments.
27 */
28 *(.data)
29 }
30
31 . = TEXT_START;
32 _text = .;
33
34 .text : {
35 _start = .;
36 *(.start)
37 *(.text)
38 *(.text.*)
39 *(.gnu.warning)
40 *(.glue_7t)
41 *(.glue_7)
42 }
43 .table : ALIGN(4) {
44 _table_start = .;
45 LONG(ZIMAGE_MAGIC(4))
46 LONG(ZIMAGE_MAGIC(0x5a534c4b))
47 LONG(ZIMAGE_MAGIC(__piggy_size_addr - _start))
48 LONG(ZIMAGE_MAGIC(_kernel_bss_size))
49 LONG(0)
50 _table_end = .;
51 }
52 .rodata : {
53 *(.rodata)
54 *(.rodata.*)
55 *(.data.rel.ro)
56 }
57 .piggydata : {
58 *(.piggydata)
59 __piggy_size_addr = . - 4;
60 }
61
62 . = ALIGN(4);
63 _etext = .;
64
65 .got.plt : { *(.got.plt) }
66#ifndef CONFIG_EFI_STUB
67 _got_start = .;
68 .got : { *(.got) }
69 _got_end = .;
70#endif
71
72 /* ensure the zImage file size is always a multiple of 64 bits */
73 /* (without a dummy byte, ld just ignores the empty section) */
74 .pad : { BYTE(0); . = ALIGN(8); }
75
76#ifdef CONFIG_EFI_STUB
77 .data : ALIGN(4096) {
78 __pecoff_data_start = .;
79 _got_start = .;
80 *(.got)
81 _got_end = .;
82 /*
83 * The EFI stub always executes from RAM, and runs strictly before the
84 * decompressor, so we can make an exception for its r/w data, and keep it
85 */
86 *(.data.efistub .bss.efistub)
87 __pecoff_data_end = .;
88
89 /*
90 * PE/COFF mandates a file size which is a multiple of 512 bytes if the
91 * section size equals or exceeds 4 KB
92 */
93 . = ALIGN(512);
94 }
95 __pecoff_data_rawsize = . - ADDR(.data);
96#endif
97
98 _edata = .;
99
100 /*
101 * The image_end section appears after any additional loadable sections
102 * that the linker may decide to insert in the binary image. Having
103 * this symbol allows further debug in the near future.
104 */
105 .image_end (NOLOAD) : {
106 /*
107 * EFI requires that the image is aligned to 512 bytes, and appended
108 * DTB requires that we know where the end of the image is. Ensure
109 * that both are satisfied by ensuring that there are no additional
110 * sections emitted into the decompressor image.
111 */
112 _edata_real = .;
113 }
114
115 _magic_sig = ZIMAGE_MAGIC(0x016f2818);
116 _magic_start = ZIMAGE_MAGIC(_start);
117 _magic_end = ZIMAGE_MAGIC(_edata);
118 _magic_table = ZIMAGE_MAGIC(_table_start - _start);
119
120 . = BSS_START;
121 __bss_start = .;
122 .bss : { *(.bss) }
123 _end = .;
124
125 . = ALIGN(8); /* the stack must be 64-bit aligned */
126 .stack : { *(.stack) }
127
128 PROVIDE(__pecoff_data_size = ALIGN(512) - ADDR(.data));
129 PROVIDE(__pecoff_end = ALIGN(512));
130
131 .stab 0 : { *(.stab) }
132 .stabstr 0 : { *(.stabstr) }
133 .stab.excl 0 : { *(.stab.excl) }
134 .stab.exclstr 0 : { *(.stab.exclstr) }
135 .stab.index 0 : { *(.stab.index) }
136 .stab.indexstr 0 : { *(.stab.indexstr) }
137 .comment 0 : { *(.comment) }
138}
139ASSERT(_edata_real == _edata, "error: zImage file size is incorrect");