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