32-bit binary compatibility on 5.3-amd64

John Baldwin jhb at FreeBSD.org
Mon Jan 31 14:54:47 PST 2005


On Friday 28 January 2005 11:44 pm, Joseph Koshy wrote:
> 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.

Because amd64 doesn't have LDTs.  Peter has hacks in place in the dynamic 
32-bit libraries that amd64 uses to use the different backing methods for 
implementing TLS on amd64, but that stuff wasn't in 5.3.  It might be in 
5.3-STABLE.

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