kern.ldscript revision 1.1
11.1Smatt/* Script for -n: mix text and data on same page */
21.1SmattOUTPUT_FORMAT("elf64-littleriscv")
31.1SmattOUTPUT_ARCH(riscv)
41.1SmattENTRY(_start)
51.1SmattSEARCH_DIR("/lib");
61.1SmattSECTIONS
71.1Smatt{
81.1Smatt  /* Read-only sections, merged into text segment: */
91.1Smatt  PROVIDE (__executable_start = SEGMENT_START("text-segment", 0xffffffff80000000)); . = SEGMENT_START("text-segment", 0xffffffff80000000) + SIZEOF_HEADERS;
101.1Smatt  .rel.rodata     : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
111.1Smatt  .rela.rodata    : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
121.1Smatt  .rel.data.rel.ro   : { *(.rel.data.rel.ro .rel.data.rel.ro.* .rel.gnu.linkonce.d.rel.ro.*) }
131.1Smatt  .rela.data.rel.ro   : { *(.rela.data.rel.ro .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*) }
141.1Smatt  .rel.data       : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
151.1Smatt  .rela.data      : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
161.1Smatt  .rel.tdata	  : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
171.1Smatt  .rela.tdata	  : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
181.1Smatt  .rel.tbss	  : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
191.1Smatt  .rela.tbss	  : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
201.1Smatt  .rel.sdata      : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) }
211.1Smatt  .rela.sdata     : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
221.1Smatt  .rel.sbss       : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) }
231.1Smatt  .rela.sbss      : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) }
241.1Smatt  .rel.sdata2     : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) }
251.1Smatt  .rela.sdata2    : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
261.1Smatt  .rel.sbss2      : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) }
271.1Smatt  .rela.sbss2     : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
281.1Smatt  .rel.bss        : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
291.1Smatt  .rela.bss       : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
301.1Smatt  .text           :
311.1Smatt  {
321.1Smatt    _ftext = . ;
331.1Smatt    *(.text)
341.1Smatt    *(.text.unlikely .text.*_unlikely)
351.1Smatt    *(.text.exit .text.exit.*)
361.1Smatt    *(.text.startup .text.startup.*)
371.1Smatt    *(.text.hot .text.hot.*)
381.1Smatt    *(.stub .text.* .gnu.linkonce.t.*)
391.1Smatt  }
401.1Smatt  PROVIDE (__etext = .);
411.1Smatt  PROVIDE (_etext = .);
421.1Smatt  PROVIDE (etext = .);
431.1Smatt  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
441.1Smatt  .rodata1        : { *(.rodata1) }
451.1Smatt  .sdata2         :
461.1Smatt  {
471.1Smatt    *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
481.1Smatt  }
491.1Smatt  .sbss2          : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
501.1Smatt  .eh_frame_hdr : { *(.eh_frame_hdr) }
511.1Smatt  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
521.1Smatt  /* These sections are generated by the Sun/Oracle C++ compiler.  */
531.1Smatt  .exception_ranges   : ONLY_IF_RO { *(.exception_ranges
541.1Smatt  .exception_ranges*) }
551.1Smatt  /* Adjust the address for the data segment.  We want to adjust up to
561.1Smatt     the same address within the page on the next page up.  */
571.1Smatt  . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
581.1Smatt  /* Exception handling  */
591.1Smatt  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
601.1Smatt  .exception_ranges   : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
611.1Smatt  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
621.1Smatt  . = DATA_SEGMENT_RELRO_END (0, .);
631.1Smatt  .data           :
641.1Smatt  {
651.1Smatt    _fdata = . ;
661.1Smatt    *(.data .data.* .gnu.linkonce.d.*)
671.1Smatt    SORT(CONSTRUCTORS)
681.1Smatt  }
691.1Smatt  .data1          : { *(.data1) }
701.1Smatt  /* We want the small data sections together, so single-instruction offsets
711.1Smatt     can access them all, and initialized data all before uninitialized, so
721.1Smatt     we can shorten the on-disk segment size.  */
731.1Smatt  .sdata          :
741.1Smatt  {
751.1Smatt    /*_gp = . + 0x800;*/
761.1Smatt    *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata*)
771.1Smatt    *(.sdata .sdata.* .gnu.linkonce.s.*)
781.1Smatt  }
791.1Smatt  _edata = .; PROVIDE (edata = .);
801.1Smatt  . = .;
811.1Smatt  __bss_start = .;
821.1Smatt  _fbss = .;
831.1Smatt  .sbss           :
841.1Smatt  {
851.1Smatt    *(.dynsbss)
861.1Smatt    *(.sbss .sbss.* .gnu.linkonce.sb.*)
871.1Smatt    *(.scommon)
881.1Smatt  }
891.1Smatt  .bss            :
901.1Smatt  {
911.1Smatt   *(.dynbss)
921.1Smatt   *(.bss .bss.* .gnu.linkonce.b.*)
931.1Smatt   *(COMMON)
941.1Smatt   /* Align here to ensure that the .bss section occupies space up to
951.1Smatt      _end.  Align after .bss to ensure correct alignment even if the
961.1Smatt      .bss section disappears because there are no input sections.
971.1Smatt      FIXME: Why do we need it? When there is no .bss section, we don't
981.1Smatt      pad the .data section.  */
991.1Smatt   . = ALIGN(. != 0 ? 64 / 8 : 1);
1001.1Smatt  }
1011.1Smatt  . = ALIGN(64 / 8);
1021.1Smatt  _end = .; PROVIDE (end = .);
1031.1Smatt  . = DATA_SEGMENT_END (.);
1041.1Smatt  /* Stabs debugging sections.  */
1051.1Smatt  .stab          0 : { *(.stab) }
1061.1Smatt  .stabstr       0 : { *(.stabstr) }
1071.1Smatt  .stab.excl     0 : { *(.stab.excl) }
1081.1Smatt  .stab.exclstr  0 : { *(.stab.exclstr) }
1091.1Smatt  .stab.index    0 : { *(.stab.index) }
1101.1Smatt  .stab.indexstr 0 : { *(.stab.indexstr) }
1111.1Smatt  .comment       0 : { *(.comment) }
1121.1Smatt  /* DWARF debug sections.
1131.1Smatt     Symbols in the DWARF debugging sections are relative to the beginning
1141.1Smatt     of the section so we begin them at 0.  */
1151.1Smatt  /* DWARF 1 */
1161.1Smatt  .debug          0 : { *(.debug) }
1171.1Smatt  .line           0 : { *(.line) }
1181.1Smatt  /* GNU DWARF 1 extensions */
1191.1Smatt  .debug_srcinfo  0 : { *(.debug_srcinfo) }
1201.1Smatt  .debug_sfnames  0 : { *(.debug_sfnames) }
1211.1Smatt  /* DWARF 1.1 and DWARF 2 */
1221.1Smatt  .debug_aranges  0 : { *(.debug_aranges) }
1231.1Smatt  .debug_pubnames 0 : { *(.debug_pubnames) }
1241.1Smatt  /* DWARF 2 */
1251.1Smatt  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
1261.1Smatt  .debug_abbrev   0 : { *(.debug_abbrev) }
1271.1Smatt  .debug_line     0 : { *(.debug_line) }
1281.1Smatt  .debug_frame    0 : { *(.debug_frame) }
1291.1Smatt  .debug_str      0 : { *(.debug_str) }
1301.1Smatt  .debug_loc      0 : { *(.debug_loc) }
1311.1Smatt  .debug_macinfo  0 : { *(.debug_macinfo) }
1321.1Smatt  /* SGI/MIPS DWARF 2 extensions */
1331.1Smatt  .debug_weaknames 0 : { *(.debug_weaknames) }
1341.1Smatt  .debug_funcnames 0 : { *(.debug_funcnames) }
1351.1Smatt  .debug_typenames 0 : { *(.debug_typenames) }
1361.1Smatt  .debug_varnames  0 : { *(.debug_varnames) }
1371.1Smatt  /* DWARF 3 */
1381.1Smatt  .debug_pubtypes 0 : { *(.debug_pubtypes) }
1391.1Smatt  .debug_ranges   0 : { *(.debug_ranges) }
1401.1Smatt  /* DWARF Extension.  */
1411.1Smatt  .debug_macro    0 : { *(.debug_macro) }
1421.1Smatt  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
1431.1Smatt  .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
1441.1Smatt  .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
1451.1Smatt  /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
1461.1Smatt}
147