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