Re: [arm-gnu] Getting linker data into a C structure
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [arm-gnu] Getting linker data into a C structure



On Monday, May 10, 2010 10:04:17 am 42Bastian wrote:
> A symbol defined in the linker script is an address.

Shouldn't matter. The compiler doesn't know that. The compiler thinks that the 
object will be an integer, and it is complaining before the linker is invoked.

In that vein,

extern const uint32_t *_etext;

also fails with the same error (initializer element is not constant). 

Here's a simple test case. I had to use longs since I'm on x86_64 on my 
desktop.

extern const long foo;

typedef struct {
        long a;
        long b;
        long c;
} the_struct_t;

const the_struct_t const the_struct = {
        .a = foo,
        .b = 2,
        .c = 3,
};

Adjust the .a = foo appropriately for casting as needed.

Compile with gcc -c -o constinit.o constinit.c.

extern const long foo;
extern const long *foo;

both fail with the same error.

extern const long foo[];

Does not.

-A.