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