1+ /* SPDX-License-Identifier: GPL-2.0-or-later 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+ _DYNAMIC = .;
30+ .dynamic : { *(.dynamic ) }
1931 . = ALIGN (4096 );
2032 .data :
2133 {
@@ -27,7 +39,32 @@ SECTIONS
2739 *(.got .plt )
2840 *(.got )
2941
30- *(.dynamic )
42+ /*
43+ * Note that these aren't the using the GNU "CONSTRUCTOR" output section
44+ * command, so they don't start with a size. Because of p2align and the
45+ * end/END definitions, and the fact that they're mergeable, they can also
46+ * have NULLs which aren't guaranteed to be at the end.
47+ */
48+ . = ALIGN (16 );
49+ __init_array_start = .;
50+ *(SORT (.init_array .*))
51+ *(.init_array )
52+ __init_array_end = .;
53+ . = ALIGN (16 );
54+ __CTOR_LIST__ = .;
55+ *(SORT (.ctors .*))
56+ *(.ctors )
57+ __CTOR_END__ = .;
58+ . = ALIGN (16 );
59+ __DTOR_LIST__ = .;
60+ *(SORT (.dtors .*))
61+ *(.dtors )
62+ __DTOR_END__ = .;
63+ . = ALIGN (16 );
64+ __fini_array_start = .;
65+ *(SORT (.fini_array .*))
66+ *(.fini_array )
67+ __fini_array_end = .;
3168
3269 /* the EFI loader doesn't seem to like a .bss section, so we stick
3370 it all into .data: */
@@ -36,23 +73,41 @@ SECTIONS
3673 *(.sbss )
3774 *(.scommon )
3875 *(.dynbss )
39- *(.bss )
76+ *(.bss * )
4077 *(COMMON )
41- _evdata = .;
42- . = ALIGN (4096 );
78+ *(.rel .local )
79+ . = ALIGN (16 );
80+
4381 _bss_end = .;
4482 }
83+ . = ALIGN (4096 );
84+ .reloc :
85+ {
86+ KEEP (*(.reloc ))
87+ }
88+
89+ . = ALIGN (4096 );
90+ .rela :
91+ {
92+ *(.rela .text *)
93+ *(.rela .data *)
94+ *(.rela .got )
95+ *(.rela .dyn )
96+ *(.rela .stab )
97+ *(.rela .init_array *)
98+ *(.rela .fini_array *)
99+ *(.rela .ctors *)
100+ *(.rela .dtors *)
101+
102+ }
103+ . = ALIGN (4096 );
104+ .rela.plt : { *(.rela .plt ) }
105+ . = ALIGN (4096 );
106+ .rodata : { *(.rodata *) }
107+ . = ALIGN (512 );
45108 _edata = .;
46- _data_vsize = _evdata - _data;
47- _data_size = . - _data;
109+ _data_size = _edata - _data;
48110
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- */
56111 . = ALIGN (4096 );
57112 .sbat :
58113 {
@@ -67,44 +122,14 @@ SECTIONS
67122 _sbat_vsize = _esbat - _sbat;
68123
69124 . = 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- }
125+ .dynsym : { *(.dynsym ) }
82126 . = ALIGN (4096 );
83- .rela :
84- {
85- *(.rela .dyn )
86- *(.rela .plt )
87- *(.rela .got )
88- *(.rela .data )
89- *(.rela .data *)
90- }
127+ .dynstr : { *(.dynstr ) }
91128 . = 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/ :
129+ .note.gnu.build-id : { *(.note .gnu .build -id) }
130+ .ignored.reloc :
105131 {
106- *(.rel .reloc )
107- *(.eh_frame )
132+ *(.rela .reloc )
108133 *(.note .GNU -stack)
109134 }
110135 .comment 0 : { *(.comment ) }
0 commit comments