[U-Boot-Users] Re: MIPS LE build problems
Jerry Van Baren
gerald.vanbaren at smiths-aerospace.com
Thu Aug 18 20:31:25 CEST 2005
Matej Kupljen wrote:
> Hi
>
>
>>So is there a clever way to "ask" gcc which endianess it's using?
>>I tried to come up with one but failed so far...
>
>
> I am searching how to do that.
> How about if the config.mk runs a little test program, like
> configure does?
>
> For example:
>
> #include <stdio.h>
> #include <stdlib.h>
> int main(int argc, char **argv)
> {
> unsigned int data = 0x01234567;
> char *ptr = (char *)&data;
> if (ptr[0] == 0x01 && ptr[1] == 0x23 && ptr[2] == 0x45 && ptr[3] == 0x67)
> printf("big\n");
> else if (ptr[3] == 0x01 && ptr[2] == 0x23 && ptr[1] == 0x45 && ptr[0] == 0x67)
> printf("little\n");
> else
> printf("unknown\n");
> return 0;
> }
>
> And then check the output of this program and decides to pass the -EL or -EB
> to LDFLAGS.
>
> Oh, do you know why I have to use the:
> -Wa,-allow_branch_to_undefined
> instead of:
> -Wa,-mips_allow_branch_to_undefined
> even though (I guess) I use the same patch as you do?
>
> And why don't you accept the patch that eliminates this patch to
> binutils?
>
> BR,
> Matej
As noted in other email in this thread, executing the above code won't
work. What about simply compiling a file containing:
constant int data = 0x01234567;
objdumping the data section, and looking (grepping) to see if the data
section has 0x12345678 or 0x78563412?
Speculating ignorantly...
gvb
More information about the U-Boot
mailing list