Bug 51281 - ld silently ignores -static when it links an explicit .so
ld silently ignores -static when it links an explicit .so
Status: CLOSED UPSTREAM
Product: Red Hat Linux
Classification: Retired
Component: binutils (Show other bugs)
8.0
i386 Linux
low Severity low
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-08-08 20:23 EDT by Pavel Kankovsky
Modified: 2005-10-31 17:00 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-10-02 15:38:36 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Pavel Kankovsky 2001-08-08 20:23:19 EDT
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 15:38:36 EDT
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.