Commit a188510
Fix hard fault: move .dmod.inputs/.dmod.outputs inside .data to fix startup copy
The startup data copy in startup.s copies bytes linearly from ROM
(__data_init_start__) to RAM (__data_start__ → __data_end__). Previously,
dmod-system.ld was included between .data and __data_end__, creating .inputs
and .outputs as separate sections with "> ram AT > rom". The ". = ALIGN(16)"
in dmod-system.ld only advances the VMA (RAM) location counter, creating
0–12 byte alignment gaps in RAM that have no corresponding gaps in the ROM
layout. This caused the startup copy to misplace the .inputs bytes in RAM,
corrupting the Dmod_ApiRegistration_t entries (swapping .Function/.Signature
pointers or mixing entries from adjacent registrations). The corrupted
.Function value (e.g. 0xd3aefbda) was then used to "connect" the module's
Dmod_EnterCritical output pointer, triggering a hard fault at runtime.
Fix: inline the .dmod.inputs and .dmod.outputs content directly inside the
.data section in linker/common.ld. Alignment padding inside a single section
is inserted identically in both the VMA and LMA representations, so the
startup byte-for-byte copy correctly initialises both sub-sections in RAM.
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>1 parent a6320a9 commit a188510
1 file changed
Lines changed: 33 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
153 | 184 | | |
154 | | - | |
| 185 | + | |
155 | 186 | | |
156 | 187 | | |
157 | 188 | | |
| |||
0 commit comments