This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]