Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * Copyright (C) 2000 Russell King |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | */ |
Nicolas Pitre | 33656d5 | 2014-06-02 17:32:25 +0100 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | OUTPUT_ARCH(arm) |
| 16 | ENTRY(_start) |
| 17 | SECTIONS |
| 18 | { |
Catalin Marinas | bff595c | 2009-02-16 11:41:36 +0100 | [diff] [blame] | 19 | /DISCARD/ : { |
| 20 | *(.ARM.exidx*) |
| 21 | *(.ARM.extab*) |
Russell King | 5de813b | 2010-02-25 12:14:40 +0000 | [diff] [blame] | 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) |
Catalin Marinas | bff595c | 2009-02-16 11:41:36 +0100 | [diff] [blame] | 29 | } |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | . = TEXT_START; |
| 32 | _text = .; |
| 33 | |
| 34 | .text : { |
| 35 | _start = .; |
| 36 | *(.start) |
| 37 | *(.text) |
Russell King | c5b8ef6 | 2006-04-09 19:08:42 +0100 | [diff] [blame] | 38 | *(.text.*) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | *(.fixup) |
| 40 | *(.gnu.warning) |
Russell King | 3002b41 | 2011-05-26 11:40:54 +0100 | [diff] [blame] | 41 | *(.glue_7t) |
| 42 | *(.glue_7) |
| 43 | } |
Russell King | c772568 | 2017-09-21 18:10:19 +0100 | [diff] [blame] | 44 | .table : ALIGN(4) { |
| 45 | _table_start = .; |
| 46 | LONG(ZIMAGE_MAGIC(2)) |
| 47 | LONG(ZIMAGE_MAGIC(0x5a534c4b)) |
| 48 | LONG(ZIMAGE_MAGIC(__piggy_size_addr - _start)) |
| 49 | LONG(ZIMAGE_MAGIC(_kernel_bss_size)) |
| 50 | LONG(0) |
| 51 | _table_end = .; |
| 52 | } |
Russell King | 3002b41 | 2011-05-26 11:40:54 +0100 | [diff] [blame] | 53 | .rodata : { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | *(.rodata) |
| 55 | *(.rodata.*) |
Russell King | 55e7cff4 | 2017-10-23 12:39:32 +0100 | [diff] [blame] | 56 | *(.data.rel.ro) |
Russell King | 3002b41 | 2011-05-26 11:40:54 +0100 | [diff] [blame] | 57 | } |
| 58 | .piggydata : { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | *(.piggydata) |
Russell King | c772568 | 2017-09-21 18:10:19 +0100 | [diff] [blame] | 60 | __piggy_size_addr = . - 4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | } |
| 62 | |
Russell King | 3002b41 | 2011-05-26 11:40:54 +0100 | [diff] [blame] | 63 | . = ALIGN(4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | _etext = .; |
| 65 | |
Russell King | 3002b41 | 2011-05-26 11:40:54 +0100 | [diff] [blame] | 66 | .got.plt : { *(.got.plt) } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | _got_start = .; |
| 68 | .got : { *(.got) } |
| 69 | _got_end = .; |
Nicolas Pitre | 72bf0bc | 2011-05-27 22:25:26 -0400 | [diff] [blame] | 70 | |
| 71 | /* ensure the zImage file size is always a multiple of 64 bits */ |
| 72 | /* (without a dummy byte, ld just ignores the empty section) */ |
| 73 | .pad : { BYTE(0); . = ALIGN(8); } |
Ard Biesheuvel | e4bae4d | 2017-08-18 20:49:44 +0100 | [diff] [blame] | 74 | |
| 75 | #ifdef CONFIG_EFI_STUB |
| 76 | .data : ALIGN(4096) { |
| 77 | __pecoff_data_start = .; |
| 78 | /* |
| 79 | * The EFI stub always executes from RAM, and runs strictly before the |
| 80 | * decompressor, so we can make an exception for its r/w data, and keep it |
| 81 | */ |
| 82 | *(.data.efistub) |
| 83 | __pecoff_data_end = .; |
| 84 | |
| 85 | /* |
| 86 | * PE/COFF mandates a file size which is a multiple of 512 bytes if the |
| 87 | * section size equals or exceeds 4 KB |
| 88 | */ |
| 89 | . = ALIGN(512); |
| 90 | } |
| 91 | __pecoff_data_rawsize = . - ADDR(.data); |
| 92 | #endif |
| 93 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | _edata = .; |
| 95 | |
Russell King | dad46753 | 2017-11-01 19:18:13 +0000 | [diff] [blame] | 96 | /* |
| 97 | * The image_end section appears after any additional loadable sections |
| 98 | * that the linker may decide to insert in the binary image. Having |
| 99 | * this symbol allows further debug in the near future. |
| 100 | */ |
| 101 | .image_end (NOLOAD) : { |
Russell King | 55e7cff4 | 2017-10-23 12:39:32 +0100 | [diff] [blame] | 102 | /* |
| 103 | * EFI requires that the image is aligned to 512 bytes, and appended |
| 104 | * DTB requires that we know where the end of the image is. Ensure |
| 105 | * that both are satisfied by ensuring that there are no additional |
| 106 | * sections emitted into the decompressor image. |
| 107 | */ |
Russell King | dad46753 | 2017-11-01 19:18:13 +0000 | [diff] [blame] | 108 | _edata_real = .; |
| 109 | } |
| 110 | |
Nicolas Pitre | 33656d5 | 2014-06-02 17:32:25 +0100 | [diff] [blame] | 111 | _magic_sig = ZIMAGE_MAGIC(0x016f2818); |
| 112 | _magic_start = ZIMAGE_MAGIC(_start); |
| 113 | _magic_end = ZIMAGE_MAGIC(_edata); |
Russell King | c772568 | 2017-09-21 18:10:19 +0100 | [diff] [blame] | 114 | _magic_table = ZIMAGE_MAGIC(_table_start - _start); |
Nicolas Pitre | 33656d5 | 2014-06-02 17:32:25 +0100 | [diff] [blame] | 115 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | . = BSS_START; |
| 117 | __bss_start = .; |
| 118 | .bss : { *(.bss) } |
| 119 | _end = .; |
| 120 | |
Nicolas Pitre | 3bd2cbb | 2011-04-21 21:45:08 -0400 | [diff] [blame] | 121 | . = ALIGN(8); /* the stack must be 64-bit aligned */ |
Russell King | b0c4d4e | 2010-11-22 12:00:59 +0000 | [diff] [blame] | 122 | .stack : { *(.stack) } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | |
Ard Biesheuvel | e4bae4d | 2017-08-18 20:49:44 +0100 | [diff] [blame] | 124 | PROVIDE(__pecoff_data_size = ALIGN(512) - ADDR(.data)); |
| 125 | PROVIDE(__pecoff_end = ALIGN(512)); |
| 126 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | .stab 0 : { *(.stab) } |
| 128 | .stabstr 0 : { *(.stabstr) } |
| 129 | .stab.excl 0 : { *(.stab.excl) } |
| 130 | .stab.exclstr 0 : { *(.stab.exclstr) } |
| 131 | .stab.index 0 : { *(.stab.index) } |
| 132 | .stab.indexstr 0 : { *(.stab.indexstr) } |
| 133 | .comment 0 : { *(.comment) } |
| 134 | } |
Russell King | 55e7cff4 | 2017-10-23 12:39:32 +0100 | [diff] [blame] | 135 | ASSERT(_edata_real == _edata, "error: zImage file size is incorrect"); |