* 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 <B>): Print "ld generated" for null bfd.
	(vfinfo <C, D, G>): Handle null bfd.  Wrap comments.
This commit is contained in:
Alan Modra 2005-06-03 09:52:50 +00:00
parent e09f16f93f
commit e1fffbe6e9
10 changed files with 322 additions and 182 deletions

View file

@ -1,5 +1,13 @@
2005-06-03 Alan Modra <amodra@bigpond.net.au> 2005-06-03 Alan Modra <amodra@bigpond.net.au>
PR 568
* 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.
* elf32-i386.c (elf_i386_relocate_section): Handle zero symndx * elf32-i386.c (elf_i386_relocate_section): Handle zero symndx
for all reloc types. for all reloc types.

344
bfd/configure vendored

File diff suppressed because it is too large Load diff

View file

@ -8,7 +8,7 @@ AC_CONFIG_SRCDIR([libbfd.c])
AC_CANONICAL_TARGET AC_CANONICAL_TARGET
AC_ISC_POSIX AC_ISC_POSIX
AM_INIT_AUTOMAKE(bfd, 2.16.90) AM_INIT_AUTOMAKE(bfd, 2.16.91)
dnl These must be called before AM_PROG_LIBTOOL, because it may want dnl These must be called before AM_PROG_LIBTOOL, because it may want
dnl to call AC_CHECK_PROG. dnl to call AC_CHECK_PROG.

View file

@ -7087,14 +7087,10 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd)
{ {
BFD_ASSERT (r_symndx != 0); BFD_ASSERT (r_symndx != 0);
if (action & COMPLAIN) if (action & COMPLAIN)
{ (*finfo->info->callbacks->einfo)
(*_bfd_error_handler) (_("%X`%s' referenced in section `%A' of %B: "
(_("`%s' referenced in section `%A' of %B: " "defined in discarded section `%A' of %B"),
"defined in discarded section `%A' of %B"), sym_name, o, input_bfd, sec, sec->owner);
o, input_bfd, sec, sec->owner, sym_name);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
/* Try to do the best we can to support buggy old /* Try to do the best we can to support buggy old
versions of gcc. If we've warned, or this is versions of gcc. If we've warned, or this is

View file

@ -92,6 +92,11 @@ simple_dummy_multiple_definition (struct bfd_link_info *link_info ATTRIBUTE_UNUS
return TRUE; return TRUE;
} }
static void
simple_dummy_einfo (const char *fmt ATTRIBUTE_UNUSED, ...)
{
}
struct saved_output_info struct saved_output_info
{ {
bfd_vma offset; bfd_vma offset;
@ -187,6 +192,7 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
callbacks.reloc_dangerous = simple_dummy_reloc_dangerous; callbacks.reloc_dangerous = simple_dummy_reloc_dangerous;
callbacks.unattached_reloc = simple_dummy_unattached_reloc; callbacks.unattached_reloc = simple_dummy_unattached_reloc;
callbacks.multiple_definition = simple_dummy_multiple_definition; callbacks.multiple_definition = simple_dummy_multiple_definition;
callbacks.einfo = simple_dummy_einfo;
memset (&link_order, 0, sizeof (link_order)); memset (&link_order, 0, sizeof (link_order));
link_order.next = NULL; link_order.next = NULL;

View file

@ -1,3 +1,7 @@
2005-06-03 Alan Modra <amodra@bigpond.net.au>
* bfdlink.h (struct bfd_link_callbacks): Add einfo.
2005-06-01 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 2005-06-01 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* libiberty.h (vsnprintf): Add format attribute. * libiberty.h (vsnprintf): Add format attribute.
@ -81,7 +85,7 @@
2005-03-28 Mark Mitchell <mark@codesourcery.com> 2005-03-28 Mark Mitchell <mark@codesourcery.com>
* libiberty.h (ffs): Declare, if necessary. * libiberty.h (ffs): Declare, if necessary.
2005-03-27 Gabriel Dos Reis <gdr@integreable-solutions.net> 2005-03-27 Gabriel Dos Reis <gdr@integreable-solutions.net>
* ternary.h: Don't use PARAMS anymore. * ternary.h: Don't use PARAMS anymore.

View file

@ -422,11 +422,11 @@ struct bfd_link_info
}; };
/* This structures holds a set of callback functions. These are /* This structures holds a set of callback functions. These are
called by the BFD linker routines. The first argument to each called by the BFD linker routines. Except for einfo, the first
callback function is the bfd_link_info structure being used. Each argument to each callback function is the bfd_link_info structure
function returns a boolean value. If the function returns FALSE, being used and each function returns a boolean value. If the
then the BFD function which called it will return with a failure function returns FALSE, then the BFD function which called it should
indication. */ return with a failure indication. */
struct bfd_link_callbacks struct bfd_link_callbacks
{ {
@ -535,6 +535,9 @@ struct bfd_link_callbacks
bfd_boolean (*notice) bfd_boolean (*notice)
(struct bfd_link_info *, const char *name, (struct bfd_link_info *, const char *name,
bfd *abfd, asection *section, bfd_vma address); bfd *abfd, asection *section, bfd_vma address);
/* General link info message. */
void (*einfo)
(const char *fmt, ...);
}; };
/* The linker builds link_order structures which tell the code how to /* The linker builds link_order structures which tell the code how to

View file

@ -1,3 +1,13 @@
2005-06-03 Alan Modra <amodra@bigpond.net.au>
* 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 <B>): Print "ld generated" for null bfd.
(vfinfo <C, D, G>): Handle null bfd. Wrap comments.
2005-06-02 Alan Modra <amodra@bigpond.net.au> 2005-06-02 Alan Modra <amodra@bigpond.net.au>
* ldexp.h (etree_value_type): Use "asection *" in place of * ldexp.h (etree_value_type): Use "asection *" in place of

View file

@ -160,7 +160,8 @@ static struct bfd_link_callbacks link_callbacks =
reloc_overflow, reloc_overflow,
reloc_dangerous, reloc_dangerous,
unattached_reloc, unattached_reloc,
notice notice,
einfo
}; };
struct bfd_link_info link_info; struct bfd_link_info link_info;
@ -873,7 +874,7 @@ add_keepsyms_file (const char *filename)
a link. */ a link. */
static bfd_boolean static bfd_boolean
add_archive_element (struct bfd_link_info *info ATTRIBUTE_UNUSED, add_archive_element (struct bfd_link_info *info,
bfd *abfd, bfd *abfd,
const char *name) const char *name)
{ {
@ -904,7 +905,7 @@ add_archive_element (struct bfd_link_info *info ATTRIBUTE_UNUSED,
bfd *from; bfd *from;
int len; 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) if (h == NULL)
from = 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 /* Ensure that BFD_RELOC_CTOR exists now, so that we can give a
useful error message. */ useful error message. */
if (bfd_reloc_type_lookup (output_bfd, BFD_RELOC_CTOR) == NULL 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)) || bfd_reloc_type_lookup (abfd, BFD_RELOC_CTOR) == NULL))
einfo (_("%P%F: BFD backend error: BFD_RELOC_CTOR unsupported\n")); 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) if (overflow_cutoff_limit == -1)
return TRUE; return TRUE;
if (abfd == NULL) einfo ("%X%C:", abfd, section, address);
einfo (_("%P%X: generated"));
else
einfo ("%X%C:", abfd, section, address);
if (overflow_cutoff_limit >= 0 if (overflow_cutoff_limit >= 0
&& overflow_cutoff_limit-- == 0) && overflow_cutoff_limit-- == 0)
@ -1477,11 +1475,8 @@ reloc_dangerous (struct bfd_link_info *info ATTRIBUTE_UNUSED,
asection *section, asection *section,
bfd_vma address) bfd_vma address)
{ {
if (abfd == NULL) einfo (_("%X%C: dangerous relocation: %s\n"),
einfo (_("%P%X: generated")); abfd, section, address, message);
else
einfo ("%X%C:", abfd, section, address);
einfo (_("dangerous relocation: %s\n"), message);
return TRUE; return TRUE;
} }
@ -1495,11 +1490,8 @@ unattached_reloc (struct bfd_link_info *info ATTRIBUTE_UNUSED,
asection *section, asection *section,
bfd_vma address) bfd_vma address)
{ {
if (abfd == NULL) einfo (_("%X%C: reloc refers to symbol `%T' which is not being output\n"),
einfo (_("%P%X: generated")); abfd, section, address, name);
else
einfo ("%X%C:", abfd, section, address);
einfo (_(" reloc refers to symbol `%T' which is not being output\n"), name);
return TRUE; return TRUE;
} }

View file

@ -190,7 +190,7 @@ vfinfo (FILE *fp, const char *fmt, va_list arg, bfd_boolean is_warning)
bfd *abfd = va_arg (arg, bfd *); bfd *abfd = va_arg (arg, bfd *);
if (abfd == NULL) if (abfd == NULL)
fprintf (fp, "<none>"); fprintf (fp, "%s generated", program_name);
else if (abfd->my_archive) else if (abfd->my_archive)
fprintf (fp, "%s(%s)", abfd->my_archive->filename, fprintf (fp, "%s(%s)", abfd->my_archive->filename,
abfd->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 *); section = va_arg (arg, asection *);
offset = va_arg (arg, bfd_vma); offset = va_arg (arg, bfd_vma);
entry = (lang_input_statement_type *) abfd->usrdata; if (abfd == NULL)
if (entry != (lang_input_statement_type *) NULL {
&& entry->asymbols != (asymbol **) NULL) entry = NULL;
asymbols = entry->asymbols; asymbols = NULL;
}
else else
{ {
long symsize; entry = (lang_input_statement_type *) abfd->usrdata;
long symbol_count; if (entry != (lang_input_statement_type *) NULL
&& entry->asymbols != (asymbol **) NULL)
symsize = bfd_get_symtab_upper_bound (abfd); asymbols = entry->asymbols;
if (symsize < 0) else
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->asymbols = asymbols; long symsize;
entry->symbol_count = symbol_count; 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 source-file-name:lineno: message
We do not always have a line number available so if we cannot find We do not always have a line number available so if
them we print out the section name and offset instread. */ we cannot find them we print out the section name and
offset instread. */
discard_last = TRUE; discard_last = TRUE;
if (bfd_find_nearest_line (abfd, section, asymbols, offset, if (abfd != NULL
&filename, &functionname, && bfd_find_nearest_line (abfd, section, asymbols, offset,
&linenumber)) &filename, &functionname,
&linenumber))
{ {
if (functionname != NULL && fmt[-1] == 'C') if (functionname != NULL && fmt[-1] == 'C')
{ {
/* Detect the case where we are printing out a message /* Detect the case where we are printing out a
for the same function as the last call to vinfo ("%C"). message for the same function as the last
In this situation do not print out the ABFD filename call to vinfo ("%C"). In this situation do
or the function name again. Note - we do still print not print out the ABFD filename or the
out the source filename, as this will allow programs function name again. Note - we do still
that parse the linker's output (eg emacs) to correctly print out the source filename, as this will
locate multiple errors in the same source file. */ allow programs that parse the linker's output
(eg emacs) to correctly locate multiple
errors in the same source file. */
if (last_bfd == NULL if (last_bfd == NULL
|| last_file == NULL || last_file == NULL
|| last_function == NULL || last_function == NULL