fstatfs break in amd64 ia32 emulation

John Baldwin jhb at FreeBSD.org
Thu Mar 31 15:07:06 PST 2005


On Thursday 31 March 2005 01:08 pm, Carlos F. A. Paniago wrote:
> hi:
> I'm tring to compile in an amd64 and running in an i386.. I read in the
> list that is not possible, but some things work if we compile using:
> gcc -Di386 -D__i386__ -Uamd64 -U__amd64__ -m32 -B/lib32 -B/usr/lib32 -g
> -o test-i386.amd test-i386.c
> some simple program could be compiled in an amd64 machine and run in a
> i386 machine.
> but this program don't work:
> --
> #include <stdio.h>
> #include <sys/param.h>
> #include <sys/mount.h>
> #include <sys/errno.h>
>
> int main(int argc, char** argv)
> {
>         struct statfs buf;
>
>         if (fstatfs(0, &buf) < 0) {
>                 perror("fstatfs");
>         }
>
>         printf("%d %d\n", sizeof(buf), sizeof(&buf));
>         return 0;
> }
> --
> the result is:
> ---
> ipe# ./test-i386
> 472 4
> ipe# ./test-i386.amd
> 384 4
> Segmentation fault (core dumped)
> ipe#
> ---
> this ipe machine is an i386 machine... the ./test-i386 is compiled in
> this machine as
> gcc -g -o test-i386 test-i386.c
> and the ./test-i386.amd is compiled in an amd64 using: gcc -Di386
> -D__i386__ -Uamd64 -U__amd64__ -m32 -B/lib32 -B/usr/lib32 -g -o
> test-i386.amd test-i386.c
> The strange thing is the size of struct statfs that changes... If I
> compile this in an amd64 machine (oliveira is an amd64 machine)
> ---
> oliveira: {248} gcc -g -o test-i386.amd test-i386.c
> oliveira: {249} ./test-i386.amd
> 472 8
> oliveira: {250}
> ---
> strange the size of the struct is the same as in i386 and the size of
> the pointer is 8 (instead of 4), but in the compilation using the -m32
> the sizeof is strange... Someone know how to solve this problem???

You need to be using a different /usr/include, specifically a 
different /usr/include/machine (one from an i386 machine) when trying to 
compile -m32.

-- 
John Baldwin <jhb at FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org


More information about the freebsd-amd64 mailing list