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 SECTIONS 6 1.1 matt { 7 1.1 matt /* Read-only sections, merged into text segment: */ 8 1.1 matt PROVIDE (__executable_start = SEGMENT_START("text-segment", 0xffffffff80000000)); . = SEGMENT_START("text-segment", 0xffffffff80000000) + SIZEOF_HEADERS; 9 1.1 matt .text : 10 1.1 matt { 11 1.1 matt _ftext = . ; 12 1.1 matt *(.text) 13 1.1 matt *(.text.unlikely .text.*_unlikely) 14 1.1 matt *(.text.exit .text.exit.*) 15 1.1 matt *(.text.startup .text.startup.*) 16 1.1 matt *(.text.hot .text.hot.*) 17 1.1 matt *(.stub .text.* .gnu.linkonce.t.*) 18 1.1 matt } 19 1.1 matt PROVIDE (__etext = .); 20 1.1 matt PROVIDE (_etext = .); 21 1.1 matt PROVIDE (etext = .); 22 1.1 matt .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } 23 1.1 matt .rodata1 : { *(.rodata1) } 24 1.1 matt .sdata2 : 25 1.1 matt { 26 1.1 matt *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) 27 1.1 matt } 28 1.1 matt .sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) } 29 1.1 matt .eh_frame_hdr : { *(.eh_frame_hdr) } 30 1.1 matt .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } 31 1.1 matt /* These sections are generated by the Sun/Oracle C++ compiler. */ 32 1.1 matt .exception_ranges : ONLY_IF_RO { *(.exception_ranges 33 1.1 matt .exception_ranges*) } 34 1.1 matt /* Adjust the address for the data segment. We want to adjust up to 35 1.1 matt the same address within the page on the next page up. */ 36 1.1 matt . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); 37 1.1 matt /* Exception handling */ 38 1.1 matt .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } 39 1.1 matt .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } 40 1.1 matt . = DATA_SEGMENT_RELRO_END (0, .); 41 1.1 matt .data : 42 1.1 matt { 43 1.1 matt _fdata = . ; 44 1.1 matt *(.data .data.* .gnu.linkonce.d.*) 45 1.1 matt SORT(CONSTRUCTORS) 46 1.1 matt } 47 1.1 matt .data1 : { *(.data1) } 48 1.1 matt /* We want the small data sections together, so single-instruction offsets 49 1.1 matt can access them all, and initialized data all before uninitialized, so 50 1.1 matt we can shorten the on-disk segment size. */ 51 1.1 matt .sdata : 52 1.1 matt { 53 1.1 matt /*_gp = . + 0x800;*/ 54 1.1 matt *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata*) 55 1.1 matt *(.sdata .sdata.* .gnu.linkonce.s.*) 56 1.1 matt } 57 1.1 matt _edata = .; PROVIDE (edata = .); 58 1.1 matt . = .; 59 1.1 matt __bss_start = .; 60 1.1 matt _fbss = .; 61 1.1 matt .sbss : 62 1.1 matt { 63 1.1 matt *(.dynsbss) 64 1.1 matt *(.sbss .sbss.* .gnu.linkonce.sb.*) 65 1.1 matt *(.scommon) 66 1.1 matt } 67 1.1 matt .bss : 68 1.1 matt { 69 1.2 uebayasi *(.dynbss) 70 1.2 uebayasi *(.bss .bss.* .gnu.linkonce.b.*) 71 1.2 uebayasi *(COMMON) 72 1.2 uebayasi /* Align here to ensure that the .bss section occupies space up to 73 1.2 uebayasi _end. Align after .bss to ensure correct alignment even if the 74 1.2 uebayasi .bss section disappears because there are no input sections. 75 1.2 uebayasi FIXME: Why do we need it? When there is no .bss section, we don't 76 1.2 uebayasi pad the .data section. */ 77 1.2 uebayasi . = ALIGN(. != 0 ? 64 / 8 : 1); 78 1.1 matt } 79 1.1 matt . = ALIGN(64 / 8); 80 1.1 matt _end = .; PROVIDE (end = .); 81 1.1 matt . = DATA_SEGMENT_END (.); 82 1.1 matt } 83