public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* using void variables as linker-script symbol refs
@ 2003-10-10 17:49 David Howells
  2003-10-10 20:44 ` Richard Henderson
  0 siblings, 1 reply; 2+ messages in thread
From: David Howells @ 2003-10-10 17:49 UTC (permalink / raw)
  To: gcc; +Cc: linux-kernel


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-10-10 20:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-10 17:49 using void variables as linker-script symbol refs David Howells
2003-10-10 20:44 ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox