Patch: Fix elf_find_function () on a corner case

Jie Zhang jzhang918@gmail.com
Tue Nov 22 16:39:00 GMT 2005


I found an issue of ld of latest CVS on the following small case:

$ cat a.c

extern void bar ();

aaa ()
{
   bar ();
}

$ cat b.c

extern void bar ();

bbb ()
{
   bar ();
}

$ cat m.c

int main ()
{
   aaa ();
   bbb ();
   return 0;
}

$ gcc -c a.c b.c m.c
$ ld -r -o t.o a.o b.o
$ ld -o m m.o t.o
ld: warning: cannot find entry symbol _start; defaulting to 08048094
t.o: In function `aaa':b.c:(.text+0x7): undefined reference to `bar'
t.o: In function `bbb':b.c:(.text+0x17): undefined reference to `bar'


While we expect it to output:

ld: warning: cannot find entry symbol _start; defaulting to 08048094
t.o: In function `aaa': undefined reference to `bar'
t.o: In function `bbb': undefined reference to `bar'

I found the automaton in elf_find_function () misses such case. The 
attached patch should fix it on such cases. It's tested using ld 
testsuite and no regressions found.

Is it OK?

Thanks,
Jie
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bfd-elf-find-function.diff
Type: text/x-patch
Size: 680 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20051122/659317b0/attachment.bin>


More information about the Binutils mailing list