This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Patch: Fix elf_find_function () on a corner case
- From: Jie Zhang <jzhang918 at gmail dot com>
- To: binutils <binutils at sources dot redhat dot com>
- Date: Wed, 23 Nov 2005 00:39:49 +0800
- Subject: Patch: Fix elf_find_function () on a corner case
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
* elf.c (elf_find_function): Don't report a filename at all for
global symbols when there are two or more FILE symbols.
Index: elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.318
diff -u -p -r1.318 elf.c
--- elf.c 3 Nov 2005 02:53:38 -0000 1.318
+++ elf.c 22 Nov 2005 15:17:14 -0000
@@ -6652,9 +6652,9 @@ elf_find_function (bfd *abfd ATTRIBUTE_U
default:
break;
case STT_FILE:
- file = &q->symbol;
- if (state == symbol_seen)
+ if (state == symbol_seen || file != NULL)
state = file_after_symbol_seen;
+ file = &q->symbol;
continue;
case STT_SECTION:
continue;