This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
RE: TODO list for 2.12.0 - ld creates unexecutables
- From: Mark Swanson <swansma at yahoo dot com>
- To: Daniel Jacobowitz <drow at mvista dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Fri, 4 Jan 2002 12:13:57 -0500
- Subject: RE: TODO list for 2.12.0 - ld creates unexecutables
- Organization: personal
Hello Daniel,
I've searched several months worth of the binutils archives and haven't found
anything like this so I believe this is new. I get the following behavior
with every gcc-3.0.x distribution right up to the latest gcc 3.1 beta with
the latest redhat binutils-2.11.92.0.12-8.
ld is creating executables that can not be executed, and ldd fails to examine
the ldd-created executable responding with 'file not found'.
Please accept my simple test code and make targets that show this behavior:
(I'm simply attempting to link the stdc++ library as static and leave
everything else as dynamic)
// The sample code
#include <vector>
using namespace std;
int main(int argc, char** argv) {
vector<int> x;
x.push_back(0);
return 0;
}
// Various make target attempts
CPP = g++-3.1.0
GCCVER = 3.1
GCCLIB = i386-redhat-linux
vec.o: Makefile
${CPP} -v vec.cpp -c -o vec.o
# Creates illegal executable (bug)
vec: Makefile vec.o
ld -o vec vec.o /usr/lib/crt1.o /usr/lib/crti.o \
/usr/lib/gcc-lib/${GCCLIB}/${GCCVER}/crtbegin.o \
-L/usr/lib/gcc-lib/${GCCLIB}/${GCCVER} \
-lm -lgcc_s -lc -lgcc -lstdc++ \
/usr/lib/gcc-lib/${GCCLIB}/${GCCVER}/crtend.o \
/usr/lib/crtn.o
# Creates illegal executable (bug)
vec2: vec.o
ld -o vec2 vec.o /usr/lib/crt1.o /usr/lib/crti.o \
/usr/lib/gcc-lib/${GCCLIB}/${GCCVER}/crtbegin.o \
-L/usr/lib/gcc-lib/${GCCLIB}/${GCCVER} \
-Bstatic -lstdc++ \
-Bdynamic -lm -lgcc_s -lc -lgcc \
/usr/lib/gcc-lib/${GCCLIB}/${GCCVER}/crtend.o \
/usr/lib/crtn.o
# Creates dynamic executable, works (to show dynamic works).
vec3: vec.cpp Makefile
${CPP} -v vec.cpp \
/usr/lib/gcc-lib/${GCCLIB}/${GCCVER}/libstdc++.a \
-L/usr/lib/gcc-lib/${GCCLIB}/${GCCVER} \
-lm -lgcc_s -lc -lgcc \
-o vec3
# libstdc++.so is used when libstdc++.a should be used (bug)
vec4: vec.cpp Makefile
${CPP} -v vec.cpp -o vec4 -Wl,-Bstatic -lstdc++ -lm -Wl,-Bdynamic
# Doesn't compile as libgcc_s.a is missing (rpm packaging bug)
vec5: vec.cpp Makefile
${CPP} -v vec.cpp -o vec5 -Wl,-static,-lstdc++,-lm
# proof that -static by itself works. However, if libstdc++.a did not
# exist, this would fail - and adding -Wl,-Bdynamic -lstdc++ creates
# an executable that is not executable (bug).
vec6: vec.cpp Makefile
${CPP} -v vec.cpp -o vec6 -static
# Creates illegal executable (bug)
vec7: vec.cpp Makefile
${CPP} -v vec.cpp -o vec7 -static -lstdc++ -lm -Wl,-Bdynamic
# Creates illegal executable (bug)
# Shows you have to use incorrect arguments to get correct results.
# F.E. The static/dynamic combos above show the linker places the
# static library in the static AND dynamic section (bug).
# Below, we use an incorrect(?) format, but the static library
# correctly shows up only in the static section.
# NOTE: Not true with lates gcc/binutils. Now libstdc++.so is in
# the static and dynamic section no matter what...
# Also, this creates illegal executable (bug) (same as above).
vec8: vec.cpp Makefile
${CPP} -v vec.cpp -o vec7 -Wl,-Bstatic -Wl,-lstdc++ -Wl,-Bdynamic