From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 31 17:32:50 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 124BB106564A for ; Fri, 31 Oct 2008 17:32:50 +0000 (UTC) (envelope-from neldredge@math.ucsd.edu) Received: from euclid.ucsd.edu (euclid.ucsd.edu [132.239.145.52]) by mx1.freebsd.org (Postfix) with ESMTP id CCC308FC1A for ; Fri, 31 Oct 2008 17:32:49 +0000 (UTC) (envelope-from neldredge@math.ucsd.edu) Received: from zeno.ucsd.edu (zeno.ucsd.edu [132.239.145.22]) by euclid.ucsd.edu (8.11.7p3+Sun/8.11.7) with ESMTP id m9VHWn627347; Fri, 31 Oct 2008 10:32:49 -0700 (PDT) Received: from localhost (neldredg@localhost) by zeno.ucsd.edu (8.11.7p3+Sun/8.11.7) with ESMTP id m9VHWmA19123; Fri, 31 Oct 2008 10:32:49 -0700 (PDT) X-Authentication-Warning: zeno.ucsd.edu: neldredg owned process doing -bs Date: Fri, 31 Oct 2008 10:32:47 -0700 (PDT) From: Nate Eldredge X-X-Sender: neldredg@zeno.ucsd.edu To: Andriy Gapon In-Reply-To: <490B05BA.9090306@icyb.net.ua> Message-ID: References: <4909DC03.1080901@icyb.net.ua> <20081030184625.GA99398@server.vk2pj.dyndns.org> <490B05BA.9090306@icyb.net.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-hackers@freebsd.org Subject: Re: memtest86+ can not link: binutils issue? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Oct 2008 17:32:50 -0000 On Fri, 31 Oct 2008, Andriy Gapon wrote: > on 30/10/2008 20:46 Peter Jeremy said the following: >> On 2008-Oct-30 18:08:35 +0200, Andriy Gapon wrote: >>> ld --warn-constructors --warn-common -static -T memtest_shared.lds \ >>> -o memtest_shared head.o reloc.o main.o test.o init.o lib.o >>> patn.o screen_buffer.o config.o linuxbios.o memsize.o pci.o controller.o >>> random.o extra.o spd.o error.o dmi.o && \ >>> ld -shared -Bsymbolic -T memtest_shared.lds -o memtest_shared >>> head.o reloc.o main.o test.o init.o lib.o patn.o screen_buffer.o >>> config.o linuxbios.o memsize.o pci.o controller.o random.o extra.o spd.o >>> error.o dmi.o >>> head.o(.text+0x7): In function `startup_32': >>> : undefined reference to `_GLOBAL_OFFSET_TABLE_' >>> Segmentation fault (core dumped) >>> gmake: *** [memtest_shared] Error 139 >> >> I can't help here. _GLOBAL_OFFSET_TABLE_ is related to the binutils >> PIC support and it appears that the linker doesn't like the code (in >> head.S) is explicitly referencing it. >> >>> Not only linking fails, but ld even crashes. >> >> I agree this shouldn't happen. >> >>> Can anybody suggest anything about this problem? >> >> It looks like stand-alone PIC code on FreeBSD needs some different >> incantations to Linux. My understanding is that several of the >> i386 bootstraps are relocatable so you might like to peruse the >> code in /usr/src/sys/boot/i386 for ideas. > > I wonder if this is something about out port of binutils or is it an > issue in older version of binutils. > I'll try to look at the boot code, thank you for the hint. FreeBSD's version of binutils is quite old. I've definitely found bugs in it which are fixed in GNU's current version. So you might try building the official GNU binutils and see if that works any better. I don't know if it will fix your error but maybe it at least won't crash. ld crashing is definitely a bug, and it would be nice if you could file a PR, including the object files. If the GNU version doesn't crash that would be useful information for the PR also, as it might encourage Them to consider importing a newer version. -- Nate Eldredge neldredge@math.ucsd.edu