1+ /* SPDX-License-Identifier: GPL-2.0+ OR BSD-2-Clause */
2+
13OUTPUT_FORMAT (" elf64-littleriscv" , " elf64-littleriscv" , " elf64-littleriscv" )
24OUTPUT_ARCH(riscv)
35ENTRY(_start)
46SECTIONS
57{
6- .text 0x0 : {
8+ . = 0 ;
9+ ImageBase = .;
10+ /* .hash and/or .gnu.hash MUST come first! */
11+ .hash : { *(.hash ) }
12+ .gnu.hash : { *(.gnu .hash ) }
13+ . = ALIGN (4096 );
14+ .eh_frame : { *(.eh_frame ) }
15+ .eh_frame_hdr : { *(.eh_frame_hdr ) }
16+ .gcc_except_table : { *(.gcc_except_table *) }
17+ . = ALIGN (4096 );
18+ .text : {
719 _text = .;
8- *(.text .head )
920 *(.text )
1021 *(.text .*)
1122 *(.gnu .linkonce .t .*)
12- _evtext = .;
13- . = ALIGN (4096 );
23+ *(. plt )
24+ . = ALIGN (16 );
1425 }
1526 _etext = .;
16- _text_size = . - _text;
17- _text_vsize = _evtext - _text;
18-
27+ _text_size = _etext - _text;
28+ . = ALIGN (65536 );
29+ .reloc :
30+ {
31+ KEEP (*(.reloc ))
32+ }
33+ . = ALIGN (4096 );
34+ .dynamic : { *(.dynamic ) }
1935 . = ALIGN (4096 );
2036 .data :
2137 {
@@ -27,7 +43,32 @@ SECTIONS
2743 *(.got .plt )
2844 *(.got )
2945
30- *(.dynamic )
46+ /*
47+ * Note that these aren't the using the GNU "CONSTRUCTOR" output section
48+ * command, so they don't start with a size. Because of p2align and the
49+ * end/END definitions, and the fact that they're mergeable, they can also
50+ * have NULLs which aren't guaranteed to be at the end.
51+ */
52+ . = ALIGN (16 );
53+ __init_array_start = .;
54+ *(SORT (.init_array .*))
55+ *(.init_array )
56+ __init_array_end = .;
57+ . = ALIGN (16 );
58+ __CTOR_LIST__ = .;
59+ *(SORT (.ctors .*))
60+ *(.ctors )
61+ __CTOR_END__ = .;
62+ . = ALIGN (16 );
63+ __DTOR_LIST__ = .;
64+ *(SORT (.dtors .*))
65+ *(.dtors )
66+ __DTOR_END__ = .;
67+ . = ALIGN (16 );
68+ __fini_array_start = .;
69+ *(SORT (.fini_array .*))
70+ *(.fini_array )
71+ __fini_array_end = .;
3172
3273 /* the EFI loader doesn't seem to like a .bss section, so we stick
3374 it all into .data: */
@@ -36,23 +77,36 @@ SECTIONS
3677 *(.sbss )
3778 *(.scommon )
3879 *(.dynbss )
39- *(.bss )
80+ *(.bss * )
4081 *(COMMON)
41- _evdata = .;
42- . = ALIGN (4096 );
82+ *(.rel .local )
83+ . = ALIGN (16 );
84+
4385 _bss_end = .;
4486 }
87+
88+ . = ALIGN (4096 );
89+ .rela :
90+ {
91+ *(.rela .text *)
92+ *(.rela .data *)
93+ *(.rela .got )
94+ *(.rela .dyn )
95+ *(.rela .stab )
96+ *(.rela .init_array *)
97+ *(.rela .fini_array *)
98+ *(.rela .ctors *)
99+ *(.rela .dtors *)
100+
101+ }
102+ . = ALIGN (4096 );
103+ .rela.plt : { *(.rela .plt ) }
104+ . = ALIGN (4096 );
105+ .rodata : { *(.rodata *) }
106+ . = ALIGN (512 );
45107 _edata = .;
46- _data_vsize = _evdata - _data;
47- _data_size = . - _data;
108+ _data_size = _edata - _data;
48109
49- /*
50- * Note that _sbat must be the beginning of the data, and _esbat must be the
51- * end and must be before any section padding. The sbat self-check uses
52- * _esbat to find the bounds of the data, and if the padding is included, the
53- * CSV parser (correctly) rejects the data as having NUL values in one of the
54- * required columns.
55- */
56110 . = ALIGN (4096 );
57111 .sbat :
58112 {
@@ -67,44 +121,14 @@ SECTIONS
67121 _sbat_vsize = _esbat - _sbat;
68122
69123 . = ALIGN (4096 );
70- .rodata :
71- {
72- _rodata = .;
73- *(.rodata *)
74- *(.srodata )
75- . = ALIGN (16 );
76- *(.note .gnu .build -id)
77- . = ALIGN (4096 );
78- *(.vendor_cert )
79- *(.data .ident )
80- . = ALIGN (4096 );
81- }
124+ .dynsym : { *(.dynsym ) }
82125 . = ALIGN (4096 );
83- .rela :
84- {
85- *(.rela .dyn )
86- *(.rela .plt )
87- *(.rela .got )
88- *(.rela .data )
89- *(.rela .data *)
90- }
126+ .dynstr : { *(.dynstr ) }
91127 . = ALIGN (4096 );
92- .dyn :
93- {
94- *(.dynsym )
95- *(.dynstr )
96- _evrodata = .;
97- . = ALIGN (4096 );
98- }
99- _erodata = .;
100- _rodata_size = . - _rodata;
101- _rodata_vsize = _evrodata - _rodata;
102- _alldata_size = . - _data;
103-
104- /DISCARD/ :
128+ .note.gnu.build-id : { *(.note .gnu .build -id) }
129+ .ignored.reloc :
105130 {
106- *(.rel .reloc )
107- *(.eh_frame )
131+ *(.rela .reloc )
108132 *(.note .GNU -stack)
109133 }
110134 .comment 0 : { *(.comment ) }
0 commit comments