From owner-freebsd-amd64@FreeBSD.ORG Thu Mar 24 22:10:35 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 67CFC16A4CE for ; Thu, 24 Mar 2005 22:10:35 +0000 (GMT) Received: from mail.mcneil.com (mcneil.com [24.199.45.54]) by mx1.FreeBSD.org (Postfix) with ESMTP id 23B4043D4C for ; Thu, 24 Mar 2005 22:10:35 +0000 (GMT) (envelope-from sean@mcneil.com) Received: from localhost (localhost.mcneil.com [127.0.0.1]) by mail.mcneil.com (Postfix) with ESMTP id C3D64F3EE9; Thu, 24 Mar 2005 14:10:32 -0800 (PST) Received: from mail.mcneil.com ([127.0.0.1]) by localhost (server.mcneil.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 02642-03; Thu, 24 Mar 2005 14:10:31 -0800 (PST) Received: from mcneil.com (mcneil.com [24.199.45.54]) by mail.mcneil.com (Postfix) with ESMTP id A626FF3EB8; Thu, 24 Mar 2005 14:10:31 -0800 (PST) From: Sean McNeil To: freebsd-amd64@freebsd.org In-Reply-To: <20050324214956.GA99087@dragon.NUXI.org> References: <20050324214956.GA99087@dragon.NUXI.org> Content-Type: multipart/mixed; boundary="=-wLOup4CYUrnuKOU6OdqB" Date: Thu, 24 Mar 2005 14:10:31 -0800 Message-Id: <1111702231.2655.6.camel@server.mcneil.com> Mime-Version: 1.0 X-Mailer: Evolution 2.2.1.1 FreeBSD GNOME Team Port X-Virus-Scanned: by amavisd-new at mcneil.com X-Content-Filtered-By: Mailman/MimeDel 2.1.1 Subject: Re: undefined reference to `memset' X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Mar 2005 22:10:35 -0000 --=-wLOup4CYUrnuKOU6OdqB Content-Type: text/plain Content-Transfer-Encoding: 7bit On Thu, 2005-03-24 at 13:49 -0800, David O'Brien wrote: > Please don't top-post -- it destroys context. [Format recovered] > > On Thu, Mar 24, 2005 at 12:46:41PM -0800, Vinod Kashyap wrote: > > > On Thu, Mar 24, 2005 at 06:05:17PM +1100, Peter Jeremy wrote: > > > > On Wed, 2005-Mar-23 13:48:04 -0800, Vinod Kashyap wrote: > > > > >If any kernel module has the following, or a similar line in it: > > > > >----- > > > > >char x[100] = {0}; > > > > >----- > > > > >building of the GENERIC kernel on FreeBSD 5 -STABLE for amd64 > > > > >as of 03/19/05, fails with the following message at the > > > time of linking: > > > > >"undefined reference to `memset'". > > > > > > > > > >The same problem is not seen on i386. > > > > > > > > > >The problem goes away if the above line is changed to: > > > > >----- > > > > >char x[100]; > > > > >memset(x, 0, 100); > > > > >----- > > > > > > > > Can you post a complete (compilable) example please. > > > > > > Vinod can you please post a complete compilable example? > > > It is impossible to get anything done about your issue without stand > > > alone test code. > > Ok, make sure you have 'device twa' in your kernel configuration > > file, and apply these patches to /sys/dev/twa/twa.c. > > This patch causes the problem: > > "stand alone" means a single foo.c file that shows the problem you want > fixed. > I cannot submit a GCC bug report with a tarball of the entire FreeBSD > kernel. I've taken the liberty to write up an example here. Not sure if this is a bug or not: cc -O -pipe -c -fno-builtin -ffreestanding memset_bug.c Take a look at what is generated: objdump --disassemble memset_bug.o You'll see that instead of performing the inline code generation for memset, the compiler generates a call to memset in the case of the assignment of {0}. memset_bug.c: #include static __inline void * memset(void *b, int c, size_t len) { char *bb; if (c == 0) bzero(b, len); else for (bb = (char *)b; len--; ) *bb++ = c; return (b); } void bug (void) { int buf[100] = { 0 }; memset (buf, sizeof(buf), 0); printf ("%d\n", buf[0]); } Attached as well. Cheers, Sean --=-wLOup4CYUrnuKOU6OdqB--