lkml.org 
[lkml]   [2003]   [Oct]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subjectusing void variables as linker-script symbol refs
Date

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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:49    [W:0.046 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site