From owner-freebsd-amd64@FreeBSD.ORG Sat Jan 29 04:44:31 2005 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E1B3016A4CE for ; Sat, 29 Jan 2005 04:44:31 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.206]) by mx1.FreeBSD.org (Postfix) with ESMTP id 179FC43D45 for ; Sat, 29 Jan 2005 04:44:30 +0000 (GMT) (envelope-from joseph.koshy@gmail.com) Received: by rproxy.gmail.com with SMTP id z35so551003rne for ; Fri, 28 Jan 2005 20:44:29 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=CtjeV+fYO2RkXuCyQAV80gGzdgVEADZOt/sWX2ZPlb/1G4wdzhjUbVEyh3rPkQTAlyvkoOSvhJTP1X7APV47Tp2a5OO0EEBW8Jr4LzvfjPgT9AtctlSQ5OSzp1OH48eIfquuE/NnTcuEzby5qC/7d64WTNizr6v44u0NK9pECtA= Received: by 10.38.104.22 with SMTP id b22mr223569rnc; Fri, 28 Jan 2005 20:44:29 -0800 (PST) Received: by 10.38.209.12 with HTTP; Fri, 28 Jan 2005 20:44:29 -0800 (PST) Message-ID: <84dead72050128204479414c88@mail.gmail.com> Date: Sat, 29 Jan 2005 04:44:29 +0000 From: Joseph Koshy To: Rob Watt In-Reply-To: <20050128105930.V54223@daemon.mistermishap.net> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <20050127100818.M46092@daemon.mistermishap.net> <84dead72050127201552e14c04@mail.gmail.com> <20050128105930.V54223@daemon.mistermishap.net> cc: freebsd-amd64@freebsd.org Subject: Re: 32-bit binary compatibility on 5.3-amd64 X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Joseph Koshy List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Jan 2005 04:44:32 -0000 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