2 OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}")
7 test -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;
14 imem (x) : ORIGIN = $TEXT_ORIGIN, LENGTH = __IMEM_SIZE
15 dmem (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = __DMEM_SIZE
18 __HEAP_SIZE = DEFINED(__HEAP_SIZE) ? __HEAP_SIZE : 32;
19 __STACK_SIZE = DEFINED(__STACK_SIZE) ? __STACK_SIZE : 512;
21 PROVIDE (_stack_top = ORIGIN(dmem) + LENGTH(dmem));
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) }
39 .rel.init ${RELOCATING-0} : { *(.rel.init) }
40 .rela.init ${RELOCATING-0} : { *(.rela.init) }
41 .rel.text ${RELOCATING-0} :
44 ${RELOCATING+*(.rel.text.*)}
45 ${RELOCATING+*(.rel.text:*)}
46 ${RELOCATING+*(.rel.gnu.linkonce.t*)}
48 .rela.text ${RELOCATING-0} :
51 ${RELOCATING+*(.rela.text.*)}
52 ${RELOCATING+*(.rela.text:*)}
53 ${RELOCATING+*(.rela.gnu.linkonce.t*)}
55 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
56 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
57 .rel.rodata ${RELOCATING-0} :
60 ${RELOCATING+*(.rel.rodata.*)}
61 ${RELOCATING+*(.rel.rodata:*)}
62 ${RELOCATING+*(.rel.gnu.linkonce.r*)}
64 .rela.rodata ${RELOCATING-0} :
67 ${RELOCATING+*(.rela.rodata.*)}
68 ${RELOCATING+*(.rela.rodata:*)}
69 ${RELOCATING+*(.rela.gnu.linkonce.r*)}
71 .rel.data ${RELOCATING-0} :
74 ${RELOCATING+*(.rel.data.*)}
75 ${RELOCATING+*(.rel.data:*)}
76 ${RELOCATING+*(.rel.gnu.linkonce.d*)}
78 .rela.data ${RELOCATING-0} :
81 ${RELOCATING+*(.rela.data.*)}
82 ${RELOCATING+*(.rela.data:*)}
83 ${RELOCATING+*(.rela.gnu.linkonce.d*)}
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) }
96 /* Internal text space. */
97 .text ${RELOCATING-0} :
99 ${RELOCATING+ _text_start = . ; }
101 ${RELOCATING+. = ALIGN(4);}
103 ${RELOCATING+*(.init0) /* Start here after reset. */}
104 ${RELOCATING+KEEP (*(.init0))}
106 ${RELOCATING+. = ALIGN(4);}
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);}
116 ${RELOCATING+ _text_end = . ; }
117 } ${RELOCATING+ > imem}
119 .data ${RELOCATING-0} :
121 /* Optional variable that user is prepared to have NULL address. */
122 ${RELOCATING+ *(.data.atzero*)}
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 = . ; }
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);}
141 ${RELOCATING+ PROVIDE (_data_start = .) ; }
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+ PROVIDE (_data_end = .) ; }
152 ${RELOCATING+/* Merge the bss input sections into the output
153 data section. The Linux kernel's remoteproc PRU ELF loader
154 will not memzero the bss section. The CRT0 will not either, in order
155 to reduce the final firmware's instruction memory size. Hence
156 present bss sections as regular data sections, at the negligible
157 expense of increasing the ELF file size. */}
158 ${RELOCATING+ PROVIDE (_bss_start = .) ; }
160 ${RELOCATING+ *(.bss.*)}
161 ${RELOCATING+ *(.bss:*)}
162 ${RELOCATING+*(.gnu.linkonce.b*)}
163 ${RELOCATING+*(COMMON)}
164 ${RELOCATING+ PROVIDE (_bss_end = .) ; }
166 ${RELOCATING+/* In case this is the last input section, align to
167 keep the loadable segment size a multiple of the common page size.
168 Some SoCs have stricter memory size requirements than others. */
169 . = ALIGN (CONSTANT (COMMONPAGESIZE));}
170 } ${RELOCATING+ > dmem}
172 /* Linux remoteproc loader requires the resource_table section
173 start address to be aligned to 8 bytes for SoCs with AARCH64
175 .resource_table ${RELOCATING-0} ${RELOCATING+ ALIGN (CONSTANT (MAXPAGESIZE))} :
177 KEEP (*(.resource_table))
178 ${RELOCATING+/* In case this is the last input section, align to
179 keep the loadable segment size a multiple of the common page size.
180 Some SoCs have stricter memory size requirements than others. */
181 . = ALIGN (CONSTANT (COMMONPAGESIZE));}
182 } ${RELOCATING+ > dmem}
184 /* Global data not cleared after reset. */
185 .noinit ${RELOCATING-0} :
187 ${RELOCATING+ PROVIDE (_noinit_start = .) ; }
188 *(.noinit${RELOCATING+ .noinit.* .gnu.linkonce.n.*})
189 ${RELOCATING+ PROVIDE (_noinit_end = .) ; }
190 ${RELOCATING+ PROVIDE (_heap_start = .) ; }
191 ${RELOCATING+ . += __HEAP_SIZE ; }
192 ${RELOCATING+/* Stack is not here really. It will be put at the end of DMEM.
193 But we take into account its size here, in order to allow
194 for MEMORY overflow checking during link time. */}
195 ${RELOCATING+ . += __STACK_SIZE ; }
196 } ${RELOCATING+ > dmem}
198 /* Remoteproc loader in Linux kernel 5.10 and later reads this section
199 to setup the PRUSS interrupt controller. The interrupt map section
200 is never referenced from PRU firmware, so there is no need to
201 place it in the target dmem memory. */
202 .pru_irq_map 0 : { *(.pru_irq_map) }
204 .note.gnu.build-id ${RELOCATING-0} : { *(.note.gnu.build-id) }
207 source_sh $srcdir/scripttempl/misc-sections.sc
208 source_sh $srcdir/scripttempl/DWARF.sc