From owner-freebsd-alpha Fri Aug 20 7:29:49 1999 Delivered-To: freebsd-alpha@freebsd.org Received: from duke.cs.duke.edu (duke.cs.duke.edu [152.3.140.1]) by hub.freebsd.org (Postfix) with ESMTP id E36B814BCF; Fri, 20 Aug 1999 07:29:44 -0700 (PDT) (envelope-from gallatin@cs.duke.edu) Received: from grasshopper.cs.duke.edu (grasshopper.cs.duke.edu [152.3.145.30]) by duke.cs.duke.edu (8.9.1/8.9.1) with ESMTP id KAA08361; Fri, 20 Aug 1999 10:27:46 -0400 (EDT) Received: (from gallatin@localhost) by grasshopper.cs.duke.edu (8.9.3/8.9.1) id KAA91199; Fri, 20 Aug 1999 10:27:46 -0400 (EDT) (envelope-from gallatin@cs.duke.edu) From: Andrew Gallatin MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Fri, 20 Aug 1999 10:27:35 -0400 (EDT) To: Doug Rabson Cc: current@FreeBSD.ORG, alpha@FreeBSD.ORG Subject: Re: cc -O broken in -current for Alpha KLDs In-Reply-To: References: <14268.1961.256187.86499@grasshopper.cs.duke.edu> X-Mailer: VM 6.43 under 20.4 "Emerald" XEmacs Lucid Message-ID: <14269.25728.498019.956479@grasshopper.cs.duke.edu> Sender: owner-freebsd-alpha@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Doug Rabson writes: > On Thu, 19 Aug 1999, Andrew Gallatin wrote: > > > > > I do most of my development on alphas & I just turned some local code > > into a loadable kernel module. It works fine when compiled into the > > kernel statically, but fails miserably when loaded into an alpha > > kernel as a module. This alpha is running -current from monday or > > so. > > > > After a day or so of debugging, I decided to run > > it on an x86 -- it ran just fine. I've narrowed the problem down to > > one involving optimization and have extracted a simple, reproducable > > test case. > > > > When the test module is loaded without optimization (CFLAGS += -g > > -O0), it prints the following (which is correct): > > It looks like we aren't handling the relocations correctly. When I get a > chance, I will try to look at it. If you want to have another look, the > code at fault is probably in alpha/alpha/elf_machdep.c and you can get a > list of relocations in the module with 'objdump --dynamic-reloc foo.ko'. Thanks for the pointer, it was right on the money. It turns out that at the default optimization level, the objdump output looks like this: <...> 0000000000010ea8 RELATIVE *ABS* 0000000000010e80 GLOB_DAT Xmit_completes+0x0000000000000028 0000000000010e88 GLOB_DAT Xmit_completes+0x0000000000000008 0000000000010e90 GLOB_DAT Xmit_completes+0x0000000000000010 0000000000010e98 GLOB_DAT Xmit_completes+0x0000000000000018 0000000000010ea0 GLOB_DAT Xmit_completes 0000000000010e70 JMP_SLOT printf <...> I've just committed a patch to alpha/alpha/elf_machdep.c which takes into account the addends for objects of type R_ALPHA_GLOB_DAT. This fixes my problem. Should it be MFC'ed? Thanks again, Drew ------------------------------------------------------------------------------ Andrew Gallatin, Sr Systems Programmer http://www.cs.duke.edu/~gallatin Duke University Email: gallatin@cs.duke.edu Department of Computer Science Phone: (919) 660-6590 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-alpha" in the body of the message