This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Confusion about value stored in linker script

"Dave Korn" <> writes:
> On 01 November 2007 19:02, Rick Mann wrote:
>   They aren't pointers and they aren't variables.  They are just numbers.  Try
> this instead: tell the compiler that these are references to a single byte of
> memory by pretending they are 'char' variables:
> extern char gVectorsStart, gVectorsEnd;
>   Then take the address of those variables:
> extern UInt32 *pgVectorsStart = &gVectorsStart;
> extern UInt32 *pgVectorsEnd = &gVectorsEnd;

Beware, this may not work for some architectures[1]. Safer bet is:

extern UInt32 gVectorStart[], gVectorEnd[];
extern UInt32 *pgVectorsStart = gVectorsStart;
extern UInt32 *pgVectorsEnd = gVectorsEnd;

[1] E.g., for archs where there is "small .data" or "small .bss"
section, compiler will expect simple "char" variables are in the small
section and do wrong thing when you try to take their address. It won't
expect this when you declare these virtual variables as arrays of
unknown size though.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]