big-endian file format

Jeff Kenton jkenton@tilera.com
Tue Jan 11 21:51:00 GMT 2011


With help from this list, I have built big-endian tools -- gcc, as, ld 
-- for our processor, running on a little-endian Intel platform.  For a 
simple program:

char g1 = 0x17;
short g2 = 0x27;
int g4 = 0x47;
long long g8 = 0x87;

int main(void)
{
   PASS(g1);
   PASS(g2);
   PASS(g4);
   PASS(g8);
   DONE(0);
   return 0;
}

Dump of object file .data section with od:

0000600 17 00 27 00 47 00 00 00 87 00 00 00 00 00 00 00

I see that the g1, g2, g4, g8 constants are laid out as little-endian 
numbers (i.e., LSB first) in the object file.  Is this to be expected 
when the tools run on a little-endian platform, or does this mean 
something is broken?

Thanks.

--jeff kenton




More information about the Gcc-help mailing list