aboutsummaryrefslogtreecommitdiff
path: root/ld/ldmisc.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2003-06-03 18:15:05 +0000
committerH.J. Lu <hjl.tools@gmail.com>2003-06-03 18:15:05 +0000
commit6f6f27f842f3e82a92d651fb02c5b51b7686dc74 (patch)
treeb04e1eb55f80af1e4211b0cd12bda762a1b13a6a /ld/ldmisc.c
parenta3b6428fe79103e838aea22ef2acd6578178bf25 (diff)
downloadgdb-6f6f27f842f3e82a92d651fb02c5b51b7686dc74.zip
gdb-6f6f27f842f3e82a92d651fb02c5b51b7686dc74.tar.gz
gdb-6f6f27f842f3e82a92d651fb02c5b51b7686dc74.tar.bz2
bfd/
2003-06-03 H.J. Lu <hongjiu.lu@intel.com> * elflink.h (elf_link_input_bfd): Call linker error_handler for discarded definitions. include/ 2003-06-03 H.J. Lu <hongjiu.lu@intel.com> * bfdlink.h (LD_DEFINITION_IN_DISCARDED_SECTION): New. ld/ 2003-06-03 H.J. Lu <hongjiu.lu@intel.com> * 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 <hongjiu.lu@intel.com> * ld-discard/extern.d: Updated. * ld-discard/start.d: Likewise. * ld-discard/static.d: Likewise.
Diffstat (limited to 'ld/ldmisc.c')
-rw-r--r--ld/ldmisc.c54
1 files changed, 53 insertions, 1 deletions
diff --git a/ld/ldmisc.c b/ld/ldmisc.c
index a2e496d..461d697 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;
}