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.
Reproduced even with current binutils. Moved upstream: http://sources.redhat.com/bugzilla/show_bug.cgi?id=423