I'm developing on a custom embedded platform with a custom version of gcc, which is based on gcc-2.8.0 (egcs-2.91.02)
. Yes, it's old. It's for a CoolRISC C816 core.
I face a strange error sometimes, when during the link of my embedded C project gcc gives me this error :
undefined reference to _spill
Indeed, when looking into the temporary *.s file generated by gcc when compiling the source files in those specific cases, I see this kind of instruction :
MOVE __spill+4,%a
I'm surprised because this _spill error only happens once in a while, on multiple big projects (20k+ LOC) there's no sign of this error, and not any reference to _spill in the *.s files.
I already have a fix consisting of allocating _spill in my startup assembly file, but I'd like to know more about this.
What is '_spill' and why do I need it ? Also, if I have to statically allocate it, how to know which size I should give it ?
Edit: As advised in the comments, I looked at the corresponding C code and the line that seems the source of the pack of instructions containing '_spill' is this one :
pStruct->psConst->puRegister[CONST_VALUE] = 0x00;
Where pStruct
is a pointer on a typedef struct (call it Foo) locally declared like this : Foo *pStruct = &MyStruct
, with MyStruct
an extern variable of type Foo
that is in another file.
psConst
is a const pointer on another typedef struct (call it Bar).
puRegister
is a member of Bar declared of type volatile uint8_t *
And finally, CONST_VALUE
is a constant value from an enumerate.
This might therefore be an issue that happens only when there's a lot of dereference in a row, or something related.