memtest86+ can not link: binutils issue?

Andriy Gapon avg at icyb.net.ua
Fri Oct 31 06:18:59 PDT 2008


on 30/10/2008 20:46 Peter Jeremy said the following:
> On 2008-Oct-30 18:08:35 +0200, Andriy Gapon <avg at icyb.net.ua> wrote:
>> 1. obtain and extract
>> http://www.memtest.org/download/2.01/memtest86+-2.01.bin.gz
> 
> This is a compressed bootable image and can't be compiled.  Possibly
> you mean http://www.memtest.org/download/2.01/memtest86+-2.01.tar.gz

Sorry - yes, this was it.

>> 2. run gmake:
>> $ gmake
>> gcc -E -traditional head.S -o head.s
>> as -32   -o head.o head.s
>> gcc -c -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin
>> -ffreestanding -fPIC -fno-strict-aliasing reloc.c
>> gcc -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin
>> -ffreestanding -fPIC   -c -o main.o main.c
>> gcc -c -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin
>> -ffreestanding test.c
> 
> Blows up at this point for me:
> gcc -c -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin -ffreestanding test.c
> test.c:14:20: error: sys/io.h: No such file or directory
> test.c: In function 'beep':
> test.c:1410: warning: implicit declaration of function 'outb_p'
> test.c:1410: warning: implicit declaration of function 'inb_p'
> test.c:1417: warning: implicit declaration of function 'outb'
> gmake: *** [test.o] Error 1
> 
> I can't find <sys/io.h> in CVS or any declarations for outb_p or inb_p
> in my source tree.

Sorry again - I patched this file to remove inclusion of this
linux-specific file and instead include machine/cpufunc.h, also I
changed outb_p => outb, inb_p => inb and swapped parameters of outb-s.
These are typical linuxisms.

>> 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.


-- 
Andriy Gapon


More information about the freebsd-hackers mailing list