xref: /DragonStub/gnuefi/elf_riscv64_efi.lds (revision b3e80c38bcab002bef2b9e66b7037fbb1980e173)
1/* SPDX-License-Identifier: GPL-2.0+ OR BSD-2-Clause */
2
3OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv")
4OUTPUT_ARCH(riscv)
5ENTRY(_start)
6SECTIONS {
7.text 0x0 :
8	{
9		_text = .;
10		*(.text.head)
11		*(.text)
12		*(.text.*)
13		*(.gnu.linkonce.t.*)
14		. = ALIGN(16);
15	}
16	_etext = .;
17	_text_size = _etext - _text;
18. = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
19.dynamic  :
20	{ *(.dynamic) }
21.data :
22	ALIGN(4096)
23	{
24		_data = .;
25		*(.sdata)
26		*(.data)
27		*(.data1)
28		*(.data.*)
29		*(.got.plt)
30		*(.got)
31
32		/*
33		* Note that these aren't the using the GNU "CONSTRUCTOR" output section
34		* command, so they don't start with a size.  Because of p2align and the
35		* end/END definitions, and the fact that they're mergeable, they can also
36		* have NULLs which aren't guaranteed to be at the end.
37		*/
38		. = ALIGN(16);
39		__init_array_start = .;
40		*(SORT(.init_array.*))
41		*(.init_array)
42		__init_array_end = .;
43		. = ALIGN(16);
44		__CTOR_LIST__ = .;
45		*(SORT(.ctors.*))
46		*(.ctors)
47		__CTOR_END__ = .;
48		. = ALIGN(16);
49		__DTOR_LIST__ = .;
50		*(SORT(.dtors.*))
51		*(.dtors)
52		__DTOR_END__ = .;
53		. = ALIGN(16);
54		__fini_array_start = .;
55		*(SORT(.fini_array.*))
56		*(.fini_array)
57		__fini_array_end = .;
58
59
60		/* the EFI loader doesn't seem to like a .bss section, so we stick
61		   it all into .data: */
62		. = ALIGN(16);
63		_bss = .;
64		*(.sbss)
65		*(.scommon)
66		*(.dynbss)
67		*(.bss*)
68		*(COMMON)
69		. = ALIGN(16);
70		_bss_end = .;
71	}
72
73. = ALIGN(4096);
74.rela :
75  {
76    *(.rela.text*)
77    *(.rela.data*)
78    *(.rela.got)
79    *(.rela.dyn)
80    *(.rela.stab)
81    *(.rela.init_array*)
82    *(.rela.fini_array*)
83    *(.rela.ctors*)
84    *(.rela.dtors*)
85  }
86. = ALIGN(4096);
87.rela.plt : { *(.rela.plt) }
88. = ALIGN(4096);
89.rodata : { *(.rodata*) }
90	_edata = .;
91	_data_size = _edata - _data;
92
93	. = ALIGN(4096);
94.dynsym   :
95	{ *(.dynsym) }
96	. = ALIGN(4096);
97.dynstr   :
98	{ *(.dynstr) }
99	. = ALIGN(4096);
100.note.gnu.build-id :
101	{ *(.note.gnu.build-id) }
102. = DATA_SEGMENT_END (.);
103/DISCARD/ :
104	{
105		*(.rel.reloc)
106		*(.eh_frame)
107		*(.note.GNU-stack)
108	}
109.comment 0 :
110	{ *(.comment) }
111}
112