Menu

#3576 <r> relocation error

closed-fixed
None
other
5
2023-04-26
2023-04-25
No

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!

Related

Wiki: NGI0-Entrust-SDCC

Discussion

  • Philipp Klaus Krause

    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:

    philipp@notebook6:/tmp$ ~/sdcc-trunk/sdcc/bin/sdcc --out-fmt-elf -mstm8 --debug test.c
    test.c:1: warning 283: function declarator with no prototype
    test.asm:188: Error: <r> Arg1 - Arg2, Arg2 must be in same area.
    removing test.rel
    

    The line for which the error gets reported is:

        .dw Stest$main$6-Stest$func$5
    

    The second symbol in that line (Stest$func$5) is apparently not defined in the function func, but in the initialization code (since i is static, the initialization of i does not happen in func but 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
  • Philipp Klaus Krause

    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
  • Philipp Klaus Krause

    • assigned_to: Philipp Klaus Krause
     
  • Philipp Klaus Krause

    • status: open --> closed-fixed
     
  • Philipp Klaus Krause

    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]


Log in to post a comment.

MongoDB Logo MongoDB