This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
RFC/PATCH: ld falsely issues .gnu.warning message for unreferenced dynamic symbols
- From: Grigory Zagorodnev <grigory_zagorodnev at linux dot intel dot com>
- To: binutils at sourceware dot org
- Date: Thu, 15 Feb 2007 17:20:43 +0300
- Subject: RFC/PATCH: ld falsely issues .gnu.warning message for unreferenced dynamic symbols
Hi!
In the conditions described below, ld 2.17.50.0.13 falsely issues
warning message associated with a symbol via .gnu.warning extension.
Test-case illustrating the problem and a fix proposal are attached to
this mail.
I'd appreciate any help in reviewing the problem and proposed patch.
Conditions:
Main executable is linked against two dynamic libraries libcall.so and
libstub.so. First library (libcall.so) is linked against third dynamic
library liberal.so. Two of these libraries, libstub and libreal, define
symbol "func2". Neither executable nor any shared library reference this
symbol.
The problem:
While building executable, ld emits warning message, defined in
.gnu.warning.func2 section of libstub.so, regardless of missing
references to this symbol. That seems to be wrong.
The test-case:
Run make to see the message "libreal.so: warning: warning: func2 is not
implemented and will always fail". This message is unexpected.
Proposed solution:
In order to ignore multiple definitions of a dynamic symbol, for any
extra copy if the symbol, linker replaces its definition section with
"*UND*" stub. Thus this symbol is treated as undefined later on.
Proposed fix uses BSF_GLOBAL flag to distinguish between naturally
undefined symbols and synthetically undefined.
Patch applied to ld version 2.17.50.0.13 20070212, bootstrapped and
regtested at x86_64-redhat-linux.
Once again, both the problem and proposed patch needs to be reviewed.
I'd appreciate any help on this.
- Grigory
Attachment:
def_warn_test.tgz
Description: Binary data
2007-02-15 Grigory Zagorodnev <grigory.zagorodnev@linux.intel.com>
* linker.c: avoid falsely .gnu.warning message for
unreferenced dynamic symbols
diff -r -up org/bfd/linker.c src/bfd/linker.c
--- org/bfd/linker.c 2006-10-31 17:18:29.000000000 +0300
+++ src/bfd/linker.c 2007-02-15 15:42:41.000000000 +0300
@@ -1908,7 +1908,7 @@ _bfd_generic_link_add_one_symbol (struct
case WARNC:
/* Issue a warning and cycle. */
- if (h->u.i.warning != NULL)
+ if (h->u.i.warning != NULL && !(flags & BSF_GLOBAL))
{
if (! (*info->callbacks->warning) (info, h->u.i.warning,
h->root.string, abfd,