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));
27 OUTPUT_SECTION_ALIGN="
28 ${RELOCATING+/* In case this is the last input section,
29 align to keep the loadable segment size a multiple of the common page size.
30 Some SoCs have stricter memory size requirements than others. */
31 . = ALIGN (CONSTANT (COMMONPAGESIZE));}"
36 /* Read-only sections, merged into text segment: */
37 ${TEXT_DYNAMIC+${DYNAMIC}}
38 .hash ${RELOCATING-0} : { *(.hash) }
39 .dynsym ${RELOCATING-0} : { *(.dynsym) }
40 .dynstr ${RELOCATING-0} : { *(.dynstr) }
41 .gnu.version ${RELOCATING-0} : { *(.gnu.version) }
42 .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) }
43 .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) }
45 .rel.init ${RELOCATING-0} : { *(.rel.init) }
46 .rela.init ${RELOCATING-0} : { *(.rela.init) }
47 .rel.text ${RELOCATING-0} :
50 ${RELOCATING+*(.rel.text.*)}
51 ${RELOCATING+*(.rel.text:*)}
52 ${RELOCATING+*(.rel.gnu.linkonce.t*)}
54 .rela.text ${RELOCATING-0} :
57 ${RELOCATING+*(.rela.text.*)}
58 ${RELOCATING+*(.rela.text:*)}
59 ${RELOCATING+*(.rela.gnu.linkonce.t*)}
61 .rel.fini ${RELOCATING-0} : { *(.rel.fini) }
62 .rela.fini ${RELOCATING-0} : { *(.rela.fini) }
63 .rel.rodata ${RELOCATING-0} :
66 ${RELOCATING+*(.rel.rodata.*)}
67 ${RELOCATING+*(.rel.rodata:*)}
68 ${RELOCATING+*(.rel.gnu.linkonce.r*)}
70 .rela.rodata ${RELOCATING-0} :
73 ${RELOCATING+*(.rela.rodata.*)}
74 ${RELOCATING+*(.rela.rodata:*)}
75 ${RELOCATING+*(.rela.gnu.linkonce.r*)}
77 .rel.data ${RELOCATING-0} :
80 ${RELOCATING+*(.rel.data.*)}
81 ${RELOCATING+*(.rel.data:*)}
82 ${RELOCATING+*(.rel.gnu.linkonce.d*)}
84 .rela.data ${RELOCATING-0} :
87 ${RELOCATING+*(.rela.data.*)}
88 ${RELOCATING+*(.rela.data:*)}
89 ${RELOCATING+*(.rela.gnu.linkonce.d*)}
91 .rel.init_array ${RELOCATING-0} : { *(.rel.init_array) }
92 .rela.init_array ${RELOCATING-0} : { *(.rela.init_array) }
93 .rel.fini_array ${RELOCATING-0} : { *(.rel.fini_array) }
94 .rela.fini_array ${RELOCATING-0} : { *(.rela.fini_array) }
95 .rel.got ${RELOCATING-0} : { *(.rel.got) }
96 .rela.got ${RELOCATING-0} : { *(.rela.got) }
97 .rel.bss ${RELOCATING-0} : { *(.rel.bss) }
98 .rela.bss ${RELOCATING-0} : { *(.rela.bss) }
99 .rel.plt ${RELOCATING-0} : { *(.rel.plt) }
100 .rela.plt ${RELOCATING-0} : { *(.rela.plt) }
102 /* Internal text space. */
103 .text ${RELOCATING-0} :
105 ${RELOCATING+ _text_start = . ; }
107 ${RELOCATING+. = ALIGN(4);}
109 ${RELOCATING+*(.init0) /* Start here after reset. */}
110 ${RELOCATING+KEEP (*(.init0))}
112 ${RELOCATING+. = ALIGN(4);}
114 ${RELOCATING+. = ALIGN(4);}
115 ${RELOCATING+*(.text.*)}
116 ${RELOCATING+. = ALIGN(4);}
117 ${RELOCATING+*(.text:*)}
118 ${RELOCATING+. = ALIGN(4);}
119 ${RELOCATING+*(.gnu.linkonce.t*)}
120 ${RELOCATING+. = ALIGN(4);}
122 ${RELOCATING+ _text_end = . ; }
123 } ${RELOCATING+ > imem}
125 .data ${RELOCATING-0} :
127 /* Optional variable that user is prepared to have NULL address. */
128 ${RELOCATING+ *(.data.atzero*)}
130 /* CRT is prepared for constructor/destructor table to have
131 a "valid" NULL address. */
132 ${CONSTRUCTING+ __init_array_start = . ; }
133 ${CONSTRUCTING+ KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)))}
134 ${CONSTRUCTING+ KEEP (*(.init_array))}
135 ${CONSTRUCTING+ __init_array_end = . ; }
136 ${CONSTRUCTING+ __fini_array_start = . ; }
137 ${CONSTRUCTING+ KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*)))}
138 ${CONSTRUCTING+ KEEP (*(.fini_array))}
139 ${CONSTRUCTING+ __fini_array_end = . ; }
141 ${RELOCATING+/* DATA memory starts at address 0. So to avoid placing a valid static
142 variable at the invalid NULL address, we introduce the .data.atzero
143 section. If CRT can make some use of it - great. Otherwise skip a
144 word. In all cases .data/.bss sections must start at non-zero. */
145 . += (. == 0 ? 4 : 0);}
147 ${RELOCATING+ PROVIDE (_data_start = .) ; }
149 ${RELOCATING+ *(.data*)}
150 ${RELOCATING+ *(.data:*)}
151 ${RELOCATING+ *(.rodata) /* We need to include .rodata here if gcc is used. */}
152 ${RELOCATING+ *(.rodata.*) /* with -fdata-sections. */}
153 ${RELOCATING+ *(.rodata:*)}
154 ${RELOCATING+*(.gnu.linkonce.d*)}
155 ${RELOCATING+*(.gnu.linkonce.r*)}
156 ${RELOCATING+ PROVIDE (_data_end = .) ; }
158 ${RELOCATING+/* Merge the bss input sections into the output
159 data section. The Linux kernel's remoteproc PRU ELF loader
160 will not memzero the bss section. The CRT0 will not either, in order
161 to reduce the final firmware's instruction memory size. Hence
162 present bss sections as regular data sections, at the negligible
163 expense of increasing the ELF file size. */}
164 ${RELOCATING+ PROVIDE (_bss_start = .) ; }
166 ${RELOCATING+ *(.bss.*)}
167 ${RELOCATING+ *(.bss:*)}
168 ${RELOCATING+*(.gnu.linkonce.b*)}
169 ${RELOCATING+*(COMMON)}
170 ${RELOCATING+ PROVIDE (_bss_end = .) ; }
172 ${OUTPUT_SECTION_ALIGN}
173 } ${RELOCATING+ > dmem}
175 .eh_frame ${RELOCATING-0} :
177 KEEP (*(.eh_frame))${RELOCATING+ *(.eh_frame.*)}
178 ${OUTPUT_SECTION_ALIGN}
179 } ${RELOCATING+ > dmem}
181 .gnu_extab ${RELOCATING-0} :
184 ${OUTPUT_SECTION_ALIGN}
185 } ${RELOCATING+ > dmem}
187 .gcc_except_table ${RELOCATING-0} :
189 *(.gcc_except_table${RELOCATING+ .gcc_except_table.*})
190 ${OUTPUT_SECTION_ALIGN}
191 } ${RELOCATING+ > dmem}
193 /* Linux remoteproc loader requires the resource_table section
194 start address to be aligned to 8 bytes for SoCs with AARCH64
196 .resource_table ${RELOCATING-0} ${RELOCATING+ ALIGN (CONSTANT (MAXPAGESIZE))} :
198 KEEP (*(.resource_table))
199 ${OUTPUT_SECTION_ALIGN}
200 } ${RELOCATING+ > dmem}
202 /* Global data not cleared after reset. */
203 .noinit ${RELOCATING-0} :
205 ${RELOCATING+ PROVIDE (_noinit_start = .) ; }
206 *(.noinit${RELOCATING+ .noinit.* .gnu.linkonce.n.*})
207 ${RELOCATING+ PROVIDE (_noinit_end = .) ; }
208 ${RELOCATING+ PROVIDE (_heap_start = .) ; }
209 ${RELOCATING+ . += __HEAP_SIZE ; }
210 ${RELOCATING+/* Stack is not here really. It will be put at the end of DMEM.
211 But we take into account its size here, in order to allow
212 for MEMORY overflow checking during link time. */}
213 ${RELOCATING+ . += __STACK_SIZE ; }
214 } ${RELOCATING+ > dmem}
216 /* Remoteproc loader in Linux kernel 5.10 and later reads this section
217 to setup the PRUSS interrupt controller. The interrupt map section
218 is never referenced from PRU firmware, so there is no need to
219 place it in the target dmem memory. */
220 .pru_irq_map 0 : { *(.pru_irq_map) }
222 .note.gnu.build-id ${RELOCATING-0} : { *(.note.gnu.build-id) }
225 source_sh $srcdir/scripttempl/misc-sections.sc
226 source_sh $srcdir/scripttempl/DWARF.sc