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