Re: memtest86+ can not link: binutils issue?

2008-12-12 Thread Andriy Gapon
on 31/10/2008 15:18 Andriy Gapon said the following:
 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)

Just in case anybody still remembers this issue.
It seams that the main culprit here was the following line in the linker
script:

OUTPUT_FORMAT(elf32-i386);

I was tipped just today that it should have read:
OUTPUT_FORMAT(elf32-i386-freebsd, elf32-i386-freebsd,
elf32-i386-freebsd);

-- 
Andriy Gapon
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: memtest86+ can not link: binutils issue?

2008-10-31 Thread Andriy Gapon
on 30/10/2008 20:46 Peter Jeremy said the following:
 On 2008-Oct-30 18:08:35 +0200, Andriy Gapon [EMAIL PROTECTED] 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
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: memtest86+ can not link: binutils issue?

2008-10-31 Thread Nate Eldredge

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 [EMAIL PROTECTED] 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
[EMAIL PROTECTED]
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


memtest86+ can not link: binutils issue?

2008-10-30 Thread Andriy Gapon

0.
FreeBSD 7.1-PRERELEASE r184195 i386
$ ld -v
GNU ld version 2.15 [FreeBSD] 2004-05-23

1. obtain and extract
http://www.memtest.org/download/2.01/memtest86+-2.01.bin.gz

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
gcc -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin
-ffreestanding -fPIC   -c -o init.o init.c
gcc -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin
-ffreestanding -fPIC   -c -o lib.o lib.c
gcc -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin
-ffreestanding -fPIC   -c -o patn.o patn.c
gcc -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin
-ffreestanding -fPIC   -c -o screen_buffer.o screen_buffer.c
gcc -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin
-ffreestanding -fPIC   -c -o config.o config.c
gcc -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin
-ffreestanding -fPIC   -c -o linuxbios.o linuxbios.c
gcc -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin
-ffreestanding -fPIC   -c -o memsize.o memsize.c
gcc -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin
-ffreestanding -fPIC   -c -o pci.o pci.c
gcc -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin
-ffreestanding -fPIC   -c -o controller.o controller.c
gcc -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin
-ffreestanding -fPIC   -c -o random.o random.c
gcc -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin
-ffreestanding -fPIC   -c -o extra.o extra.c
gcc -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin
-ffreestanding -fPIC   -c -o spd.o spd.c
gcc -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin
-ffreestanding -fPIC   -c -o error.o error.c
gcc -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin
-ffreestanding -fPIC   -c -o dmi.o dmi.c
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


Not only linking fails, but ld even crashes.
Things are more complicated than usual because of the custom linker
script memtest_shared.lds.

The same compiles/links nicely on Fedora 9.
$ ld -v
GNU ld version 2.18.50.0.6-5.fc9 20080403


Can anybody suggest anything about this problem?
If somebody is working on newer version of binuitls for FreeBSD I can
help as a tester.

-- 
Andriy Gapon
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: memtest86+ can not link: binutils issue?

2008-10-30 Thread Peter Jeremy
On 2008-Oct-30 18:08:35 +0200, Andriy Gapon [EMAIL PROTECTED] 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

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.

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.

-- 
Peter Jeremy
Please excuse any delays as the result of my ISP's inability to implement
an MTA that is either RFC2821-compliant or matches their claimed behaviour.


pgpmHMDH1fDJe.pgp
Description: PGP signature