Bug 51281 - ld silently ignores -static when it links an explicit .so
Summary: ld silently ignores -static when it links an explicit .so
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: binutils
Version: 8.0
Hardware: i386
OS: Linux
low
low
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-08-09 00:23 UTC by Pavel Kankovsky
Modified: 2005-10-31 22:00 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2004-10-02 19:38:36 UTC
Embargoed:


Attachments (Terms of Use)

Description Pavel Kankovsky 2001-08-09 00:23:19 UTC
Description of Problem:

When the program is linked with -static and one of the listed objects is a
shared object (.so), ld silently decides to create a dynamically linked
executable despite -static but gcc will not give it --dynamic-linker when
invoked with -static and the result is an unusable dynamically linked
program whose dyn. linker is set to /usr/lib/libc.so.1 (cf. #38309).

Steps to Reproduce:

1. echo 'int main() { return 0; }' > t.c
2. gcc -static -o t t.c /lib/libc.so.6
3. file t
4. ./t

Actual Results:

$ file t
t: ELF 32-bit LSB executable, Intel 80386, version 1, dynamically linked
(uses shared libs), not stripped
$ ./t
bash2: ./t: No such file or directory


Expected Results:

IMHO, when ld gets -(B)static as one of its first argument and no -Bdynamic
or -Bsymbolic, then it is obvious its caller intends to make a statically
linked binary, and no artificial intelligence in ld should ever decide to
generate anything else. It should either force static linking of shared
objects or fail with an error.

The problem was observed using egcs-1.1.2-30 and binutils-2.9.5.0.22-6 on
RH 6.2.

Comment 1 Jakub Jelinek 2004-10-02 19:38:36 UTC
Reproduced even with current binutils.
Moved upstream:
http://sources.redhat.com/bugzilla/show_bug.cgi?id=423


Note You need to log in before you can comment on or make changes to this bug.