This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Should gcc generate ELF type info for undefined symbol?
- From: "H. J. Lu" <hjl at lucon dot org>
- To: gcc at gcc dot gnu dot org
- Cc: binutils at sources dot redhat dot com
- Date: Tue, 28 Feb 2006 11:54:17 -0800
- Subject: Should gcc generate ELF type info for undefined symbol?
The current gcc only generates ELF type info for undefined symbol for
HPUX. This information is useful for linker to detect possible run-time
problems at link-time. Here is an example:
[hjl@gnu-13 mismatch]$ cat foo.c
#include <stdio.h>
extern void bar (void);
int times;
int
main ()
{
printf ("times: %d\n", times);
bar ();
return 0;
}
[hjl@gnu-13 mismatch]$ cat bar.c
#include <stdio.h>
#include <sys/times.h>
void
bar (void)
{
struct tms buf;
clock_t ticks = times (&buf);
printf ("Ticks: %ld\n", (long) ticks);
}
[hjl@gnu-13 mismatch]$ make
gcc -O -g -c -o foo.o foo.c
gcc -O -g -fPIC -c -o bar.o bar.c
gcc -o libbar.so -shared bar.o
gcc -o foo foo.o libbar.so -Wl,-rpath,.
./foo
times: 0
make: *** [all] Segmentation fault
If linker knows "times" referenced by libbar.so is a function, it can
avoid the run-time problem.
H.J.