Open ali1234 opened 5 years ago
Including the link flags "-Wl,--undefined=_mmcu,--section-start=.mmcu=0x910000" makes this work, but I don't see why it should be necessary given that objdump can find the intact .data section just fine without it.
I realize this is quite old news, but this occurs because of section ordering. It's possible that the .mmcu
section appears between .text
and .data
, but simavr loads .text
and .data
immediately adjacent to each other. This means the offsets in __do_copy_data
(a stub inserted by libgcc) don't match the flash memory map simulated by simavr. Moving the section start address ensures it is not mapped between the two other sections.
Test one:
Compile and run it in simavr:
Check the contents of the data section:
Run it in simavr:
Debug with gdb:
Test two:
Source code:
Compile and run as before. Verify the data section again with objdump to confirm it is the same.
Run it in gdb:
Result: myvar is now 0xff instead of 0xab, but the data section has not changed according to objdump.