Hey,
void fkt(const char *t) {
const char *string = t;
}
void main(void) {
static const char *test = "Hello!\n";
fkt( test );
return;
}
sdcc -mstm8 --debug --out-fmt-elf -c test.c
running this code leads to a segmentation fault from the assembler.
Compiling seem to be fine:
sdcc -mstm8 --debug --out-fmt-elf -S test.c
If the string is not declarated as static it seem to be fine, too.
If ether "--debug" or "--out-fmt-elf" is missing in the commandline it seem to be fine, too.
$sdcc -v
SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/gbz80/tlcs90/ez80_z80/z80n/ds390/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15 4.0.7 #11994 (Linux)
published under GNU General Public License (GPL)
Best regards
Michael
invoking the assembler by "hand" gives additional errors:
line 505 is
Last edit: Michael 2020-12-18
It seems that the labels for all functions are stored in a global structur "dwCFIRoot" that is read to create the debug entries in the asm file.
It's values are set in SDCCast.c createFunction() throw the calls of -> eBBlockFromiCode() -> port->assignRegiste() aka "stm8_asignRegister()" -> genSTM8Code() -> debugFile->writeFunction aka "dwWriteFunction()"
interesting is line 7652 in SDCCast.c in function createFunction here is eBBlockFromiCode are called and after that there is a if(staticAutos) that calls eBBlockFromiCode again and causes the messed up labels when the string is declared as static.
I'm getting the same. SDCC 4.0.7 #11994 (Linux). I've been using global variables as a workaround. Ugly, but, works. (there are a handful of open tickets and discussion on this issue dating back to 3.7.0)
Last edit: brad roy 2021-01-05
Fixed in [r12537]