diff options
author | Alan Modra <amodra@gmail.com> | 2016-05-27 17:20:55 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2016-05-28 11:17:20 +0930 |
commit | 1a72702bb30ec3f94627cfcae684823b413f20b9 (patch) | |
tree | d697bddb351a52f2f14e6c28a030357756609a30 /bfd/xcofflink.c | |
parent | d5dca95ffc284d4380fddc063be43e155b7eb731 (diff) | |
download | gdb-1a72702bb30ec3f94627cfcae684823b413f20b9.zip gdb-1a72702bb30ec3f94627cfcae684823b413f20b9.tar.gz gdb-1a72702bb30ec3f94627cfcae684823b413f20b9.tar.bz2 |
Return void from linker callbacks
The ldmain.c implementation of these linker callback functions always
return true, so any code handling a false return is dead. What's
more, some of the bfd backends abort if ever a false return is seen,
and there seems to be some confusion in gdb's compile-object-load.c.
The return value was never meant to be "oh yes, a multiple_definition
error occurred", but rather "out of memory or other catastrophic
failure".
This patch removes the status return on the callbacks that always
return true. I kept the return status for "notice" because that one
does happen to need to return "out of memory".
include/
* bfdlink.h (struct bfd_link_callbacks): Update comments.
Return void from multiple_definition, multiple_common,
add_to_set, constructor, warning, undefined_symbol,
reloc_overflow, reloc_dangerous and unattached_reloc.
bfd/
* aoutx.h: Adjust linker callback calls throughout file,
removing dead code.
* bout.c: Likewise.
* coff-alpha.c: Likewise.
* coff-arm.c: Likewise.
* coff-h8300.c: Likewise.
* coff-h8500.c: Likewise.
* coff-i960.c: Likewise.
* coff-mcore.c: Likewise.
* coff-mips.c: Likewise.
* coff-ppc.c: Likewise.
* coff-rs6000.c: Likewise.
* coff-sh.c: Likewise.
* coff-tic80.c: Likewise.
* coff-w65.c: Likewise.
* coff-z80.c: Likewise.
* coff-z8k.c: Likewise.
* coff64-rs6000.c: Likewise.
* cofflink.c: Likewise.
* ecoff.c: Likewise.
* elf-bfd.h: Likewise.
* elf-m10200.c: Likewise.
* elf-m10300.c: Likewise.
* elf32-arc.c: Likewise.
* elf32-arm.c: Likewise.
* elf32-avr.c: Likewise.
* elf32-bfin.c: Likewise.
* elf32-cr16.c: Likewise.
* elf32-cr16c.c: Likewise.
* elf32-cris.c: Likewise.
* elf32-crx.c: Likewise.
* elf32-d10v.c: Likewise.
* elf32-epiphany.c: Likewise.
* elf32-fr30.c: Likewise.
* elf32-frv.c: Likewise.
* elf32-ft32.c: Likewise.
* elf32-h8300.c: Likewise.
* elf32-hppa.c: Likewise.
* elf32-i370.c: Likewise.
* elf32-i386.c: Likewise.
* elf32-i860.c: Likewise.
* elf32-ip2k.c: Likewise.
* elf32-iq2000.c: Likewise.
* elf32-lm32.c: Likewise.
* elf32-m32c.c: Likewise.
* elf32-m32r.c: Likewise.
* elf32-m68hc1x.c: Likewise.
* elf32-m68k.c: Likewise.
* elf32-mep.c: Likewise.
* elf32-metag.c: Likewise.
* elf32-microblaze.c: Likewise.
* elf32-moxie.c: Likewise.
* elf32-msp430.c: Likewise.
* elf32-mt.c: Likewise.
* elf32-nds32.c: Likewise.
* elf32-nios2.c: Likewise.
* elf32-or1k.c: Likewise.
* elf32-ppc.c: Likewise.
* elf32-s390.c: Likewise.
* elf32-score.c: Likewise.
* elf32-score7.c: Likewise.
* elf32-sh.c: Likewise.
* elf32-sh64.c: Likewise.
* elf32-spu.c: Likewise.
* elf32-tic6x.c: Likewise.
* elf32-tilepro.c: Likewise.
* elf32-v850.c: Likewise.
* elf32-vax.c: Likewise.
* elf32-visium.c: Likewise.
* elf32-xstormy16.c: Likewise.
* elf32-xtensa.c: Likewise.
* elf64-alpha.c: Likewise.
* elf64-hppa.c: Likewise.
* elf64-ia64-vms.c: Likewise.
* elf64-mmix.c: Likewise.
* elf64-ppc.c: Likewise.
* elf64-s390.c: Likewise.
* elf64-sh64.c: Likewise.
* elf64-x86-64.c: Likewise.
* elflink.c: Likewise.
* elfnn-aarch64.c: Likewise.
* elfnn-ia64.c: Likewise.
* elfxx-mips.c: Likewise.
* elfxx-sparc.c: Likewise.
* elfxx-tilegx.c: Likewise.
* linker.c: Likewise.
* pdp11.c: Likewise.
* pe-mips.c: Likewise.
* reloc.c: Likewise.
* reloc16.c: Likewise.
* simple.c: Likewise.
* vms-alpha.c: Likewise.
* xcofflink.c: Likewise.
* elf32-rl78.c (get_symbol_value, get_romstart, get_ramstart): Delete
status param. Adjust calls to these and linker callbacks throughout.
* elf32-rx.c: (get_symbol_value, get_gp, get_romstart,
get_ramstart): Delete status param. Adjust calls to these and
linker callbacks throughout.
ld/
* ldmain.c (multiple_definition, multiple_common, add_to_set,
constructor_callback, warning_callback, undefined_symbol,
reloc_overflow, reloc_dangerous, unattached_reloc): Return void.
* emultempl/elf32.em: Adjust callback calls.
gdb/
* compile/compile-object-load.c (link_callbacks_multiple_definition,
link_callbacks_warning, link_callbacks_undefined_symbol,
link_callbacks_undefined_symbol, link_callbacks_reloc_overflow,
link_callbacks_reloc_dangerous,
link_callbacks_unattached_reloc): Return void.
Diffstat (limited to 'bfd/xcofflink.c')
-rw-r--r-- | bfd/xcofflink.c | 50 |
1 files changed, 20 insertions, 30 deletions
diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c index ca40096..de7a992 100644 --- a/bfd/xcofflink.c +++ b/bfd/xcofflink.c @@ -1992,9 +1992,10 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info) sure the XCOFF linker is wholly prepared to handle them, and that would only be a warning, not an error. */ - if (! ((*info->callbacks->multiple_definition) - (info, &(*sym_hash)->root, NULL, NULL, (bfd_vma) 0))) - goto error_return; + (*info->callbacks->multiple_definition) (info, + &(*sym_hash)->root, + NULL, NULL, + (bfd_vma) 0); /* Try not to give this error too many times. */ (*sym_hash)->flags &= ~XCOFF_MULTIPLY_DEFINED; } @@ -3117,11 +3118,8 @@ bfd_xcoff_import_symbol (bfd *output_bfd, if (h->root.type == bfd_link_hash_defined && (! bfd_is_abs_section (h->root.u.def.section) || h->root.u.def.value != val)) - { - if (! ((*info->callbacks->multiple_definition) - (info, &h->root, output_bfd, bfd_abs_section_ptr, val))) - return FALSE; - } + (*info->callbacks->multiple_definition) (info, &h->root, output_bfd, + bfd_abs_section_ptr, val); h->root.type = bfd_link_hash_defined; h->root.u.def.section = bfd_abs_section_ptr; @@ -4942,10 +4940,9 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo, if (name == NULL) return FALSE; - if (!(*flinfo->info->callbacks->unattached_reloc) - (flinfo->info, name, input_bfd, o, - irel->r_vaddr)) - return FALSE; + (*flinfo->info->callbacks->unattached_reloc) + (flinfo->info, name, + input_bfd, o, irel->r_vaddr); } } } @@ -5712,9 +5709,8 @@ xcoff_reloc_link_order (bfd *output_bfd, FALSE, FALSE, TRUE)); if (h == NULL) { - if (! ((*flinfo->info->callbacks->unattached_reloc) - (flinfo->info, link_order->u.reloc.p->u.name, NULL, NULL, (bfd_vma) 0))) - return FALSE; + (*flinfo->info->callbacks->unattached_reloc) + (flinfo->info, link_order->u.reloc.p->u.name, NULL, NULL, (bfd_vma) 0); return TRUE; } @@ -5752,13 +5748,9 @@ xcoff_reloc_link_order (bfd *output_bfd, case bfd_reloc_outofrange: abort (); case bfd_reloc_overflow: - if (! ((*flinfo->info->callbacks->reloc_overflow) - (flinfo->info, NULL, link_order->u.reloc.p->u.name, - howto->name, addend, NULL, NULL, (bfd_vma) 0))) - { - free (buf); - return FALSE; - } + (*flinfo->info->callbacks->reloc_overflow) + (flinfo->info, NULL, link_order->u.reloc.p->u.name, + howto->name, addend, NULL, NULL, (bfd_vma) 0); break; } ok = bfd_set_section_contents (output_bfd, output_section, (void *) buf, @@ -6282,10 +6274,9 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info) { if ((*rel_hash)->indx < 0) { - if (! ((*info->callbacks->unattached_reloc) - (info, (*rel_hash)->root.root.string, - NULL, o, irel->r_vaddr))) - goto error_return; + (*info->callbacks->unattached_reloc) + (info, (*rel_hash)->root.root.string, + NULL, o, irel->r_vaddr); (*rel_hash)->indx = 0; } irel->r_symndx = (*rel_hash)->indx; @@ -6298,10 +6289,9 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info) { if (toc_rel_hash->h->u.toc_indx < 0) { - if (! ((*info->callbacks->unattached_reloc) - (info, toc_rel_hash->h->root.root.string, - NULL, o, toc_rel_hash->rel->r_vaddr))) - goto error_return; + (*info->callbacks->unattached_reloc) + (info, toc_rel_hash->h->root.root.string, + NULL, o, toc_rel_hash->rel->r_vaddr); toc_rel_hash->h->u.toc_indx = 0; } toc_rel_hash->rel->r_symndx = toc_rel_hash->h->u.toc_indx; |