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