This is the mail archive of the
mailing list for the binutils project.
Re: ld: creating a dynamically linked executable ...
- From: John Reiser <jreiser at bitwagon dot com>
- To: binutils at sourceware dot org
- Date: Thu, 11 Jul 2013 06:59:40 -0700
- Subject: Re: ld: creating a dynamically linked executable ...
- References: <CABzSAw81DSh1OOnKrQk+XTKVrMqMdJXmx2sS1_3MCm-6nWKd8g at mail dot gmail dot com>
> 2) ld -o use-of-lib use-of-lib.o -lc
Many uses of -lc also require the use of the corresponding startup object
files with names such as crt0.o, crt1.o, crtn.o, etc. Use gcc for linking
until you become an expert.
gcc -v -o use-of-lib use-of-lib.o
> $> ./use-of-lib
> zsh: no such file or directory: ./use-of-lib
zsh has a bug in its error reporting. It is not ./use-of-lib which cannot
be found, but rather the [PT_]INTERP which cannot be found.
To be fair to zsh, the kernel does not say which file suffers ENOENT.
However, *all* shells could be more user-friendly in this case.
Obviously ./use-of-lib does exist (and most shells check for existence and
+x permission _before_ trying execve()), so the shell should investigate
further instead of emitting a message that makes no sense.
$ readelf --segments /bin/date
INTERP 0x0000000000000238 0x0000000000400238 0x0000000000400238
0x000000000000001c 0x000000000000001c R 1
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
So /lib64/ld-linux-x86-64.so.2 also must exist in order for /bin/date to run.