From owner-freebsd-amd64@FreeBSD.ORG Fri Mar 25 03:52:48 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 17CAB16A4CE; Fri, 25 Mar 2005 03:52:48 +0000 (GMT) Received: from hadar.amcc.com (hadar.amcc.com [192.195.69.168]) by mx1.FreeBSD.org (Postfix) with ESMTP id 68C5943D41; Fri, 25 Mar 2005 03:52:47 +0000 (GMT) (envelope-from vkashyap@amcc.com) Received: from mailhost01.amcc.com ([192.195.69.30]) by hadar.amcc.com (Netscape Messaging Server 4.15) with SMTP id IDW2S101.STY; Thu, 24 Mar 2005 19:52:49 -0800 Received: (from vkashyap-pc [10.66.6.61]) by mailhost01.amcc.com (SMSSMTP 4.0.0.59) with SMTP id M2005032419554319947 ; Thu, 24 Mar 2005 19:55:43 -0800 From: "Vinod Kashyap" To: Sean McNeil Date: Thu, 24 Mar 2005 19:51:49 -0800 X-Sent-Folder-Path: Sent Items X-Mailer: Oracle Connector for Outlook 9.0.4 51114 (9.0.6627) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Message-ID: cc: Peter Jeremy cc: freebsd-stable@freebsd.org cc: freebsd-amd64@freebsd.org 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: Fri, 25 Mar 2005 03:52:48 -0000 > -----Original Message----- > From: Sean McNeil [mailto:sean@mcneil.com] > Sent: Thursday, March 24, 2005 7:15 PM > To: Vinod Kashyap > Cc: Peter Jeremy; freebsd-stable@freebsd.org; = > freebsd-amd64@freebsd.org > Subject: RE: undefined reference to `memset' > = > = > Vinod, > = > On Thu, 2005-03-24 at 19:01 -0800, Vinod Kashyap wrote: > > Just like the problem is not seen when I build only the module, it's > > not seen if I simply write a foo.c (with the example code) = > and compile it. > > That's the reason I posted the patch to /sys/dev/twa/twa.c, = > which would > > cause the problem if applied, and then followed with a kernel build. > > I can send the result of running nm on twa.o tomorrow. > = > Please take a look at other messages in this thread, like some of the > ones I have posted. They clearly show your problem in a small example > and how it is happening in the -O2 case as memset is being optimized > away. -O would appear to do the right thing and adding > -minline-all-stringops (at either optimization level) would = > produce even > better code. > = I did look at your posting Sean, thanks. But did you see the "undefined reference to `memset'" linker error when you built it? It's obvious that a reference to memset is being generated by the initialization of an array of 100 bytes to 0. The linker is getting the needed memset if you build a stand alone program, or even build a stand= alone kernel module, but is not being able to find it when building the kernel itself. This implies to me that it is a difference in the use of flags, or linking/not linking with particular libraries that's causing the problem. I am also confused as to how an explicit call to memset works, when compiler generated call doesn't! Are we talking 2 different memset's here? Maybe a memset and an __memset?