using void variables as linker-script symbol refs
From: David Howells
Date: Fri Oct 10 2003 - 12:50:52 EST
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/