summaryrefslogtreecommitdiff
path: root/ld/ldmisc.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl@lucon.org>2003-06-03 18:15:05 +0000
committerH.J. Lu <hjl@lucon.org>2003-06-03 18:15:05 +0000
commit61c85f87776a0930ef243cc9551e941d14f374b3 (patch)
tree3be4bfa78ed28cdde9f38b52c11b59eb20045e1c /ld/ldmisc.c
parent190b02635013cffdbf38eedcb6eeca148406aa47 (diff)
downloadbinutils-redhat-61c85f87776a0930ef243cc9551e941d14f374b3.tar.gz
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 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;
}