Hello SDCC team,
I found this while compiling some ST STM8 libraries, which declare externs all over that are not all used.
code:
extern int something_non_existent; int main(void) { return 0; }
1) with "--debug" this compiles fine.
2) with "--debug --out-fmt-elf" this fails.
It fails with undefined symbol in the linker.
This is because the dwarf 2 emitter indiscriminately emits symbols that are extern and never used.
This is wrong. It should not add such symbols to the REL file, unless they are used.
A small check in the dwarf2 emitter for this special case fixes it up.
Thanks,
/pedro
Applied in revision #9465.
Philipp