using void variables as linker-script symbol refs
I've got a situation in which I'd like to use something like the following to refer to constants defined in the linker script:
extern const void _stext, _etext; #define __kernel_size ((unsigned long)&_etext - (unsigned long)&_stext)
Rather than:
extern int _stext, _etext;
Or:
extern int _stext[], _etext[];
Or:
struct __not_really_a_struct; struct __not_really_a_struct _stext, _etext;
This has a couple of advantages:
(1) You can't accidentally read/set such variables directly.
(2) GCC doesn't assume they can be referenced by register-relative means, if the CPU has a special data pointer (such as a small-data pointer).
Any thoughts? Or is this just a straight forward shooting offence?
David
Quoted 1 line · David Howells
extern int _stext[], _etext[];
s/int/char/ and this is the most correct way. Really.
r~