This is the mail archive of the binutils@sources.redhat.com 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: objcopy / binary inclusion weirdness (repost)



>   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.


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