fstatfs break in amd64 ia32 emulation

Carlos F. A. Paniago pan at cnpm.embrapa.br
Thu Mar 31 10:07:26 PST 2005


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???

Paniago                 

-- 
Nome:  Carlos Fernando Assis Paniago
Email: pan at cnpm.embrapa.br		Fone: +55 (19) 3256-60-30
Web:   http://www.cnpm.embrapa.br/	Fax:  +55 (19) 3254-11-00
--



More information about the freebsd-amd64 mailing list