From 6f6f27f842f3e82a92d651fb02c5b51b7686dc74 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/ChangeLog | 9 +++++++ ld/Makefile.am | 8 +++--- ld/Makefile.in | 8 +++--- ld/ldmisc.c | 54 +++++++++++++++++++++++++++++++++++++++- ld/testsuite/ChangeLog | 6 +++++ ld/testsuite/ld-discard/extern.d | 2 +- ld/testsuite/ld-discard/start.d | 2 +- ld/testsuite/ld-discard/static.d | 2 +- 8 files changed, 79 insertions(+), 12 deletions(-) (limited to 'ld') diff --git a/ld/ChangeLog b/ld/ChangeLog index 731f6ec..2652c8d 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,12 @@ +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. + 2003-06-03 Kaz Kojima * emulparams/shlelf_linux.sh (GENERATE_PIE_SCRIPT): Set to yes. diff --git a/ld/Makefile.am b/ld/Makefile.am index a09ccfe..0ad0824 100644 --- a/ld/Makefile.am +++ b/ld/Makefile.am @@ -1662,10 +1662,10 @@ ldmain.o: ldmain.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ ldmain.h ldmisc.h ldwrite.h ldexp.h ldlang.h ldgram.h \ ldlex.h ldfile.h ldemul.h ldctor.h ldmisc.o: ldmisc.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ - $(INCDIR)/symcat.h sysdep.h config.h $(INCDIR)/fopen-same.h \ - $(INCDIR)/libiberty.h $(INCDIR)/demangle.h ld.h $(INCDIR)/bin-bugs.h \ - ldmisc.h ldexp.h ldlang.h ldgram.h ldlex.h ldmain.h \ - ldfile.h + $(INCDIR)/symcat.h $(INCDIR)/bfdlink.h sysdep.h config.h \ + $(INCDIR)/fopen-same.h $(INCDIR)/libiberty.h $(INCDIR)/demangle.h \ + ld.h $(INCDIR)/bin-bugs.h ldmisc.h ldexp.h ldlang.h \ + ldgram.h ldlex.h ldmain.h ldfile.h ldver.o: ldver.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/symcat.h ../bfd/bfdver.h sysdep.h config.h \ $(INCDIR)/fopen-same.h ld.h $(INCDIR)/bin-bugs.h ldver.h \ diff --git a/ld/Makefile.in b/ld/Makefile.in index f3e7cc5..bd4b71c 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -2362,10 +2362,10 @@ ldmain.o: ldmain.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ ldmain.h ldmisc.h ldwrite.h ldexp.h ldlang.h ldgram.h \ ldlex.h ldfile.h ldemul.h ldctor.h ldmisc.o: ldmisc.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ - $(INCDIR)/symcat.h sysdep.h config.h $(INCDIR)/fopen-same.h \ - $(INCDIR)/libiberty.h $(INCDIR)/demangle.h ld.h $(INCDIR)/bin-bugs.h \ - ldmisc.h ldexp.h ldlang.h ldgram.h ldlex.h ldmain.h \ - ldfile.h + $(INCDIR)/symcat.h $(INCDIR)/bfdlink.h sysdep.h config.h \ + $(INCDIR)/fopen-same.h $(INCDIR)/libiberty.h $(INCDIR)/demangle.h \ + ld.h $(INCDIR)/bin-bugs.h ldmisc.h ldexp.h ldlang.h \ + ldgram.h ldlex.h ldmain.h ldfile.h ldver.o: ldver.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/symcat.h ../bfd/bfdver.h sysdep.h config.h \ $(INCDIR)/fopen-same.h ld.h $(INCDIR)/bin-bugs.h ldver.h \ 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; } diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 8cdb4c4..cd38c94d 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,5 +1,11 @@ 2003-06-03 H.J. Lu + * ld-discard/extern.d: Updated. + * ld-discard/start.d: Likewise. + * ld-discard/static.d: Likewise. + +2003-06-03 H.J. Lu + * ld-elfcomm/elfcomm.exp: Mark tests untested if compiler is not available. diff --git a/ld/testsuite/ld-discard/extern.d b/ld/testsuite/ld-discard/extern.d index 76d4263..10fa0f7 100644 --- a/ld/testsuite/ld-discard/extern.d +++ b/ld/testsuite/ld-discard/extern.d @@ -1,3 +1,3 @@ #source: extern.s #ld: -T discard.ld -#error: undefined reference to `(data|local symbols in discarded section \.data\.exit)' +#error: data: discarded in section `\.data\.exit' from tmpdir/dump0.o diff --git a/ld/testsuite/ld-discard/start.d b/ld/testsuite/ld-discard/start.d index feef5ea..b8f46ae 100644 --- a/ld/testsuite/ld-discard/start.d +++ b/ld/testsuite/ld-discard/start.d @@ -1,4 +1,4 @@ #source: start.s #source: exit.s #ld: -T discard.ld -#error: undefined reference to `data' +#error: data: discarded in section `\.data\.exit' from tmpdir/dump1.o diff --git a/ld/testsuite/ld-discard/static.d b/ld/testsuite/ld-discard/static.d index 2253f1a..78b89b0 100644 --- a/ld/testsuite/ld-discard/static.d +++ b/ld/testsuite/ld-discard/static.d @@ -1,3 +1,3 @@ #source: static.s #ld: -T discard.ld -#error: undefined reference to `local symbols in discarded section \.data\.exit' +#error: local symbol 0: discarded in section `\.data\.exit' from tmpdir/dump0.o -- cgit v1.1