32 bit FreeBSD compiled binary coredumps on 64 bit(amd) FreeBSD

Peter Jeremy peterjeremy at optushome.com.au
Thu Feb 21 07:59:45 UTC 2008

On Wed, Feb 20, 2008 at 11:46:00AM +0530, navneet Upadhyay wrote:
>       I am compiling the binary on 32 bit FreeBSD and running it on 64
>(amd64)bit FreeBSD . FreeBSD says it is possible to do so.

In general, you can take a FreeBSD/i386 executable and run it on
FreeBSD/amd64.  I don't believe FreeBSD has ever stated that you
can take _any_ FreeBSD/i386 executable and run it on FreeBSD/amd64.

>       But my application core dumps . I investigated the reason which is as
>follows :
>The problem is in the call *retval = sysctl(mib, 4, &kp, &sz, NULL, 0);*
>where sz is size of kp and where *kp* is a structure of type
>*kinfo_proc.*The size of this structure on 32bit system is 768 and on
>64 bit system is 1088.

If your process grovels around inside kernel data structures then it's
unlikely to be portable.

>If i hardcode the sz to 1088 then it works on amd64 systems , how do i deal
>with it. I am anticipating lot of coredumps like that, what is a generic
>solution for such kinds of problems.

There is no generic solution.  FreeBSD includes shims to handle
syscalls where the arguments differ in size between different
emulations (i386, Linux, iBCS etc).  If you want to pull assorted
machine-dependent datastructures out of the kernel then you will
need to write shims to handle the conversion.

Peter Jeremy
Please excuse any delays as the result of my ISP's inability to implement
an MTA that is either RFC2821-compliant or matches their claimed behaviour.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-amd64/attachments/20080221/93d9e507/attachment.pgp

More information about the freebsd-amd64 mailing list