32-bit binary compatibility on 5.3-amd64

Joseph Koshy joseph.koshy at gmail.com
Fri Jan 28 20:44:32 PST 2005


rw> a ktrace is attached for this sample code:

Here is the culprit:

src/lib/libc/i386/gen/_set_tp.c:

        sel = i386_set_ldt(LDT_AUTO_ALLOC, &ldt, 1);
        __asm __volatile("movl %0,%%gs" : : "rm" ((sel << 3) | 7));

i386_set_ldt() will return -1 on the AMD64 since this
function is not supported there.  The lack of error checking
means that -1 will be attempted to be loaded into %gs by the
movl instruction, leading to a processor protection fault and
a process SIGSEGV.

Compiling your sample program with '-static' under a 4.X
environment yields an executable that runs on the AMD64.

On 5.X both statically linked and dynamically linked
executables appear to call _init_tls() and _set_tp()
and are consequently not usable in IA32 emulation
mode.

Clearly our IA32 emulation needs work.  I've no idea
why we don't support a sysarch(I386_{GET,SET}_LDT) operation
for IA32 executables.

-- 
FreeBSD Volunteer, http://people.freebsd.org/~jkoshy


More information about the freebsd-amd64 mailing list