From 61c85f87776a0930ef243cc9551e941d14f374b3 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 3 Jun 2003 18:15:05 +0000 Subject: bfd/ 2003-06-03 H.J. Lu * elflink.h (elf_link_input_bfd): Call linker error_handler for discarded definitions. include/ 2003-06-03 H.J. Lu * bfdlink.h (LD_DEFINITION_IN_DISCARDED_SECTION): New. ld/ 2003-06-03 H.J. Lu * ldmisc.c: Include "bfdlink.h". (error_handler): Handle LD_DEFINITION_IN_DISCARDED_SECTION and -LD_DEFINITION_IN_DISCARDED_SECTION. * Makefile.am: Rebuild dependency. * Makefile.in: Regenerated. ld/testsuite/ 2003-06-03 H.J. Lu * ld-discard/extern.d: Updated. * ld-discard/start.d: Likewise. * ld-discard/static.d: Likewise. --- ld/ldmisc.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'ld/ldmisc.c') diff --git a/ld/ldmisc.c b/ld/ldmisc.c index a2e496da9c..461d697274 100644 --- a/ld/ldmisc.c +++ b/ld/ldmisc.c @@ -22,6 +22,7 @@ 02111-1307, USA. */ #include "bfd.h" +#include "bfdlink.h" #include "sysdep.h" #include "libiberty.h" #include "demangle.h" @@ -508,12 +509,63 @@ ld_abort (file, line, fn) } bfd_boolean -error_handler VPARAMS ((int id ATTRIBUTE_UNUSED, const char *fmt, ...)) +error_handler VPARAMS ((int id, const char *fmt, ...)) { VA_OPEN (arg, fmt); VA_FIXEDARG (arg, const char *, fmt); + va_start (arg, fmt); + + switch (id) + { + default: + break; + + /* We can be called with + + error_handler (-LD_DEFINITION_IN_DISCARDED_SECTION, "", 0); + + to make this error non-fatal and + + error_handler (-LD_DEFINITION_IN_DISCARDED_SECTION, "", 1); + + to make this error fatal. */ + case -LD_DEFINITION_IN_DISCARDED_SECTION: + case LD_DEFINITION_IN_DISCARDED_SECTION: + { + static struct bfd_hash_table *hash; + static int fatal = 1; + const char *name; + + if (id == -LD_DEFINITION_IN_DISCARDED_SECTION) + { + fatal = va_arg (arg, int); + goto out; + } + + name = va_arg (arg, const char *); + /* Only warn once about a particular undefined symbol. */ + if (hash == NULL) + { + hash = ((struct bfd_hash_table *) + xmalloc (sizeof (struct bfd_hash_table))); + if (! bfd_hash_table_init (hash, bfd_hash_newfunc)) + einfo (_("%F%P: bfd_hash_table_init failed: %E\n")); + } + + if (bfd_hash_lookup (hash, name, FALSE, FALSE) != NULL) + goto out; + + if (bfd_hash_lookup (hash, name, TRUE, TRUE) == NULL) + einfo (_("%F%P: bfd_hash_lookup failed: %E\n")); + + if (fatal) + config.make_executable = FALSE; + } + break; + } vfinfo (stderr, fmt, arg); +out: VA_CLOSE (arg); return TRUE; } -- cgit v1.2.1