Bug 176413

Summary: ld --as-needed behaviour changed
Product: [Fedora] Fedora Reporter: Dmitry V. Levin <ldv>
Component: binutilsAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: rawhide   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-12-22 13:23:37 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
zv.c none

Description Dmitry V. Levin 2005-12-22 13:16:46 UTC
The --as-needed behaviour seems to be changed in 2.16:

$ readelf -d /usr/lib/libz.so |grep -w NEEDED
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
$ readelf -d /usr/lib/libpng.so |grep -w NEEDED
 0x00000001 (NEEDED)                     Shared library: [libz.so.1]
 0x00000001 (NEEDED)                     Shared library: [libm.so.6]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
$ gcc -Wall -W zv.c -c

When linking with old ld (binutils-2.15.94.0.2.2-2 from FC4):
$ gcc zv.o -o zv -Wl,--as-needed -lz
$ readelf -d zv |grep -w NEEDED
 0x00000001 (NEEDED)                     Shared library: [libz.so.1]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
$ gcc zv.o -o zv -Wl,--as-needed -lpng
$ readelf -d zv |grep -w NEEDED
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x00000001 (NEEDED)                     Shared library: [libz.so.1]

When linking with new ld (binutils-2.16.91.0.3-2 from FC-devel):
$ gcc zv.o -o zv -Wl,--as-needed -lz
$ readelf -d zv |grep -w NEEDED
 0x00000001 (NEEDED)                     Shared library: [libz.so.1]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
$ gcc zv.o -o zv -Wl,--as-needed -lpng
zv.o: In function `main':
zv.c:(.text+0x23): undefined reference to `zlibVersion'
collect2: ld returned 1 exit status

Despite of the fact that new behaviour better fits to documentation
(http://sourceware.org/ml/binutils/2005-05/msg00611.html),
I must say that old behaviour better fits to my needs.

Comment 1 Dmitry V. Levin 2005-12-22 13:16:46 UTC
Created attachment 122526 [details]
zv.c

Comment 2 Jakub Jelinek 2005-12-22 13:23:37 UTC
Yes, the behaviour changed, but why are you filling it as a bug here?
You are free to argue upstream about the change, but we as the distro aren't
going to diverge from upstream in this.

Comment 3 Dmitry V. Levin 2005-12-22 13:31:05 UTC
1. To ensure this is really upstream change not yours since I tested your
packages.
2. To find out your opinion on this change.
3. For reference.

Sorry for (ab)using bugzilla.