1/* SPDX-License-Identifier: GPL-2.0 */
2#include <asm-generic/vmlinux.lds.h>
3
4OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT)
5
6#undef i386
7
8#include <asm/cache.h>
9#include <asm/page_types.h>
10
11#ifdef CONFIG_X86_64
12OUTPUT_ARCH(i386:x86-64)
13ENTRY(startup_64)
14#else
15OUTPUT_ARCH(i386)
16ENTRY(startup_32)
17#endif
18
19SECTIONS
20{
21	/* Be careful parts of head_64.S assume startup_32 is at
22	 * address 0.
23	 */
24	. = 0;
25	.head.text : {
26		_head = . ;
27		HEAD_TEXT
28		_ehead = . ;
29	}
30	.rodata..compressed : {
31		*(.rodata..compressed)
32	}
33	.text :	{
34		_text = .; 	/* Text */
35		*(.text)
36		*(.text.*)
37		*(.noinstr.text)
38		_etext = . ;
39	}
40	.rodata : {
41		_rodata = . ;
42		*(.rodata)	 /* read-only data */
43		*(.rodata.*)
44		_erodata = . ;
45	}
46	.data :	{
47		_data = . ;
48		*(.data)
49		*(.data.*)
50		*(.bss.efistub)
51		_edata = . ;
52	}
53	. = ALIGN(L1_CACHE_BYTES);
54	.bss : {
55		_bss = . ;
56		*(.bss)
57		*(.bss.*)
58		*(COMMON)
59		. = ALIGN(8);	/* For convenience during zeroing */
60		_ebss = .;
61	}
62#ifdef CONFIG_X86_64
63       . = ALIGN(PAGE_SIZE);
64       .pgtable : {
65		_pgtable = . ;
66		*(.pgtable)
67		_epgtable = . ;
68	}
69#endif
70	. = ALIGN(PAGE_SIZE);	/* keep ZO size page aligned */
71	_end = .;
72
73	STABS_DEBUG
74	DWARF_DEBUG
75	ELF_DETAILS
76
77	DISCARDS
78	/DISCARD/ : {
79		*(.dynamic) *(.dynsym) *(.dynstr) *(.dynbss)
80		*(.hash) *(.gnu.hash)
81		*(.note.*)
82	}
83
84	.got.plt (INFO) : {
85		*(.got.plt)
86	}
87	ASSERT(SIZEOF(.got.plt) == 0 ||
88#ifdef CONFIG_X86_64
89	       SIZEOF(.got.plt) == 0x18,
90#else
91	       SIZEOF(.got.plt) == 0xc,
92#endif
93	       "Unexpected GOT/PLT entries detected!")
94
95	/*
96	 * Sections that should stay zero sized, which is safer to
97	 * explicitly check instead of blindly discarding.
98	 */
99	.got : {
100		*(.got)
101	}
102	ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!")
103
104	.plt : {
105		*(.plt) *(.plt.*)
106	}
107	ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!")
108
109	.rel.dyn : {
110		*(.rel.*) *(.rel_*)
111	}
112	ASSERT(SIZEOF(.rel.dyn) == 0, "Unexpected run-time relocations (.rel) detected!")
113
114	.rela.dyn : {
115		*(.rela.*) *(.rela_*)
116	}
117	ASSERT(SIZEOF(.rela.dyn) == 0, "Unexpected run-time relocations (.rela) detected!")
118}
119