All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: gcc@gcc.gnu.org
Cc: linux-kernel@vger.kernel.org
Subject: using void variables as linker-script symbol refs
Date: Fri, 10 Oct 2003 18:49:28 +0100	[thread overview]
Message-ID: <15494.1065808168@redhat.com> (raw)


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

             reply	other threads:[~2003-10-10 17:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-10 17:49 David Howells [this message]
2003-10-10 20:44 ` using void variables as linker-script symbol refs Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15494.1065808168@redhat.com \
    --to=dhowells@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.