objcopy / binary inclusion weirdness (repost)

DJ Delorie dj@delorie.com
Tue Feb 26 18:08:00 GMT 2002


>   extern u8* _binary_sprite_start;
> 
> causes a segfault, but
> 
>   extern u8  _binary_sprite_start[];
> 
> allows me to reference the data as I'd expect.  What's the difference from
> the linker's point of view?

In the first case, the symbol _binary_sprite_start refers to four
bytes of memory which contain an address, which is the address of some
*other* chunk of memory that contains the raw data.

In the second case, the symbol _binary_sprite_start refers directly to
the chunk of memory that contains the raw data.

If your raw data was the string "abcdefg", then in the first case
you'd be referring to the memory as if it were an address, and you'd
get the bogus address 0x61626364 (hex values for 'a', 'b', 'c', and
'd') (of 0x64636261 for little-endian machines).

Consider this standard C source:

	int *a;
	int b;

Both refer to four bytes of memory, but one contains the address of
another four bytes of memory that contain an integer, while the other
itself contains an integer.



More information about the Binutils mailing list