From owner-freebsd-current@FreeBSD.ORG Mon May 24 04:49:59 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3F62A106566C for ; Mon, 24 May 2010 04:49:59 +0000 (UTC) (envelope-from okuno.kohji@jp.panasonic.com) Received: from smtp.mei.co.jp (smtp.mei.co.jp [133.183.100.20]) by mx1.freebsd.org (Postfix) with ESMTP id D5B858FC14 for ; Mon, 24 May 2010 04:49:58 +0000 (UTC) Received: from mail-gw.jp.panasonic.com ([157.8.1.145]) by smtp.mei.co.jp (8.12.11.20060614/3.7W/kc-maile14) with ESMTP id o4O4nvIm002109 for ; Mon, 24 May 2010 13:49:57 +0900 (JST) Received: from epochmail.jp.panasonic.com (localhost [127.0.0.1]) by mail.jp.panasonic.com (8.11.6p2/3.7W/kc-maili01) with ESMTP id o4O4nuA05108 for ; Mon, 24 May 2010 13:49:56 +0900 (JST) Received: by epochmail.jp.panasonic.com (8.12.11.20060308/3.7W/somla6) id o4O4nvYw006214 for freebsd-current@freebsd.org; Mon, 24 May 2010 13:49:57 +0900 (JST) Received: from localhost by somla6.jp.panasonic.com (8.12.11.20060308/3.7W) with ESMTP id o4O4nuaY006183 for ; Mon, 24 May 2010 13:49:56 +0900 (JST) Date: Mon, 24 May 2010 13:49:55 +0900 (JST) Message-Id: <20100524.134955.2300883222251175323.okuno.kohji@jp.panasonic.com> To: freebsd-current@freebsd.org From: Kohji Okuno Organization: Panasonic Corporation X-Mailer: Mew version 6.3 on Emacs 23.2 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: About 32bit binary on amd64 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 May 2010 04:49:59 -0000 Hi all, I want to compile 32bit binary on amd64, but I met with the problem. Could you teach me the best solution, please? My environment is FreeBSD 8.1-PRERELEASE #0: Tue May 18 12:01:26 JST 2010. I compiled and executed test.c as below on amd64. -- begin -- test.c ------------------------------------------------------ #include #include #include #include int main() { void *ptr; ptr = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0); if (ptr == MAP_FAILED) { perror("mmap"); exit(1); } printf("%lx\n", (unsigned long)ptr); munmap(ptr, 4096); exit(0); } -- end -- test.c -------------------------------------------------------- % gcc -m32 -B/usr/lib32 test.c % ./a.out mmap: Invalid argument I disassembled a.out. I think that 'movl $0x0,0x18(%esp)' is needed. This error is occured by 'off_t offset'. 80484ce: 83 ec 34 sub $0x34,%esp 80484d1: c7 44 24 14 00 00 00 movl $0x0,0x14(%esp) 80484d8: 00 80484d9: c7 44 24 10 ff ff ff movl $0xffffffff,0x10(%esp) 80484e0: ff 80484e1: c7 44 24 0c 00 10 00 movl $0x1000,0xc(%esp) 80484e8: 00 80484e9: c7 44 24 08 03 00 00 movl $0x3,0x8(%esp) 80484f0: 00 80484f1: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp) 80484f8: 00 80484f9: c7 04 24 00 00 00 00 movl $0x0,(%esp) 8048500: e8 43 fe ff ff call 8048348 I found this solution. I modified machine depended header as below. # cd /usr/include/machine # cp /usr/src/sys/i386/include/_types.h _types32.h # patch < _types.h.diff -- begin -- _types.h.diff ------------------------------------------------ --- _types.h.org 2010-05-24 13:34:55.406874258 +0900 +++ _types.h 2010-05-24 13:35:33.790522354 +0900 @@ -36,6 +36,10 @@ * $FreeBSD: src/sys/amd64/include/_types.h,v 1.12.2.1 2009/08/03 08:13:06 kensmith Exp $ */ +#ifdef __i386__ +#include +#else + #ifndef _MACHINE__TYPES_H_ #define _MACHINE__TYPES_H_ @@ -115,3 +119,4 @@ #endif #endif /* !_MACHINE__TYPES_H_ */ +#endif /* __i386__ */ -- end -- _types.h.diff ---------------------------------------------- In this case, 'off_t offset' is set correctly as below. 80484d1: c7 44 24 14 00 00 00 movl $0x0,0x14(%esp) 80484d8: 00 80484d9: c7 44 24 18 00 00 00 movl $0x0,0x18(%esp) 80484e0: 00 80484e1: c7 44 24 10 ff ff ff movl $0xffffffff,0x10(%esp) 80484e8: ff 80484e9: c7 44 24 0c 00 10 00 movl $0x1000,0xc(%esp) 80484f0: 00 80484f1: c7 44 24 08 03 00 00 movl $0x3,0x8(%esp) 80484f8: 00 80484f9: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp) 8048500: 00 8048501: c7 04 24 00 00 00 00 movl $0x0,(%esp) 8048508: e8 3b fe ff ff call 8048348 How should we deal with this problem? Best reards, Kohji Okuno