This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
big-endian file format
- From: Jeff Kenton <jkenton at tilera dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Tue, 11 Jan 2011 16:51:07 -0500
- Subject: big-endian file format
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