xref: /linux/arch/arm/boot/compressed/vmlinux.lds.S (revision ed0f941022515ff40473ea5335769a5dc2524a3f)
1d2912cb1SThomas Gleixner/* SPDX-License-Identifier: GPL-2.0-only */
2c79bf928SRussell King/*
3c79bf928SRussell King *  Copyright (C) 2000 Russell King
4c79bf928SRussell King */
57e8c4ed2SKees Cook#include <asm/vmlinux.lds.h>
6c79bf928SRussell King
7c79bf928SRussell King#ifdef CONFIG_CPU_ENDIAN_BE8
8c79bf928SRussell King#define ZIMAGE_MAGIC(x) ( (((x) >> 24) & 0x000000ff) | \
9c79bf928SRussell King			  (((x) >>  8) & 0x0000ff00) | \
10c79bf928SRussell King			  (((x) <<  8) & 0x00ff0000) | \
11c79bf928SRussell King			  (((x) << 24) & 0xff000000) )
12c79bf928SRussell King#else
13c79bf928SRussell King#define ZIMAGE_MAGIC(x) (x)
14c79bf928SRussell King#endif
15c79bf928SRussell King
16c79bf928SRussell KingOUTPUT_ARCH(arm)
17c79bf928SRussell KingENTRY(_start)
18c79bf928SRussell KingSECTIONS
19c79bf928SRussell King{
20c79bf928SRussell King  /DISCARD/ : {
217e8c4ed2SKees Cook    COMMON_DISCARDS
22c79bf928SRussell King    *(.ARM.exidx*)
23c79bf928SRussell King    *(.ARM.extab*)
247e8c4ed2SKees Cook    *(.note.*)
257e8c4ed2SKees Cook    *(.rel.*)
261b64daf4SKees Cook    *(.printk_index)
27c79bf928SRussell King    /*
28c79bf928SRussell King     * Discard any r/w data - this produces a link error if we have any,
29c79bf928SRussell King     * which is required for PIC decompression.  Local data generates
30c79bf928SRussell King     * GOTOFF relocations, which prevents it being relocated independently
31c79bf928SRussell King     * of the text/got segments.
32c79bf928SRussell King     */
33c79bf928SRussell King    *(.data)
34c79bf928SRussell King  }
35c79bf928SRussell King
36c79bf928SRussell King  . = TEXT_START;
37c79bf928SRussell King  _text = .;
38c79bf928SRussell King
39c79bf928SRussell King  .text : {
40c79bf928SRussell King    _start = .;
41c79bf928SRussell King    *(.start)
42c79bf928SRussell King    *(.text)
43c79bf928SRussell King    *(.text.*)
447e8c4ed2SKees Cook    ARM_STUBS_TEXT
45c79bf928SRussell King  }
46c7725687SRussell King  .table : ALIGN(4) {
47c7725687SRussell King    _table_start = .;
48adc5f702SRussell King    LONG(ZIMAGE_MAGIC(6))
49c7725687SRussell King    LONG(ZIMAGE_MAGIC(0x5a534c4b))
50c7725687SRussell King    LONG(ZIMAGE_MAGIC(__piggy_size_addr - _start))
51c7725687SRussell King    LONG(ZIMAGE_MAGIC(_kernel_bss_size))
5283dfeedbSRussell King    LONG(ZIMAGE_MAGIC(TEXT_OFFSET))
53adc5f702SRussell King    LONG(ZIMAGE_MAGIC(MALLOC_SIZE))
54c7725687SRussell King    LONG(0)
55c7725687SRussell King    _table_end = .;
56c7725687SRussell King  }
57c79bf928SRussell King  .rodata : {
58c79bf928SRussell King    *(.rodata)
59c79bf928SRussell King    *(.rodata.*)
6055e7cff4SRussell King    *(.data.rel.ro)
611b64daf4SKees Cook    *(.data.rel.ro.*)
62c79bf928SRussell King  }
63c79bf928SRussell King  .piggydata : {
64c79bf928SRussell King    *(.piggydata)
65c7725687SRussell King    __piggy_size_addr = . - 4;
66c79bf928SRussell King  }
67c79bf928SRussell King
68c79bf928SRussell King  . = ALIGN(4);
69c79bf928SRussell King  _etext = .;
70c79bf928SRussell King
71c79bf928SRussell King  .got.plt		: { *(.got.plt) }
7235d57d12SArd Biesheuvel#ifndef CONFIG_EFI_STUB
73c79bf928SRussell King  _got_start = .;
74c79bf928SRussell King  .got			: { *(.got) }
75c79bf928SRussell King  _got_end = .;
7635d57d12SArd Biesheuvel#endif
77c79bf928SRussell King
78c79bf928SRussell King  /* ensure the zImage file size is always a multiple of 64 bits */
79c79bf928SRussell King  /* (without a dummy byte, ld just ignores the empty section) */
80c79bf928SRussell King  .pad			: { BYTE(0); . = ALIGN(8); }
81e4bae4d0SArd Biesheuvel
82e4bae4d0SArd Biesheuvel#ifdef CONFIG_EFI_STUB
83e4bae4d0SArd Biesheuvel  .data : ALIGN(4096) {
84e4bae4d0SArd Biesheuvel    __pecoff_data_start = .;
8535d57d12SArd Biesheuvel    _got_start = .;
8635d57d12SArd Biesheuvel    *(.got)
8735d57d12SArd Biesheuvel    _got_end = .;
88e4bae4d0SArd Biesheuvel    /*
89e4bae4d0SArd Biesheuvel     * The EFI stub always executes from RAM, and runs strictly before the
90e4bae4d0SArd Biesheuvel     * decompressor, so we can make an exception for its r/w data, and keep it
91e4bae4d0SArd Biesheuvel     */
92420b6d00SArvind Sankar    *(.data.efistub .bss.efistub)
93e4bae4d0SArd Biesheuvel    __pecoff_data_end = .;
94e4bae4d0SArd Biesheuvel
95e4bae4d0SArd Biesheuvel    /*
96e4bae4d0SArd Biesheuvel     * PE/COFF mandates a file size which is a multiple of 512 bytes if the
97e4bae4d0SArd Biesheuvel     * section size equals or exceeds 4 KB
98e4bae4d0SArd Biesheuvel     */
99e4bae4d0SArd Biesheuvel    . = ALIGN(512);
100e4bae4d0SArd Biesheuvel  }
101e4bae4d0SArd Biesheuvel  __pecoff_data_rawsize = . - ADDR(.data);
102e4bae4d0SArd Biesheuvel#endif
103e4bae4d0SArd Biesheuvel
104c79bf928SRussell King  _edata = .;
105c79bf928SRussell King
106dad46753SRussell King  /*
107dad46753SRussell King   * The image_end section appears after any additional loadable sections
108dad46753SRussell King   * that the linker may decide to insert in the binary image.  Having
109dad46753SRussell King   * this symbol allows further debug in the near future.
110dad46753SRussell King   */
111dad46753SRussell King  .image_end (NOLOAD) : {
11255e7cff4SRussell King    /*
11355e7cff4SRussell King     * EFI requires that the image is aligned to 512 bytes, and appended
11455e7cff4SRussell King     * DTB requires that we know where the end of the image is.  Ensure
11555e7cff4SRussell King     * that both are satisfied by ensuring that there are no additional
11655e7cff4SRussell King     * sections emitted into the decompressor image.
11755e7cff4SRussell King     */
118dad46753SRussell King    _edata_real = .;
119dad46753SRussell King  }
120dad46753SRussell King
121c79bf928SRussell King  _magic_sig = ZIMAGE_MAGIC(0x016f2818);
122c79bf928SRussell King  _magic_start = ZIMAGE_MAGIC(_start);
123c79bf928SRussell King  _magic_end = ZIMAGE_MAGIC(_edata);
124c7725687SRussell King  _magic_table = ZIMAGE_MAGIC(_table_start - _start);
125c79bf928SRussell King
126c79bf928SRussell King  . = BSS_START;
127c79bf928SRussell King  __bss_start = .;
128*ed0f9410SYuntao Liu  .bss			: { *(.bss .bss.*) }
129c79bf928SRussell King  _end = .;
130c79bf928SRussell King
131c79bf928SRussell King  . = ALIGN(8);		/* the stack must be 64-bit aligned */
132c79bf928SRussell King  .stack		: { *(.stack) }
133c79bf928SRussell King
134e4bae4d0SArd Biesheuvel  PROVIDE(__pecoff_data_size = ALIGN(512) - ADDR(.data));
135e4bae4d0SArd Biesheuvel  PROVIDE(__pecoff_end = ALIGN(512));
136e4bae4d0SArd Biesheuvel
1377e8c4ed2SKees Cook  STABS_DEBUG
1387e8c4ed2SKees Cook  DWARF_DEBUG
1397e8c4ed2SKees Cook  ARM_DETAILS
1407e8c4ed2SKees Cook
1417e8c4ed2SKees Cook  ARM_ASSERTS
142c79bf928SRussell King}
14355e7cff4SRussell KingASSERT(_edata_real == _edata, "error: zImage file size is incorrect");
144