1/ Sample code:
void func()
{
static int i = 0;
}
void main(void)
{
}
2/ Command:
sdcc -mstm8 --out-fmt-elf --debug main.c
3/ Version: SDCC :
mcs51/stm8 4.2.0 #13081 (Linux)
4/ Error message:
main.asm:184: Error: <r> relocation error
removing main.rel</r>
Thank you for your wonderful software!
In current trunk (built from today's svn on Debian GNU/Linux on amd64), I still see a problem, though the error message is a bit different:
The line for which the error gets reported is:
The second symbol in that line (
Stest$func$5) is apparently not defined in the functionfunc, but in the initialization code (since i is static, the initialization of i does not happen infuncbut in the initialization of global variables). Thus the difference is not known at assembly time (it should be known at link time, though).Last edit: Philipp Klaus Krause 2023-04-25
I think this patch could fix the issue. For me, it makes your example program compile, but I haven't tested it yet otherwise. In particular, I haven't tested if the emitted line number information actually works when used in a debugger.
P.S.: TESTING SHOWED THAT THIS PATCH BREAKS DEBUGGING.
Last edit: Philipp Klaus Krause 2023-04-26
I think I fixed this in [r14012] by using DW_LNE_set_address instead of DW_LNS_fixed_advance_pc. But I am not really familiar with DWARF. And it looks like stepping through the initializations of static variables still doesn't fully work.
But at least it compiles now, and stepping through other code still works.
Related
Commit: [r14012]