This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: big-endian file format
- From: Ian Lance Taylor <iant at google dot com>
- To: Jeff Kenton <jkenton at tilera dot com>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: Tue, 11 Jan 2011 15:17:30 -0800
- Subject: Re: big-endian file format
- References: <4D2CD0CB.1030203@tilera.com>
Jeff Kenton <jkenton@tilera.com> writes:
> 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?
Something is broken, probably the assembler.
Ian