From e1fffbe6e9081f5d7b12fe6d591b00a8eb6d8897 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 3 Jun 2005 09:52:50 +0000 Subject: include/ * bfdlink.h (struct bfd_link_callbacks): Add einfo. bfd/ * configure.in: Bump version * configure: Regenerate. * elflink.c (elf_link_input_bfd): Use einfo linker callback to print discarded section sym refs and kill linker output. * simple.c (simple_dummy_einfo): New function. (bfd_simple_get_relocated_section_contents): Init callbacks.einfo. ld/ * ldmain.c (link_callbacks): Add einfo. (add_archive_element): Use passed info, not link_info. (constructor_callback): Likewise. (reloc_overflow): Don't handle null bfd specially. (reloc_dangerous, unattached_reloc): Likewise. * ldmisc.c (vfinfo ): Print "ld generated" for null bfd. (vfinfo ): Handle null bfd. Wrap comments. --- ld/ChangeLog | 10 ++++++++ ld/ldmain.c | 28 ++++++++--------------- ld/ldmisc.c | 75 +++++++++++++++++++++++++++++++++++------------------------- 3 files changed, 64 insertions(+), 49 deletions(-) (limited to 'ld') diff --git a/ld/ChangeLog b/ld/ChangeLog index f940d2c..7789ed6 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,13 @@ +2005-06-03 Alan Modra + + * ldmain.c (link_callbacks): Add einfo. + (add_archive_element): Use passed info, not link_info. + (constructor_callback): Likewise. + (reloc_overflow): Don't handle null bfd specially. + (reloc_dangerous, unattached_reloc): Likewise. + * ldmisc.c (vfinfo ): Print "ld generated" for null bfd. + (vfinfo ): Handle null bfd. Wrap comments. + 2005-06-02 Alan Modra * ldexp.h (etree_value_type): Use "asection *" in place of diff --git a/ld/ldmain.c b/ld/ldmain.c index a25ceb9..38c92d5 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -160,7 +160,8 @@ static struct bfd_link_callbacks link_callbacks = reloc_overflow, reloc_dangerous, unattached_reloc, - notice + notice, + einfo }; struct bfd_link_info link_info; @@ -873,7 +874,7 @@ add_keepsyms_file (const char *filename) a link. */ static bfd_boolean -add_archive_element (struct bfd_link_info *info ATTRIBUTE_UNUSED, +add_archive_element (struct bfd_link_info *info, bfd *abfd, const char *name) { @@ -904,7 +905,7 @@ add_archive_element (struct bfd_link_info *info ATTRIBUTE_UNUSED, bfd *from; int len; - h = bfd_link_hash_lookup (link_info.hash, name, FALSE, FALSE, TRUE); + h = bfd_link_hash_lookup (info->hash, name, FALSE, FALSE, TRUE); if (h == NULL) from = NULL; @@ -1145,7 +1146,7 @@ constructor_callback (struct bfd_link_info *info, /* Ensure that BFD_RELOC_CTOR exists now, so that we can give a useful error message. */ if (bfd_reloc_type_lookup (output_bfd, BFD_RELOC_CTOR) == NULL - && (link_info.relocatable + && (info->relocatable || bfd_reloc_type_lookup (abfd, BFD_RELOC_CTOR) == NULL)) einfo (_("%P%F: BFD backend error: BFD_RELOC_CTOR unsupported\n")); @@ -1422,10 +1423,7 @@ reloc_overflow (struct bfd_link_info *info ATTRIBUTE_UNUSED, if (overflow_cutoff_limit == -1) return TRUE; - if (abfd == NULL) - einfo (_("%P%X: generated")); - else - einfo ("%X%C:", abfd, section, address); + einfo ("%X%C:", abfd, section, address); if (overflow_cutoff_limit >= 0 && overflow_cutoff_limit-- == 0) @@ -1477,11 +1475,8 @@ reloc_dangerous (struct bfd_link_info *info ATTRIBUTE_UNUSED, asection *section, bfd_vma address) { - if (abfd == NULL) - einfo (_("%P%X: generated")); - else - einfo ("%X%C:", abfd, section, address); - einfo (_("dangerous relocation: %s\n"), message); + einfo (_("%X%C: dangerous relocation: %s\n"), + abfd, section, address, message); return TRUE; } @@ -1495,11 +1490,8 @@ unattached_reloc (struct bfd_link_info *info ATTRIBUTE_UNUSED, asection *section, bfd_vma address) { - if (abfd == NULL) - einfo (_("%P%X: generated")); - else - einfo ("%X%C:", abfd, section, address); - einfo (_(" reloc refers to symbol `%T' which is not being output\n"), name); + einfo (_("%X%C: reloc refers to symbol `%T' which is not being output\n"), + abfd, section, address, name); return TRUE; } diff --git a/ld/ldmisc.c b/ld/ldmisc.c index 0b2b69b..9b8f44f 100644 --- a/ld/ldmisc.c +++ b/ld/ldmisc.c @@ -190,7 +190,7 @@ vfinfo (FILE *fp, const char *fmt, va_list arg, bfd_boolean is_warning) bfd *abfd = va_arg (arg, bfd *); if (abfd == NULL) - fprintf (fp, ""); + fprintf (fp, "%s generated", program_name); else if (abfd->my_archive) fprintf (fp, "%s(%s)", abfd->my_archive->filename, abfd->filename); @@ -275,49 +275,62 @@ vfinfo (FILE *fp, const char *fmt, va_list arg, bfd_boolean is_warning) section = va_arg (arg, asection *); offset = va_arg (arg, bfd_vma); - entry = (lang_input_statement_type *) abfd->usrdata; - if (entry != (lang_input_statement_type *) NULL - && entry->asymbols != (asymbol **) NULL) - asymbols = entry->asymbols; + if (abfd == NULL) + { + entry = NULL; + asymbols = NULL; + } else { - long symsize; - long symbol_count; - - symsize = bfd_get_symtab_upper_bound (abfd); - if (symsize < 0) - einfo (_("%B%F: could not read symbols\n"), abfd); - asymbols = xmalloc (symsize); - symbol_count = bfd_canonicalize_symtab (abfd, asymbols); - if (symbol_count < 0) - einfo (_("%B%F: could not read symbols\n"), abfd); - if (entry != (lang_input_statement_type *) NULL) + entry = (lang_input_statement_type *) abfd->usrdata; + if (entry != (lang_input_statement_type *) NULL + && entry->asymbols != (asymbol **) NULL) + asymbols = entry->asymbols; + else { - entry->asymbols = asymbols; - entry->symbol_count = symbol_count; + long symsize; + long sym_count; + + symsize = bfd_get_symtab_upper_bound (abfd); + if (symsize < 0) + einfo (_("%B%F: could not read symbols\n"), abfd); + asymbols = xmalloc (symsize); + sym_count = bfd_canonicalize_symtab (abfd, asymbols); + if (sym_count < 0) + einfo (_("%B%F: could not read symbols\n"), abfd); + if (entry != (lang_input_statement_type *) NULL) + { + entry->asymbols = asymbols; + entry->symbol_count = sym_count; + } } } - /* The GNU Coding Standard requires that error messages be of the form: + /* The GNU Coding Standard requires that error messages + be of the form: source-file-name:lineno: message - We do not always have a line number available so if we cannot find - them we print out the section name and offset instread. */ + We do not always have a line number available so if + we cannot find them we print out the section name and + offset instread. */ discard_last = TRUE; - if (bfd_find_nearest_line (abfd, section, asymbols, offset, - &filename, &functionname, - &linenumber)) + if (abfd != NULL + && bfd_find_nearest_line (abfd, section, asymbols, offset, + &filename, &functionname, + &linenumber)) { if (functionname != NULL && fmt[-1] == 'C') { - /* Detect the case where we are printing out a message - for the same function as the last call to vinfo ("%C"). - In this situation do not print out the ABFD filename - or the function name again. Note - we do still print - out the source filename, as this will allow programs - that parse the linker's output (eg emacs) to correctly - locate multiple errors in the same source file. */ + /* Detect the case where we are printing out a + message for the same function as the last + call to vinfo ("%C"). In this situation do + not print out the ABFD filename or the + function name again. Note - we do still + print out the source filename, as this will + allow programs that parse the linker's output + (eg emacs) to correctly locate multiple + errors in the same source file. */ if (last_bfd == NULL || last_file == NULL || last_function == NULL -- cgit v1.1