1cat <<EOF 2OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}") 3OUTPUT_ARCH(${ARCH}) 4 5MEMORY 6{ 7 imem (x) : ORIGIN = $TEXT_ORIGIN, LENGTH = $TEXT_LENGTH 8 dmem (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = $DATA_LENGTH 9} 10 11__HEAP_SIZE = DEFINED(__HEAP_SIZE) ? __HEAP_SIZE : 32; 12__STACK_SIZE = DEFINED(__STACK_SIZE) ? __STACK_SIZE : 512; 13 14${RELOCATING+ PROVIDE (_stack_top = ORIGIN(dmem) + LENGTH(dmem)) ; } 15 16${RELOCATING+ENTRY (_start)} 17 18SECTIONS 19{ 20 /* Read-only sections, merged into text segment: */ 21 ${TEXT_DYNAMIC+${DYNAMIC}} 22 .hash ${RELOCATING-0} : { *(.hash) } 23 .dynsym ${RELOCATING-0} : { *(.dynsym) } 24 .dynstr ${RELOCATING-0} : { *(.dynstr) } 25 .gnu.version ${RELOCATING-0} : { *(.gnu.version) } 26 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } 27 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } 28 29 .rel.init ${RELOCATING-0} : { *(.rel.init) } 30 .rela.init ${RELOCATING-0} : { *(.rela.init) } 31 .rel.text ${RELOCATING-0} : 32 { 33 *(.rel.text) 34 ${RELOCATING+*(.rel.text.*)} 35 ${RELOCATING+*(.rel.text:*)} 36 ${RELOCATING+*(.rel.gnu.linkonce.t*)} 37 } 38 .rela.text ${RELOCATING-0} : 39 { 40 *(.rela.text) 41 ${RELOCATING+*(.rela.text.*)} 42 ${RELOCATING+*(.rela.text:*)} 43 ${RELOCATING+*(.rela.gnu.linkonce.t*)} 44 } 45 .rel.fini ${RELOCATING-0} : { *(.rel.fini) } 46 .rela.fini ${RELOCATING-0} : { *(.rela.fini) } 47 .rel.rodata ${RELOCATING-0} : 48 { 49 *(.rel.rodata) 50 ${RELOCATING+*(.rel.rodata.*)} 51 ${RELOCATING+*(.rel.rodata:*)} 52 ${RELOCATING+*(.rel.gnu.linkonce.r*)} 53 } 54 .rela.rodata ${RELOCATING-0} : 55 { 56 *(.rela.rodata) 57 ${RELOCATING+*(.rela.rodata.*)} 58 ${RELOCATING+*(.rela.rodata:*)} 59 ${RELOCATING+*(.rela.gnu.linkonce.r*)} 60 } 61 .rel.data ${RELOCATING-0} : 62 { 63 *(.rel.data) 64 ${RELOCATING+*(.rel.data.*)} 65 ${RELOCATING+*(.rel.data:*)} 66 ${RELOCATING+*(.rel.gnu.linkonce.d*)} 67 } 68 .rela.data ${RELOCATING-0} : 69 { 70 *(.rela.data) 71 ${RELOCATING+*(.rela.data.*)} 72 ${RELOCATING+*(.rela.data:*)} 73 ${RELOCATING+*(.rela.gnu.linkonce.d*)} 74 } 75 .rel.init_array ${RELOCATING-0} : { *(.rel.init_array) } 76 .rela.init_array ${RELOCATING-0} : { *(.rela.init_array) } 77 .rel.fini_array ${RELOCATING-0} : { *(.rel.fini_array) } 78 .rela.fini_array ${RELOCATING-0} : { *(.rela.fini_array) } 79 .rel.got ${RELOCATING-0} : { *(.rel.got) } 80 .rela.got ${RELOCATING-0} : { *(.rela.got) } 81 .rel.bss ${RELOCATING-0} : { *(.rel.bss) } 82 .rela.bss ${RELOCATING-0} : { *(.rela.bss) } 83 .rel.plt ${RELOCATING-0} : { *(.rel.plt) } 84 .rela.plt ${RELOCATING-0} : { *(.rela.plt) } 85 86 /* Internal text space. */ 87 .text ${RELOCATING-0} : 88 { 89 ${RELOCATING+ _text_start = . ; } 90 91 ${RELOCATING+. = ALIGN(4);} 92 93 ${RELOCATING+*(.init0) /* Start here after reset. */} 94 ${RELOCATING+KEEP (*(.init0))} 95 96 ${RELOCATING+. = ALIGN(4);} 97 *(.text) 98 ${RELOCATING+. = ALIGN(4);} 99 ${RELOCATING+*(.text.*)} 100 ${RELOCATING+. = ALIGN(4);} 101 ${RELOCATING+*(.text:*)} 102 ${RELOCATING+. = ALIGN(4);} 103 ${RELOCATING+*(.gnu.linkonce.t*)} 104 ${RELOCATING+. = ALIGN(4);} 105 106 ${RELOCATING+ _text_end = . ; } 107 } ${RELOCATING+ > imem} 108 109 .data ${RELOCATING-0} : 110 { 111 /* Optional variable that user is prepared to have NULL address. */ 112 ${RELOCATING+ *(.data.atzero*)} 113 114 /* CRT is prepared for constructor/destructor table to have 115 a "valid" NULL address. */ 116 ${CONSTRUCTING+ __init_array_begin = . ; } 117 ${CONSTRUCTING+ KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)))} 118 ${CONSTRUCTING+ KEEP (*(.init_array))} 119 ${CONSTRUCTING+ __init_array_end = . ; } 120 ${CONSTRUCTING+ __fini_array_begin = . ; } 121 ${CONSTRUCTING+ KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*)))} 122 ${CONSTRUCTING+ KEEP (*(.fini_array))} 123 ${CONSTRUCTING+ __fini_array_end = . ; } 124 125 /* DATA memory starts at address 0. So to avoid placing a valid static 126 variable at the invalid NULL address, we introduce the .data.atzero 127 section. If CRT can make some use of it - great. Otherwise skip a 128 word. In all cases .data/.bss sections must start at non-zero. */ 129 . += (. == 0 ? 4 : 0); 130 131 ${RELOCATING+ PROVIDE (_data_start = .) ; } 132 *(.data) 133 ${RELOCATING+ *(.data*)} 134 ${RELOCATING+ *(.data:*)} 135 ${RELOCATING+ *(.rodata) /* We need to include .rodata here if gcc is used. */} 136 ${RELOCATING+ *(.rodata.*) /* with -fdata-sections. */} 137 ${RELOCATING+ *(.rodata:*)} 138 ${RELOCATING+*(.gnu.linkonce.d*)} 139 ${RELOCATING+*(.gnu.linkonce.r*)} 140 ${RELOCATING+. = ALIGN(4);} 141 ${RELOCATING+ PROVIDE (_data_end = .) ; } 142 } ${RELOCATING+ > dmem } 143 144 .resource_table ${RELOCATING-0} : 145 { 146 *(.resource_table) 147 KEEP (*(.resource_table)) 148 } > dmem 149 150 .bss ${RELOCATING-0} : 151 { 152 ${RELOCATING+ PROVIDE (_bss_start = .) ; } 153 *(.bss) 154 ${RELOCATING+ *(.bss.*)} 155 ${RELOCATING+ *(.bss:*)} 156 ${RELOCATING+*(.gnu.linkonce.b*)} 157 *(COMMON) 158 ${RELOCATING+ PROVIDE (_bss_end = .) ; } 159 } ${RELOCATING+ > dmem} 160 161 /* Global data not cleared after reset. */ 162 .noinit ${RELOCATING-0}: 163 { 164 ${RELOCATING+ PROVIDE (_noinit_start = .) ; } 165 *(.noinit) 166 ${RELOCATING+ PROVIDE (_noinit_end = .) ; } 167 ${RELOCATING+ PROVIDE (_heap_start = .) ; } 168 ${RELOCATING+ . += __HEAP_SIZE ; } 169 /* Stack is not here really. It will be put at the end of DMEM. 170 But we take into account its size here, in order to allow 171 for MEMORY overflow checking during link time. */ 172 ${RELOCATING+ . += __STACK_SIZE ; } 173 } ${RELOCATING+ > dmem} 174 175 /* Stabs debugging sections. */ 176 .stab 0 : { *(.stab) } 177 .stabstr 0 : { *(.stabstr) } 178 .stab.excl 0 : { *(.stab.excl) } 179 .stab.exclstr 0 : { *(.stab.exclstr) } 180 .stab.index 0 : { *(.stab.index) } 181 .stab.indexstr 0 : { *(.stab.indexstr) } 182 .comment 0 : { *(.comment) } 183 .note.gnu.build-id : { *(.note.gnu.build-id) } 184EOF 185 186. $srcdir/scripttempl/DWARF.sc 187 188cat <<EOF 189} 190EOF 191