Bug 1249

Summary: --hash-style=gnu support in ld not detected correctly if ld == gold
Product: uClibc Reporter: Bernhard Rosenkraenzer <bero>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: enhancement CC: uclibc-cvs
Priority: P5    
Version: 0.9.31   
Target Milestone: 0.9.32   
Hardware: Other   
OS: Linux   
Host: Target:
Build:
Attachments: fix

Description Bernhard Rosenkraenzer 2010-03-04 10:55:23 UTC
When enabling gnu hash support, uClibc's build process errors out with

Rules.mak:585: *** Your binutils do not support --hash-style option, while you want to use it.  Stop.
make: *** [pregen-headers] Error 2

even though binutils does support the --hash-style option.

Looking into what happens, Rules.mak runs this command to determine if --hash-style is supported:

armv6j-blankpage-linux-gnueabi-ld --hash-style=gnu -o /dev/null -b binary /dev/null

This fails, but not because of --hash-style=gnu:

armv6j-blankpage-linux-gnueabi-ld: fatal error: /dev/null: mmap failed: Invalid argument

strace-ing ld shows:

open("/dev/null", O_RDONLY|0x80000)     = 3
fstat(3, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 3), ...}) = 0
mmap(NULL, 0, PROT_READ, MAP_PRIVATE, 3, 0) = -1 EINVAL (Invalid argument)

mmap with a size of 0 fails with EINVAL since Linux 2.6.12
Comment 1 Bernhard Rosenkraenzer 2010-03-04 10:59:23 UTC
Created attachment 1195 [details]
fix

This patch is not very nice, but fixes the problem
Comment 2 Bernhard Reutner-Fischer 2010-03-04 15:20:29 UTC
which version of ld are you using?
Comment 3 Bernhard Rosenkraenzer 2010-03-04 15:33:37 UTC
2.20.51.0.6 -- and it turns out it was using gold by default, ld.bfd does work w/ the original detection method.
Comment 4 Khem Raj 2010-03-05 00:25:08 UTC
It could be a ld bug here. Verify if older ld works.
Comment 5 solar 2010-03-05 00:33:19 UTC
armv6j-blankpage-linux-gnueabi <-- How is this uClibc ? 
Sure looks like a GNU (glibc) built toolchain to me which would make this (INVALID).
Comment 6 Bernhard Reutner-Fischer 2012-04-18 17:09:57 UTC
Nowadays this works at least with gold-1.11 from binutils-2.22