From 1a72702bb30ec3f94627cfcae684823b413f20b9 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 27 May 2016 17:20:55 +0930 Subject: 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. --- bfd/elf32-rl78.c | 45 ++++++++++++++------------------------------- 1 file changed, 14 insertions(+), 31 deletions(-) (limited to 'bfd/elf32-rl78.c') diff --git a/bfd/elf32-rl78.c b/bfd/elf32-rl78.c index b6e0eb8..70011f9 100644 --- a/bfd/elf32-rl78.c +++ b/bfd/elf32-rl78.c @@ -295,7 +295,6 @@ rl78_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, static bfd_vma get_symbol_value (const char * name, - bfd_reloc_status_type * status, struct bfd_link_info * info, bfd * input_bfd, asection * input_section, @@ -312,12 +311,8 @@ get_symbol_value (const char * name, || (h->type != bfd_link_hash_defined && h->type != bfd_link_hash_defweak)) { - bfd_reloc_status_type res; - - res = info->callbacks->undefined_symbol + (*info->callbacks->undefined_symbol) (info, name, input_bfd, input_section, offset, TRUE); - if (status) - * status = res; return 0; } @@ -327,44 +322,36 @@ get_symbol_value (const char * name, } static bfd_vma -get_romstart (bfd_reloc_status_type * status, - struct bfd_link_info * info, +get_romstart (struct bfd_link_info * info, bfd * abfd, asection * sec, int offset) { static bfd_boolean cached = FALSE; static bfd_vma cached_value = 0; - static bfd_reloc_status_type cached_status; if (!cached) { - cached_value = get_symbol_value ("_start", & cached_status, info, abfd, sec, offset); + cached_value = get_symbol_value ("_start", info, abfd, sec, offset); cached = TRUE; } - if (status) - * status = cached_status; return cached_value; } static bfd_vma -get_ramstart (bfd_reloc_status_type * status, - struct bfd_link_info * info, +get_ramstart (struct bfd_link_info * info, bfd * abfd, asection * sec, int offset) { static bfd_boolean cached = FALSE; static bfd_vma cached_value = 0; - static bfd_reloc_status_type cached_status; if (!cached) { - cached_value = get_symbol_value ("__datastart", & cached_status, info, abfd, sec, offset); + cached_value = get_symbol_value ("__datastart", info, abfd, sec, offset); cached = TRUE; } - if (status) - * status = cached_status; return cached_value; } @@ -573,12 +560,12 @@ rl78_special_reloc (bfd * input_bfd, break; case R_RL78_OPromtop: - relocation = get_romstart (&r, NULL, input_bfd, input_section, + relocation = get_romstart (NULL, input_bfd, input_section, reloc->address); break; case R_RL78_OPramtop: - relocation = get_ramstart (&r, NULL, input_bfd, input_section, + relocation = get_ramstart (NULL, input_bfd, input_section, reloc->address); break; } @@ -1068,12 +1055,12 @@ rl78_elf_relocate_section break; case R_RL78_OPromtop: - relocation = get_romstart (&r, info, input_bfd, input_section, rel->r_offset); + relocation = get_romstart (info, input_bfd, input_section, rel->r_offset); (void) rl78_compute_complex_reloc (r_type, relocation, input_section); break; case R_RL78_OPramtop: - relocation = get_ramstart (&r, info, input_bfd, input_section, rel->r_offset); + relocation = get_ramstart (info, input_bfd, input_section, rel->r_offset); (void) rl78_compute_complex_reloc (r_type, relocation, input_section); break; @@ -1094,15 +1081,14 @@ rl78_elf_relocate_section if (r_type == R_RL78_DIR24S_PCREL) msg = _("%B(%A): error: call to undefined function '%s'"); else - r = info->callbacks->reloc_overflow + (*info->callbacks->reloc_overflow) (info, (h ? &h->root : NULL), name, howto->name, (bfd_vma) 0, input_bfd, input_section, rel->r_offset); break; case bfd_reloc_undefined: - r = info->callbacks->undefined_symbol - (info, name, input_bfd, input_section, rel->r_offset, - TRUE); + (*info->callbacks->undefined_symbol) + (info, name, input_bfd, input_section, rel->r_offset, TRUE); break; case bfd_reloc_other: @@ -1128,9 +1114,6 @@ rl78_elf_relocate_section if (msg) _bfd_error_handler (msg, input_bfd, input_section, name); - - if (! r) - return FALSE; } } @@ -1932,12 +1915,12 @@ rl78_offset_for_reloc (bfd * abfd, break; case R_RL78_OPromtop: - symval = get_romstart (NULL, info, input_bfd, input_section, rel->r_offset); + symval = get_romstart (info, input_bfd, input_section, rel->r_offset); (void) rl78_compute_complex_reloc (r_type, symval, input_section); break; case R_RL78_OPramtop: - symval = get_ramstart (NULL, info, input_bfd, input_section, rel->r_offset); + symval = get_ramstart (info, input_bfd, input_section, rel->r_offset); (void) rl78_compute_complex_reloc (r_type, symval, input_section); break; -- cgit v1.1