xref: /DragonStub/gnuefi/elf_riscv64_efi.lds (revision 58dce6991b675f6ad063bbb5a362817ba5ba55a0)
10f9c15feSbmeng@tinylab.org/* SPDX-License-Identifier: GPL-2.0+ OR BSD-2-Clause */
2b95f138fSHeinrich Schuchardt
3b95f138fSHeinrich SchuchardtOUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv")
4b95f138fSHeinrich SchuchardtOUTPUT_ARCH(riscv)
5b95f138fSHeinrich SchuchardtENTRY(_start)
6*58dce699SCallum FarmerSECTIONS
7b95f138fSHeinrich Schuchardt{
8*58dce699SCallum Farmer  .text 0 : {
9b95f138fSHeinrich Schuchardt    *(.text.head)
10*58dce699SCallum Farmer    . = ALIGN(4096);
11*58dce699SCallum Farmer    _text = .;
12b95f138fSHeinrich Schuchardt    *(.text)
13b95f138fSHeinrich Schuchardt    *(.text.*)
14b95f138fSHeinrich Schuchardt    *(.gnu.linkonce.t.*)
158abf159dSCallum Farmer    *(.plt)
16b95f138fSHeinrich Schuchardt    . = ALIGN(16);
17*58dce699SCallum Farmer    _evtext = .;
18*58dce699SCallum Farmer    . = ALIGN(4096);
19b95f138fSHeinrich Schuchardt    _etext = .;
20*58dce699SCallum Farmer  } =0
21*58dce699SCallum Farmer  _text_vsize = _evtext - _text;
2220110935SCallum Farmer  _text_size = _etext - _text;
23*58dce699SCallum Farmer  . = ALIGN(4096);
24*58dce699SCallum Farmer  _reloc = .;
25*58dce699SCallum Farmer  .reloc : {
26*58dce699SCallum Farmer    *(.reloc)
27*58dce699SCallum Farmer    _evreloc = .;
28*58dce699SCallum Farmer    . = ALIGN(4096);
29*58dce699SCallum Farmer    _ereloc = .;
30*58dce699SCallum Farmer  } =0
31*58dce699SCallum Farmer  _reloc_vsize = _evreloc - _reloc;
32*58dce699SCallum Farmer  _reloc_size = _ereloc - _reloc;
33*58dce699SCallum Farmer  . = ALIGN(4096);
34b95f138fSHeinrich Schuchardt  _data = .;
35*58dce699SCallum Farmer  .dynamic  : { *(.dynamic) }
36*58dce699SCallum Farmer  . = ALIGN(4096);
37*58dce699SCallum Farmer  .data :
38*58dce699SCallum Farmer  {
39b95f138fSHeinrich Schuchardt   *(.sdata)
40b95f138fSHeinrich Schuchardt   *(.data)
41b95f138fSHeinrich Schuchardt   *(.data1)
42b95f138fSHeinrich Schuchardt   *(.data.*)
43b95f138fSHeinrich Schuchardt   *(.got.plt)
44b95f138fSHeinrich Schuchardt   *(.got)
45b95f138fSHeinrich Schuchardt
46d8e6b531SCallum Farmer   /*
47d8e6b531SCallum Farmer    * Note that these aren't the using the GNU "CONSTRUCTOR" output section
48d8e6b531SCallum Farmer    * command, so they don't start with a size.  Because of p2align and the
49d8e6b531SCallum Farmer    * end/END definitions, and the fact that they're mergeable, they can also
50d8e6b531SCallum Farmer    * have NULLs which aren't guaranteed to be at the end.
51d8e6b531SCallum Farmer    */
52d8e6b531SCallum Farmer   . = ALIGN(16);
53d8e6b531SCallum Farmer   __init_array_start = .;
54d8e6b531SCallum Farmer   *(SORT(.init_array.*))
55d8e6b531SCallum Farmer   *(.init_array)
56d8e6b531SCallum Farmer   __init_array_end = .;
57d8e6b531SCallum Farmer  . = ALIGN(16);
58d8e6b531SCallum Farmer   __CTOR_LIST__ = .;
59d8e6b531SCallum Farmer   *(SORT(.ctors.*))
60d8e6b531SCallum Farmer   *(.ctors)
61d8e6b531SCallum Farmer   __CTOR_END__ = .;
62d8e6b531SCallum Farmer  . = ALIGN(16);
63d8e6b531SCallum Farmer   __DTOR_LIST__ = .;
64d8e6b531SCallum Farmer   *(SORT(.dtors.*))
65d8e6b531SCallum Farmer   *(.dtors)
66d8e6b531SCallum Farmer   __DTOR_END__ = .;
67d8e6b531SCallum Farmer   . = ALIGN(16);
68d8e6b531SCallum Farmer   __fini_array_start = .;
69d8e6b531SCallum Farmer   *(SORT(.fini_array.*))
70d8e6b531SCallum Farmer   *(.fini_array)
71d8e6b531SCallum Farmer   __fini_array_end = .;
72d8e6b531SCallum Farmer
73b95f138fSHeinrich Schuchardt   /* the EFI loader doesn't seem to like a .bss section, so we stick
74b95f138fSHeinrich Schuchardt      it all into .data: */
75b95f138fSHeinrich Schuchardt   . = ALIGN(16);
76b95f138fSHeinrich Schuchardt   _bss = .;
77b95f138fSHeinrich Schuchardt   *(.sbss)
78b95f138fSHeinrich Schuchardt   *(.scommon)
79b95f138fSHeinrich Schuchardt   *(.dynbss)
80*58dce699SCallum Farmer   *(.bss)
81*58dce699SCallum Farmer   *(.bss.*)
82b95f138fSHeinrich Schuchardt   *(COMMON)
83b95f138fSHeinrich Schuchardt   . = ALIGN(16);
84b95f138fSHeinrich Schuchardt   _bss_end = .;
85*58dce699SCallum Farmer   _evdata = .;
86*58dce699SCallum Farmer   . = ALIGN(4096);
87*58dce699SCallum Farmer   _edata = .;
88*58dce699SCallum Farmer  } =0
89*58dce699SCallum Farmer  _data_vsize = _evdata - _data;
90*58dce699SCallum Farmer  _data_size = _edata - _data;
91b95f138fSHeinrich Schuchardt
927ad75d91SCallum Farmer  . = ALIGN(4096);
93*58dce699SCallum Farmer  _rodata = .;
94eea6d31aSCallum Farmer  .rela :
95eea6d31aSCallum Farmer  {
96eea6d31aSCallum Farmer    *(.rela.text*)
97eea6d31aSCallum Farmer    *(.rela.data*)
98eea6d31aSCallum Farmer    *(.rela.got)
9902f96e8aSCallum Farmer    *(.rela.dyn)
100eea6d31aSCallum Farmer    *(.rela.stab)
101d8e6b531SCallum Farmer    *(.rela.init_array*)
102d8e6b531SCallum Farmer    *(.rela.fini_array*)
103d8e6b531SCallum Farmer    *(.rela.ctors*)
104d8e6b531SCallum Farmer    *(.rela.dtors*)
105*58dce699SCallum Farmer
106eea6d31aSCallum Farmer  }
1071a10c661SCallum Farmer  . = ALIGN(4096);
1081a10c661SCallum Farmer  .rela.plt : { *(.rela.plt) }
109b3e80c38SCallum Farmer  . = ALIGN(4096);
110*58dce699SCallum Farmer  .rodata : {
111*58dce699SCallum Farmer    *(.rodata*)
112*58dce699SCallum Farmer    _evrodata = .;
113*58dce699SCallum Farmer    . = ALIGN(4096);
114*58dce699SCallum Farmer    _erodata = .;
115*58dce699SCallum Farmer  } =0
116*58dce699SCallum Farmer  _rodata_vsize = _evrodata - _rodata;
117*58dce699SCallum Farmer  _rodata_size = _erodata - _rodata;
118*58dce699SCallum Farmer  _image_end = .;
119*58dce699SCallum Farmer  _alldata_size = _image_end - _reloc;
120b95f138fSHeinrich Schuchardt
121b95f138fSHeinrich Schuchardt  . = ALIGN(4096);
122*58dce699SCallum Farmer  .dynsym   : { *(.dynsym) }
123b95f138fSHeinrich Schuchardt  . = ALIGN(4096);
124*58dce699SCallum Farmer  .dynstr   : { *(.dynstr) }
125b95f138fSHeinrich Schuchardt  . = ALIGN(4096);
126*58dce699SCallum Farmer  .note.gnu.build-id : { *(.note.gnu.build-id) }
127*58dce699SCallum Farmer  . = ALIGN(4096);
128*58dce699SCallum Farmer  .hash : { *(.hash) }
129*58dce699SCallum Farmer  . = ALIGN(4096);
130*58dce699SCallum Farmer  .gnu.hash : { *(.gnu.hash) }
131*58dce699SCallum Farmer  . = ALIGN(4096);
132*58dce699SCallum Farmer  .eh_frame : { *(.eh_frame) }
133*58dce699SCallum Farmer  . = ALIGN(4096);
134*58dce699SCallum Farmer  .gcc_except_table : { *(.gcc_except_table*) }
135b95f138fSHeinrich Schuchardt  /DISCARD/ :
136b95f138fSHeinrich Schuchardt  {
137*58dce699SCallum Farmer    *(.rela.reloc)
138b95f138fSHeinrich Schuchardt    *(.note.GNU-stack)
139b95f138fSHeinrich Schuchardt  }
140*58dce699SCallum Farmer  .comment 0 : { *(.comment) }
141b95f138fSHeinrich Schuchardt}
142*58dce699SCallum Farmer
143