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