kern.ldscript revision 1.3
1/* Script for -n: mix text and data on same page */
2OUTPUT_FORMAT("elf64-littleriscv")
3OUTPUT_ARCH(riscv)
4ENTRY(_start)
5SECTIONS
6{
7  /* Read-only sections, merged into text segment: */
8  PROVIDE (__executable_start = SEGMENT_START("text-segment", 0xffffffff80000000)); . = SEGMENT_START("text-segment", 0xffffffff80000000) + SIZEOF_HEADERS;
9  .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
10  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
11  .rel.data.rel.ro   : { *(.rel.data.rel.ro .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*) }
12  .rela.data.rel.ro   : { *(.rela.data.rel.ro .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*) }
13  .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
14  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
15  .rel.tdata	  : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
16  .rela.tdata	  : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
17  .rel.tbss	  : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
18  .rela.tbss	  : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
19  .rel.sdata      : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) }
20  .rela.sdata     : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
21  .rel.sbss       : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) }
22  .rela.sbss      : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) }
23  .rel.sdata2     : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) }
24  .rela.sdata2    : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
25  .rel.sbss2      : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) }
26  .rela.sbss2     : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
27  .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
28  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
29  .text           :
30  {
31    _ftext = . ;
32    *(.text)
33    *(.text.unlikely .text.*_unlikely)
34    *(.text.exit .text.exit.*)
35    *(.text.startup .text.startup.*)
36    *(.text.hot .text.hot.*)
37    *(.stub .text.* .gnu.linkonce.t.*)
38  }
39  PROVIDE (__etext = .);
40  PROVIDE (_etext = .);
41  PROVIDE (etext = .);
42  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
43  .rodata1        : { *(.rodata1) }
44  .sdata2         :
45  {
46    *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
47  }
48  .sbss2          : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
49  .eh_frame_hdr : { *(.eh_frame_hdr) }
50  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
51  /* These sections are generated by the Sun/Oracle C++ compiler.  */
52  .exception_ranges   : ONLY_IF_RO { *(.exception_ranges
53  .exception_ranges*) }
54  /* Adjust the address for the data segment.  We want to adjust up to
55     the same address within the page on the next page up.  */
56  . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
57  /* Exception handling  */
58  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
59  .exception_ranges   : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
60  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
61  . = DATA_SEGMENT_RELRO_END (0, .);
62  .data           :
63  {
64    _fdata = . ;
65    *(.data .data.* .gnu.linkonce.d.*)
66    SORT(CONSTRUCTORS)
67  }
68  .data1          : { *(.data1) }
69  /* We want the small data sections together, so single-instruction offsets
70     can access them all, and initialized data all before uninitialized, so
71     we can shorten the on-disk segment size.  */
72  .sdata          :
73  {
74    /*_gp = . + 0x800;*/
75    *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata*)
76    *(.sdata .sdata.* .gnu.linkonce.s.*)
77  }
78  _edata = .; PROVIDE (edata = .);
79  . = .;
80  __bss_start = .;
81  _fbss = .;
82  .sbss           :
83  {
84    *(.dynsbss)
85    *(.sbss .sbss.* .gnu.linkonce.sb.*)
86    *(.scommon)
87  }
88  .bss            :
89  {
90    *(.dynbss)
91    *(.bss .bss.* .gnu.linkonce.b.*)
92    *(COMMON)
93    /* Align here to ensure that the .bss section occupies space up to
94       _end.  Align after .bss to ensure correct alignment even if the
95       .bss section disappears because there are no input sections.
96       FIXME: Why do we need it? When there is no .bss section, we don't
97       pad the .data section.  */
98    . = ALIGN(. != 0 ? 64 / 8 : 1);
99  }
100  . = ALIGN(64 / 8);
101  _end = .; PROVIDE (end = .);
102  . = DATA_SEGMENT_END (.);
103  /* Stabs debugging sections.  */
104  .stab          0 : { *(.stab) }
105  .stabstr       0 : { *(.stabstr) }
106  .stab.excl     0 : { *(.stab.excl) }
107  .stab.exclstr  0 : { *(.stab.exclstr) }
108  .stab.index    0 : { *(.stab.index) }
109  .stab.indexstr 0 : { *(.stab.indexstr) }
110  .comment       0 : { *(.comment) }
111  /* DWARF debug sections.
112     Symbols in the DWARF debugging sections are relative to the beginning
113     of the section so we begin them at 0.  */
114  /* DWARF 1 */
115  .debug          0 : { *(.debug) }
116  .line           0 : { *(.line) }
117  /* GNU DWARF 1 extensions */
118  .debug_srcinfo  0 : { *(.debug_srcinfo) }
119  .debug_sfnames  0 : { *(.debug_sfnames) }
120  /* DWARF 1.1 and DWARF 2 */
121  .debug_aranges  0 : { *(.debug_aranges) }
122  .debug_pubnames 0 : { *(.debug_pubnames) }
123  /* DWARF 2 */
124  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
125  .debug_abbrev   0 : { *(.debug_abbrev) }
126  .debug_line     0 : { *(.debug_line) }
127  .debug_frame    0 : { *(.debug_frame) }
128  .debug_str      0 : { *(.debug_str) }
129  .debug_loc      0 : { *(.debug_loc) }
130  .debug_macinfo  0 : { *(.debug_macinfo) }
131  /* SGI/MIPS DWARF 2 extensions */
132  .debug_weaknames 0 : { *(.debug_weaknames) }
133  .debug_funcnames 0 : { *(.debug_funcnames) }
134  .debug_typenames 0 : { *(.debug_typenames) }
135  .debug_varnames  0 : { *(.debug_varnames) }
136  /* DWARF 3 */
137  .debug_pubtypes 0 : { *(.debug_pubtypes) }
138  .debug_ranges   0 : { *(.debug_ranges) }
139  /* DWARF Extension.  */
140  .debug_macro    0 : { *(.debug_macro) }
141  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
142  .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
143  .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
144  /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
145}
146