From: Ian Lance Taylor Date: Fri, 27 Mar 1998 21:30:53 +0000 (+0000) Subject: Fix gcc -Wall warnings. See ChangeLog for details. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f6727b9083c41114889541d26cdad5f9d011c863;p=binutils-gdb.git Fix gcc -Wall warnings. See ChangeLog for details. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 514eb4f9583..89aa40045fc 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,97 @@ +Fri Mar 27 16:06:02 1998 Ian Lance Taylor + + Fix some gcc -Wall warnings: + * aout-arm.c (MY(fix_pcrel_26)): Add casts to avoid warnings. + * archive.c (_bfd_generic_read_ar_hdr_mag): Likewise. + * archures.c (bfd_default_scan): Likewise. + * bfd.c (bfd_scan_vma): Likewise. + * binary.c (mangle_name): Likewise + * coff-arm.c (aoutarm_fix_pcrel_26): Likewise. + * coff-sh.c (sh_relocate_section): Likewise. + * coff-stgo32.c (create_go32_stub): Likewise. + * coffcode.h (coff_slurp_line_table): Likewise. + * ecoff.c (_bfd_ecoff_write_armap): Likewise. + * elf.c (_bfd_elf_make_section_from_shdr): Likewise. + (assign_file_positions_for_segments): Likewise. + * elf32-mips.c (mips_elf_relocate_section): Likewise. + * elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise. + * oasys.c (oasys_write_sections): Likewise. + * ppcboot.c (ppcboot_object_p): Likewise. + (mangle_name): Likewise. + * riscix.c (riscix_fix_pcrel_26): Likewise. + * srec.c (srec_scan): Likewise. + * stabs.c (_bfd_write_section_stabs): Likewise. + * sunos.c (sunos_add_dynamic_symbols): Likewise. + * aout-ns32k.c (_bfd_ns32k_relocate_contents): Add default case to + switch. Declare parameters for function pointers. + * archures.c (bfd_default_scan): Add braces to avoid ambiguous if + warning. + * elf.c (elf_sort_sections): Likewise. + * coff-arm.c (coff_thumb_pcrel_common): Initialize relocation. + Add default cases to switches. + (coff_arm_relocate_section): Remove unused local variables. + Always set rstat. + (coff_arm_bfd_set_private_flags): Change flag variable to type + flagword. + * coff-mips.c (mips_relocate_section): Initialize use_lo. + * coff-ppc.c (ppc_record_toc_entry): Change i to unsigned int. + (dump_toc): Change cat to const, and initialize it. + * coff-sh.c (sh_relax_delete_bytes): Initialize start and voff. + * elf32-sh.c (sh_elf_relax_delete_bytes): Likewise. + (sh_elf_relocate_section): Initialize r_symndx. + * coffcode.h (coff_compute_section_file_positions): Only declare + old_sofar if ALIGN_SECTIONS_IN_FILE. + (coff_write_object_contents): Initialize csym. + * coffgen.c (coff_pointerize_aux): Make type and class unsigned. + * cpu-ns32k.c (_bfd_ns32k_get_displacement): Add default case to + switch. + * dwarf2.c: Include libiberty.h. + (read_2_signed_bytes, read_4_signed_bytes): Comment out. + (decode_line_info): Remove unused local variables. + * elf32-m32r.c (m32r_elf_sda16_reloc): Likewise. + (m32r_elf_relocate_section): Likewise. + * elf32-v850.c (v850_elf_store_addend_in_insn): Likewise. + (v850_elf_reloc): Likewise. + * elf-bfd.h (elf_linker_section_t): Make alignment unsigned. + (struct elf_obj_tdata): Make cverdefs and cverrefs unsigned. + * elf.c (assign_file_positions_for_segments): Always set adjust. + * elf32-d30v.c (bfd_elf_d30v_reloc): Initialize tmp_addr. Fully + parenthesize expression. + * elf32-m32r.c (m32r_elf_relocate_section): Always initialize h. + (m32r_elf_object_p): Return a value. + (m32r_elf_print_private_bfd_data): Change fprintf format string. + * elf32-mips.c (mips_elf_final_link): Initialize last. + (mips_elf_finish_dynamic_sections): Initialize last and dindx. + * elf32-v850.c (v850_elf_object_p): Return a value. + (v850_elf_print_private_bfd_data): Change fprintf format string. + * elfcode.h (elf_slurp_symbol_table): Change symcount and i to + unsigned long. + * elflink.h (elf_link_add_object_symbols): Change vernum to + unsigned int, and initialize it. Change fprintf format string. + (NAME(bfd_elf,size_dynamic_sections)): Cast -1 to bfd_size_type + when setting or comparing to soname_indx. + (elf_create_pointer_linker_section): Change num_symbols to + unsigned int. + * libcoff-in.h (coff_data_type): Change flags to flagword. + * peicode.h (pe_print_idata): Initialize idx. Change j to + bfd_size_type. Initialize hint_member. Remove useless test to + time_stamp. + (pe_print_edata): Change num_functions and num_names in struct + EDT_type to unsigned long. Remove cast. Change fprintf format + string. + * ppcboot.c (ppcboot_object_p): Change i to size_t. + * reloc.c (bfd_get_reloc_size): Change return type to unsigned + int. + * reloc16.c (bfd_coff_reloc16_relax_section): Change shrinks to + int *. Update uses. Change j to long. + * bfd-in2.h, libcoff.h: Rebuild. + +Thu Mar 26 13:32:17 1998 Ian Lance Taylor + + * coffcode.h (coff_new_section_hook): Set the type and storage + class in the native symbol information allocated for a new section + symbol. + Thu Mar 26 10:13:41 1998 Nick Clifton * peicode.h: Chain together calls to diff --git a/bfd/coff-arm.c b/bfd/coff-arm.c index af129eb6823..9840d7b54e7 100644 --- a/bfd/coff-arm.c +++ b/bfd/coff-arm.c @@ -1,5 +1,6 @@ /* BFD back-end for ARM COFF files. - Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998 + Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -496,7 +497,7 @@ aoutarm_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section, /* Check for overflow */ if (relocation & 0x02000000) { - if ((relocation & ~0x03ffffff) != ~0x03ffffff) + if ((relocation & ~ (bfd_vma) 0x03ffffff) != ~ (bfd_vma) 0x03ffffff) flag = bfd_reloc_overflow; } else if (relocation & ~0x03ffffff) @@ -527,7 +528,7 @@ coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, input_section, char **error_message; thumb_pcrel_branchtype btype; { - bfd_vma relocation; + bfd_vma relocation = 0; bfd_size_type addr = reloc_entry->address; long target = bfd_get_32 (abfd, (bfd_byte *) data + addr); bfd_reloc_status_type flag = bfd_reloc_ok; @@ -586,6 +587,9 @@ coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, input_section, else relocation = ((target & 0x7ff) << 12) | ((target & 0x07ff0000) >> 15); break; + + default: + abort (); } relocation = (relocation ^ signbit) - signbit; /* Sign extend */ @@ -623,6 +627,9 @@ coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, input_section, else target |= ((relocation & 0xffe) << 15) | ((relocation >> 12) & 0x7ff); break; + + default: + abort (); } bfd_put_32 (abfd, target, (bfd_byte *) data + addr); @@ -1073,7 +1080,6 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, && ( h->root.type == bfd_link_hash_defined || h->root.type == bfd_link_hash_defweak)) { - asection * sec; asection * h_sec = h->root.u.def.section; const char * name = h->root.root.string; @@ -1088,14 +1094,10 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, || h->class == C_THUMBEXTFUNC) { /* Arm code calling a Thumb function */ - signed long int final_disp; unsigned long int tmp; long int my_offset; - long int offset; asection * s = 0; - unsigned long int return_address; long int ret_offset; - long int disp; struct coff_link_hash_entry * myh; myh = find_arm_glue (info, name, input_bfd); @@ -1166,8 +1168,6 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, || h->class == C_LABEL) { /* Thumb code calling an ARM function */ - unsigned long int return_address; - signed long int final_disp; asection * s = 0; long int my_offset; unsigned long int tmp; @@ -1292,7 +1292,7 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, #if 1 /* THUMBEXTENSION */ if (done) - ; + rstat = bfd_reloc_ok; /* Only perform this fix during the final link, not a relocatable link. nickc@cygnus.com */ else if (! info->relocateable && howto->type == ARM_THUMB23) @@ -1932,7 +1932,7 @@ coff_arm_bfd_set_private_flags (abfd, flags) bfd * abfd; flagword flags; { - int flag; + flagword flag; BFD_ASSERT (abfd != NULL); @@ -2064,9 +2064,11 @@ coff_arm_is_local_label_name (abfd, name) #define coff_bfd_set_private_flags coff_arm_bfd_set_private_flags #define coff_bfd_copy_private_bfd_data coff_arm_bfd_copy_private_bfd_data -extern boolean coff_arm_final_link_postscript (); extern boolean coff_arm_bfd_set_private_flags (); extern boolean coff_arm_bfd_merge_private_bfd_data (); +extern boolean coff_arm_bfd_copy_private_bfd_data (); +extern boolean coff_arm_bfd_print_private_bfd_data (); +extern boolean coff_arm_final_link_postscript (); extern boolean coff_arm_link_output_has_begun (); extern boolean coff_arm_is_local_label_name (); diff --git a/bfd/elf.c b/bfd/elf.c index 71d13f78af2..5ea51070eb9 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -1,5 +1,5 @@ /* ELF executable support for BFD. - Copyright 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -401,7 +401,7 @@ _bfd_elf_make_section_from_shdr (abfd, hdr, name) && phdr->p_vaddr <= hdr->sh_addr && phdr->p_vaddr + phdr->p_memsz >= hdr->sh_addr + hdr->sh_size && ((flags & SEC_LOAD) == 0 - || (phdr->p_offset <= hdr->sh_offset + || (phdr->p_offset <= (bfd_vma) hdr->sh_offset && (phdr->p_offset + phdr->p_filesz >= hdr->sh_offset + hdr->sh_size)))) { @@ -2276,10 +2276,12 @@ elf_sort_sections (arg1, arg2) #define TOEND(x) (((x)->flags & SEC_LOAD) == 0) if (TOEND (sec1)) - if (TOEND (sec2)) - return sec1->target_index - sec2->target_index; - else - return 1; + { + if (TOEND (sec2)) + return sec1->target_index - sec2->target_index; + else + return 1; + } if (TOEND (sec2)) return -1; @@ -2432,7 +2434,7 @@ assign_file_positions_for_segments (abfd) { BFD_ASSERT (p->p_type == PT_LOAD); - if (p->p_vaddr < off) + if (p->p_vaddr < (bfd_vma) off) { _bfd_error_handler ("%s: Not enough room for program headers, try linking with -N", bfd_get_filename (abfd)); @@ -2526,6 +2528,8 @@ assign_file_positions_for_segments (abfd) else adjust = (sec->vma - voff) % align; } + else + adjust = 0; if (adjust != 0) { @@ -2909,11 +2913,6 @@ prep_headers (abfd) case bfd_arch_mn10300: i_ehdrp->e_machine = EM_CYGNUS_MN10300; break; -/* start-sanitize-sky */ - case bfd_arch_txvu: - i_ehdrp->e_machine = EM_CYGNUS_TXVU; - break; -/* end-sanitize-sky */ /* also note that EM_M32, AT&T WE32100 is unknown to bfd */ default: i_ehdrp->e_machine = EM_NONE; diff --git a/bfd/elflink.h b/bfd/elflink.h index cde235454f5..21bd270c0a4 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -1,5 +1,5 @@ /* ELF linker support. - Copyright 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright 1995, 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -1098,7 +1098,7 @@ elf_link_add_object_symbols (abfd, info) if (info->hash->creator->flavour == bfd_target_elf_flavour) { Elf_Internal_Versym iver; - int vernum; + unsigned int vernum = 0; boolean override; if (ever != NULL) @@ -1123,7 +1123,7 @@ elf_link_add_object_symbols (abfd, info) if (vernum > elf_tdata (abfd)->dynverdef_hdr.sh_info) { (*_bfd_error_handler) - ("%s: %s: invalid version %d (max %d)", + ("%s: %s: invalid version %u (max %d)", abfd->filename, name, vernum, elf_tdata (abfd)->dynverdef_hdr.sh_info); bfd_set_error (bfd_error_bad_value); @@ -2211,7 +2211,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, *sinterpptr = NULL; - soname_indx = -1; + soname_indx = (bfd_size_type) -1; if (info->hash->creator->flavour != bfd_target_elf_flavour) return true; @@ -2458,7 +2458,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, def.vd_next = (sizeof (Elf_External_Verdef) + sizeof (Elf_External_Verdaux)); - if (soname_indx != -1) + if (soname_indx != (bfd_size_type) -1) { def.vd_hash = bfd_elf_hash ((const unsigned char *) soname); defaux.vda_name = soname_indx; @@ -5101,7 +5101,7 @@ elf_create_pointer_linker_section (abfd, info, lsect, h, rel) /* Allocate a table to hold the local symbols if first time */ if (!ptr) { - int num_symbols = elf_tdata (abfd)->symtab_hdr.sh_info; + unsigned int num_symbols = elf_tdata (abfd)->symtab_hdr.sh_info; register unsigned int i; ptr = (elf_linker_section_pointers_t **)