Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 580212

Summary: sys-apps/memtest86+-5.01-r1 with gold: syslinux reports "Invalid argument."
Product: Gentoo Linux Reporter: Matt Whitlock <gentoo>
Component: [OLD] Core systemAssignee: Gentoo's Team for Core System packages <base-system>
Status: RESOLVED FIXED    
Severity: normal CC: ansla80
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 269315    

Description Matt Whitlock 2016-04-16 10:18:09 UTC
Attempting to boot Memtest86+ 5.01, linked using Gold, causes EXTLINUX to report the error "Invalid argument." Rebuilding Memtest86+ using the BFD linker produces a binary that boots correctly.

You can see there is a significant difference in the file size of the produced binary when built using Gold versus BFD ld.

$ x86_64-pc-linux-gnu-ld --version | head -n1
GNU gold (Gentoo 2.25.1 p1.1 2.25.1) 1.11

# ebuild /usr/portage/sys-apps/memtest86+/memtest86+-5.01-r1.ebuild clean install &>/dev/null && ls -l /var/tmp/portage/sys-apps/memtest86+-5.01-r1/image/boot/memtest86plus
total 344
-rw-r--r-- 1 root root 175260 16-Apr-2016 06:11 memtest
lrwxrwxrwx 1 root root      7 16-Apr-2016 06:11 memtest.bin -> memtest
-rw-r--r-- 1 root root 172648 16-Apr-2016 06:11 memtest.netbsd

# cat > /etc/portage/env/sys-apps/memtest86+ <<EOF
post_src_prepare() {
	default
	tc-ld-disable-gold
}
EOF

# ebuild /usr/portage/sys-apps/memtest86+/memtest86+-5.01-r1.ebuild clean install &>/dev/null && ls -l /var/tmp/portage/sys-apps/memtest86+-5.01-r1/image/boot/memtest86plus
total 364
-rw-r--r-- 1 root root  182704 16-Apr-2016 06:13 memtest
lrwxrwxrwx 1 root root       7 16-Apr-2016 06:13 memtest.bin -> memtest
-rw-r--r-- 1 root root 1228860 16-Apr-2016 06:13 memtest.netbsd


Suggest adding a call to "tc-ld-disable-gold" in the ebuild to force usage of the BFD linker.
Comment 1 om3i 2016-04-28 09:03:38 UTC
ld.gold mislinks both sys-apps/memtest86 and sys-apps/memtest86+:
file /boot/memtest86/memtest /boot/memtest86plus/memtest /boot/memtest86plus/memtest.netbsd 
/boot/memtest86/memtest:            ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, stripped
/boot/memtest86plus/memtest:        ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, stripped
/boot/memtest86plus/memtest.netbsd: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped

Look at official binaries:
file memtest86*
memtest86+-5.01.bin: DOS/MBR boot sector
memtest86-6.3.0.bin: DOS/MBR boot sector

Custom built with gold (which are ELF) won't boot with lilo, while offical binaries which are boot sector work. Custom built with ld.bfd work.