From owner-freebsd-amd64@FreeBSD.ORG Sun Oct 23 23:27:28 2011 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 225A2106566B; Sun, 23 Oct 2011 23:27:28 +0000 (UTC) (envelope-from llwang@llwang.org) Received: from mail-yx0-f182.google.com (mail-yx0-f182.google.com [209.85.213.182]) by mx1.freebsd.org (Postfix) with ESMTP id CCFC58FC13; Sun, 23 Oct 2011 23:27:27 +0000 (UTC) Received: by yxt33 with SMTP id 33so1841443yxt.13 for ; Sun, 23 Oct 2011 16:27:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.124.4 with SMTP id w4mr31802066yhh.30.1319411091955; Sun, 23 Oct 2011 16:04:51 -0700 (PDT) Sender: llwang@llwang.org Received: by 10.236.47.168 with HTTP; Sun, 23 Oct 2011 16:04:51 -0700 (PDT) Date: Sun, 23 Oct 2011 18:04:51 -0500 X-Google-Sender-Auth: IrCwH1Vrt7OCMeoIbw5wlKGfvK0 Message-ID: From: "Li-Lun \"Leland\" Wang" To: freebsd-amd64@freebsd.org, freebsd-emulation@freebsd.org Content-Type: text/plain; charset=UTF-8 Cc: Subject: 32-bit binaries (e.g. wine) and 64-bit kernel structures X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Oct 2011 23:27:28 -0000 Hi, Although I only encounter this kind of problem when running wine (because it is one of the few ports that need to compile into 32-bit), it is a problem of i386 binaries on x64 FreeBSD in general. The problem that I'm running into recently is http://bugs.winehq.org/show_bug.cgi?id=28857 . In short, wine recently implemented GetUdpTable() for Mac OS and BSD. It uses sysctlbyname() to get net.inet.udp.pcblist, and parses it into xinpgen structures. However, the size of xinpgen is different on i386 and x64. As a result, when I run applications that call GetUdpTable(), the kernel supplies wine with 64-bit structures, while wine expects 32-bit structures, and crashes. They decided that this is a FreeBSD bug rather than a wine bug, and that the kernel or LD should know a 32-bit binary is being run and return proper structures, as is done in Mac OS. xinpgen is not the only structure of wrong sizes for 32-bit binaries on x64. A while ago I was trying to make my usb gamepad work on wine using the ugen device. libusbhid uses ioctl to get the usb_gen_descriptor structure, which is also of different sizes on i386 and x64. I had to manually "pad" the pointers to 64-bit and build a custom libusbhid for it to work. As it stands, they will probably not fix GetUdpTable() on wine side, and any windows applications that uses GetUdpTable() will not run properly in wine on FreeBSD x64. Do we have plans to fix this kind of problems in general? Although wine port on FreeBSD is only supported for ARCH=i386, could there be workarounds? -- llwang