1*3d8817e4Smiod# Linker Script for National Semiconductor's CRX-ELF32. 2*3d8817e4Smiod 3*3d8817e4Smiod# The next line should be uncommented if it is desired to link 4*3d8817e4Smiod# without libstart.o and directly enter main. 5*3d8817e4Smiod 6*3d8817e4Smiod# ENTRY=_main 7*3d8817e4Smiod 8*3d8817e4Smiodtest -z "$ENTRY" && ENTRY=_start 9*3d8817e4Smiodcat <<EOF 10*3d8817e4Smiod 11*3d8817e4Smiod/* Example Linker Script for linking NS CRX elf32 files. */ 12*3d8817e4Smiod 13*3d8817e4Smiod/* The next line forces the entry point (${ENTRY} in this script) 14*3d8817e4Smiod to be entered in the output file as an undefined symbol. 15*3d8817e4Smiod It is needed in case the entry point is not called explicitly 16*3d8817e4Smiod (which is the usual case) AND is in an archive. */ 17*3d8817e4Smiod 18*3d8817e4SmiodOUTPUT_FORMAT("${OUTPUT_FORMAT}") 19*3d8817e4SmiodOUTPUT_ARCH(${ARCH}) 20*3d8817e4SmiodEXTERN(${ENTRY}) 21*3d8817e4SmiodENTRY(${ENTRY}) 22*3d8817e4Smiod 23*3d8817e4Smiod/* Define memory regions. */ 24*3d8817e4SmiodMEMORY 25*3d8817e4Smiod{ 26*3d8817e4Smiod rom : ORIGIN = 0x2, LENGTH = 3M 27*3d8817e4Smiod ram : ORIGIN = 4M, LENGTH = 10M 28*3d8817e4Smiod} 29*3d8817e4Smiod 30*3d8817e4Smiod/* Many sections come in three flavours. There is the 'real' section, 31*3d8817e4Smiod like ".data". Then there are the per-procedure or per-variable 32*3d8817e4Smiod sections, generated by -ffunction-sections and -fdata-sections in GCC, 33*3d8817e4Smiod and useful for --gc-sections, which for a variable "foo" might be 34*3d8817e4Smiod ".data.foo". Then there are the linkonce sections, for which the linker 35*3d8817e4Smiod eliminates duplicates, which are named like ".gnu.linkonce.d.foo". 36*3d8817e4Smiod The exact correspondences are: 37*3d8817e4Smiod 38*3d8817e4Smiod Section Linkonce section 39*3d8817e4Smiod .text .gnu.linkonce.t.foo 40*3d8817e4Smiod .rdata .gnu.linkonce.r.foo 41*3d8817e4Smiod .data .gnu.linkonce.d.foo 42*3d8817e4Smiod .bss .gnu.linkonce.b.foo 43*3d8817e4Smiod .debug_info .gnu.linkonce.wi.foo */ 44*3d8817e4Smiod 45*3d8817e4SmiodSECTIONS 46*3d8817e4Smiod{ 47*3d8817e4Smiod .init : 48*3d8817e4Smiod { 49*3d8817e4Smiod __INIT_START = .; 50*3d8817e4Smiod KEEP (*(.init)) 51*3d8817e4Smiod __INIT_END = .; 52*3d8817e4Smiod } > rom 53*3d8817e4Smiod 54*3d8817e4Smiod .fini : 55*3d8817e4Smiod { 56*3d8817e4Smiod __FINI_START = .; 57*3d8817e4Smiod KEEP (*(.fini)) 58*3d8817e4Smiod __FINI_END = .; 59*3d8817e4Smiod } > rom 60*3d8817e4Smiod 61*3d8817e4Smiod .jcr : 62*3d8817e4Smiod { 63*3d8817e4Smiod KEEP (*(.jcr)) 64*3d8817e4Smiod } > rom 65*3d8817e4Smiod 66*3d8817e4Smiod .text : 67*3d8817e4Smiod { 68*3d8817e4Smiod __TEXT_START = .; 69*3d8817e4Smiod *(.text) *(.text.*) *(.gnu.linkonce.t.*) 70*3d8817e4Smiod __TEXT_END = .; 71*3d8817e4Smiod } > rom 72*3d8817e4Smiod 73*3d8817e4Smiod .rdata : 74*3d8817e4Smiod { 75*3d8817e4Smiod __RDATA_START = .; 76*3d8817e4Smiod *(.rdata_4) *(.rdata_2) *(.rdata_1) *(.rdata.*) *(.gnu.linkonce.r.*) *(.rodata.*) 77*3d8817e4Smiod __RDATA_END = .; 78*3d8817e4Smiod } > rom 79*3d8817e4Smiod 80*3d8817e4Smiod .ctor ALIGN(4) : 81*3d8817e4Smiod { 82*3d8817e4Smiod __CTOR_START = .; 83*3d8817e4Smiod /* The compiler uses crtbegin.o to find the start 84*3d8817e4Smiod of the constructors, so we make sure it is 85*3d8817e4Smiod first. Because this is a wildcard, it 86*3d8817e4Smiod doesn't matter if the user does not 87*3d8817e4Smiod actually link against crtbegin.o; the 88*3d8817e4Smiod linker won't look for a file to match a 89*3d8817e4Smiod wildcard. The wildcard also means that it 90*3d8817e4Smiod doesn't matter which directory crtbegin.o 91*3d8817e4Smiod is in. */ 92*3d8817e4Smiod 93*3d8817e4Smiod KEEP (*crtbegin*.o(.ctors)) 94*3d8817e4Smiod 95*3d8817e4Smiod /* We don't want to include the .ctor section from 96*3d8817e4Smiod the crtend.o file until after the sorted ctors. 97*3d8817e4Smiod The .ctor section from the crtend file contains the 98*3d8817e4Smiod end of ctors marker and it must be last */ 99*3d8817e4Smiod 100*3d8817e4Smiod KEEP (*(EXCLUDE_FILE (*crtend*.o) .ctors)) 101*3d8817e4Smiod KEEP (*(SORT(.ctors.*))) 102*3d8817e4Smiod KEEP (*(.ctors)) 103*3d8817e4Smiod __CTOR_END = .; 104*3d8817e4Smiod } > rom 105*3d8817e4Smiod 106*3d8817e4Smiod .dtor ALIGN(4) : 107*3d8817e4Smiod { 108*3d8817e4Smiod __DTOR_START = .; 109*3d8817e4Smiod KEEP (*crtbegin*.o(.dtors)) 110*3d8817e4Smiod KEEP (*(EXCLUDE_FILE (*crtend*.o) .dtors)) 111*3d8817e4Smiod KEEP (*(SORT(.dtors.*))) 112*3d8817e4Smiod KEEP (*(.dtors)) 113*3d8817e4Smiod __DTOR_END = .; 114*3d8817e4Smiod } > rom 115*3d8817e4Smiod 116*3d8817e4Smiod .data : 117*3d8817e4Smiod { 118*3d8817e4Smiod __DATA_START = .; 119*3d8817e4Smiod *(.data_4) *(.data_2) *(.data_1) *(.data) *(.data.*) *(.gnu.linkonce.d.*) 120*3d8817e4Smiod __DATA_END = .; 121*3d8817e4Smiod } > ram AT > rom 122*3d8817e4Smiod 123*3d8817e4Smiod .bss (NOLOAD) : 124*3d8817e4Smiod { 125*3d8817e4Smiod __BSS_START = .; 126*3d8817e4Smiod *(.bss_4) *(.bss_2) *(.bss_1) *(.bss) *(COMMON) *(.bss.*) *(.gnu.linkonce.b.*) 127*3d8817e4Smiod __BSS_END = .; 128*3d8817e4Smiod } > ram 129*3d8817e4Smiod 130*3d8817e4Smiod/* You may change the sizes of the following sections to fit the actual 131*3d8817e4Smiod size your program requires. 132*3d8817e4Smiod 133*3d8817e4Smiod The heap and stack are aligned to the bus width, as a speed optimization 134*3d8817e4Smiod for accessing data located there. */ 135*3d8817e4Smiod 136*3d8817e4Smiod .heap : 137*3d8817e4Smiod { 138*3d8817e4Smiod . = ALIGN(4); 139*3d8817e4Smiod __HEAP_START = .; 140*3d8817e4Smiod . += 0x2000; __HEAP_MAX = .; 141*3d8817e4Smiod } > ram 142*3d8817e4Smiod 143*3d8817e4Smiod .stack : 144*3d8817e4Smiod { 145*3d8817e4Smiod . = ALIGN(4); 146*3d8817e4Smiod . += 0x6000; 147*3d8817e4Smiod __STACK_START = .; 148*3d8817e4Smiod } > ram 149*3d8817e4Smiod 150*3d8817e4Smiod .istack : 151*3d8817e4Smiod { 152*3d8817e4Smiod . = ALIGN(4); 153*3d8817e4Smiod . += 0x100; 154*3d8817e4Smiod __ISTACK_START = .; 155*3d8817e4Smiod } > ram 156*3d8817e4Smiod 157*3d8817e4Smiod .comment 0 : { *(.comment) } 158*3d8817e4Smiod 159*3d8817e4Smiod /* DWARF debug sections. 160*3d8817e4Smiod Symbols in the DWARF debugging sections are relative to the beginning 161*3d8817e4Smiod of the section so we begin them at 0. */ 162*3d8817e4Smiod 163*3d8817e4Smiod .debug_aranges 0 : { *(.debug_aranges) } 164*3d8817e4Smiod .debug_pubnames 0 : { *(.debug_pubnames) } 165*3d8817e4Smiod .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } 166*3d8817e4Smiod .debug_abbrev 0 : { *(.debug_abbrev) } 167*3d8817e4Smiod .debug_line 0 : { *(.debug_line) } 168*3d8817e4Smiod .debug_frame 0 : { *(.debug_frame) } 169*3d8817e4Smiod .debug_str 0 : { *(.debug_str) } 170*3d8817e4Smiod .debug_loc 0 : { *(.debug_loc) } 171*3d8817e4Smiod .debug_macinfo 0 : { *(.debug_macinfo) } 172*3d8817e4Smiod} 173*3d8817e4Smiod 174*3d8817e4Smiod__DATA_IMAGE_START = LOADADDR(.data); 175*3d8817e4SmiodEOF 176