From a253d456e1c74d11503d31fe813da7eeeceed338 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Wed, 17 Apr 2013 14:16:01 +0000 Subject: [PATCH] * coffcode.h: Added a cast to void when a bfd_set_section_*() macro's return value is ignored. * elf32-hppa.c: Likewise. * elf32-tic6x.c: Likewise. * mach-o.c: Likewise. * mmo.c: Likewise. * opncls.c: Likewise. * peicode.h: Likewise. * elf32-m32r.c: Check return value of bfd_set_section_*(). * elfnn-ia64.c: Likewise. * elfxx-mips.c: Likewise. * vms-alpha.c: Likewise. --- bfd/ChangeLog | 15 +++++++++++++++ bfd/coffcode.h | 6 ++---- bfd/compress.c | 7 ++++--- bfd/elf32-hppa.c | 6 ++---- bfd/elf32-m32r.c | 6 +++--- bfd/elf32-tic6x.c | 5 ++--- bfd/elfnn-ia64.c | 13 +++++++------ bfd/elfxx-mips.c | 24 ++++++++++++++---------- bfd/mach-o.c | 6 ++---- bfd/mmo.c | 18 ++++++++++-------- bfd/opncls.c | 7 +++---- bfd/peicode.h | 6 ++---- bfd/vms-alpha.c | 6 +++--- 13 files changed, 69 insertions(+), 56 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 883c4a2..40c339f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,18 @@ +2013-04-17 Luca Pizzamiglio + + * coffcode.h: Added a cast to void when a bfd_set_section_*() + macro's return value is ignored. + * elf32-hppa.c: Likewise. + * elf32-tic6x.c: Likewise. + * mach-o.c: Likewise. + * mmo.c: Likewise. + * opncls.c: Likewise. + * peicode.h: Likewise. + * elf32-m32r.c: Check return value of bfd_set_section_*(). + * elfnn-ia64.c: Likewise. + * elfxx-mips.c: Likewise. + * vms-alpha.c: Likewise. + 2013-04-15 H.J. Lu PR ld/15371 diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 49c13c3..9d9c992 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -1,7 +1,5 @@ /* Support for the generic parts of most COFF variants, for BFD. - Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 - Free Software Foundation, Inc. + Copyright 1990-2013 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -3447,7 +3445,7 @@ coff_compute_section_file_positions (bfd * abfd) incremented in coff_set_section_contents. This is right for SVR3.2. */ if (strcmp (current->name, _LIB) == 0) - bfd_set_section_vma (abfd, current, 0); + (void) bfd_set_section_vma (abfd, current, 0); #endif #ifdef ALIGN_SECTIONS_IN_FILE diff --git a/bfd/compress.c b/bfd/compress.c index eb3bc53..46c2bcb 100644 --- a/bfd/compress.c +++ b/bfd/compress.c @@ -45,19 +45,20 @@ decompress_contents (bfd_byte *compressed_buffer, strm.next_in = (Bytef*) compressed_buffer + 12; strm.avail_out = uncompressed_size; + BFD_ASSERT (Z_OK == 0); rc = inflateInit (&strm); while (strm.avail_in > 0 && strm.avail_out > 0) { if (rc != Z_OK) - return FALSE; + break; strm.next_out = ((Bytef*) uncompressed_buffer + (uncompressed_size - strm.avail_out)); rc = inflate (&strm, Z_FINISH); if (rc != Z_STREAM_END) - return FALSE; + break; rc = inflateReset (&strm); } - rc = inflateEnd (&strm); + rc |= inflateEnd (&strm); return rc == Z_OK && strm.avail_out == 0; } #endif diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 4ffa3d2..dfffbcb 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -1,7 +1,5 @@ /* BFD back-end for HP PA-RISC ELF files. - Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001, - 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 - Free Software Foundation, Inc. + Copyright 1990-2013 Free Software Foundation, Inc. Original code by Center for Software Science @@ -2370,7 +2368,7 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, bfd_size_type mask; if (gotalign > pltalign) - bfd_set_section_alignment (dynobj, sec, gotalign); + (void) bfd_set_section_alignment (dynobj, sec, gotalign); mask = ((bfd_size_type) 1 << gotalign) - 1; sec->size = (sec->size + sizeof (plt_stub) + mask) & ~mask; } diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index 789a456..71e8fc7 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -1,6 +1,5 @@ /* M32R-specific support for 32-bit ELF. - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. + Copyright 1996-2013 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -1390,7 +1389,8 @@ m32r_elf_add_symbol_hook (bfd *abfd, flags); if (s == NULL) return FALSE; - bfd_set_section_alignment (abfd, s, 2); + if (! bfd_set_section_alignment (abfd, s, 2)) + return FALSE; } bh = bfd_link_hash_lookup (info->hash, "_SDA_BASE_", diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c index 04ef708..77c6ad1 100644 --- a/bfd/elf32-tic6x.c +++ b/bfd/elf32-tic6x.c @@ -1,6 +1,5 @@ /* 32-bit ELF support for TI C6X - Copyright 2010, 2011, 2012 - Free Software Foundation, Inc. + Copyright 2010-2013 Free Software Foundation, Inc. Contributed by Joseph Myers Bernd Schmidt @@ -3038,7 +3037,7 @@ elf32_tic6x_add_symbol_hook (bfd *abfd, *secp = bfd_make_section_old_way (abfd, ".scommon"); (*secp)->flags |= SEC_IS_COMMON; *valp = sym->st_size; - bfd_set_section_alignment (abfd, *secp, bfd_log2 (sym->st_value)); + (void) bfd_set_section_alignment (abfd, *secp, bfd_log2 (sym->st_value)); break; } diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c index 05c2f1b..117b4c8 100644 --- a/bfd/elfnn-ia64.c +++ b/bfd/elfnn-ia64.c @@ -1,6 +1,5 @@ /* IA-64 support for 64-bit ELF - Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. + Copyright 1998-2013 Free Software Foundation, Inc. Contributed by David Mosberger-Tang This file is part of BFD, the Binary File Descriptor library. @@ -1546,7 +1545,8 @@ elfNN_ia64_create_dynamic_sections (bfd *abfd, bfd_set_section_flags (abfd, ia64_info->root.sgot, SEC_SMALL_DATA | flags); /* The .got section is always aligned at 8 bytes. */ - bfd_set_section_alignment (abfd, ia64_info->root.sgot, 3); + if (! bfd_set_section_alignment (abfd, ia64_info->root.sgot, 3)) + return FALSE; } if (!get_pltoff (abfd, info, ia64_info)) @@ -1952,16 +1952,17 @@ get_got (bfd *abfd, struct bfd_link_info *info, if (!dynobj) ia64_info->root.dynobj = dynobj = abfd; if (!_bfd_elf_create_got_section (dynobj, info)) - return 0; + return NULL; got = ia64_info->root.sgot; /* The .got section is always aligned at 8 bytes. */ if (!bfd_set_section_alignment (abfd, got, 3)) - return 0; + return NULL; flags = bfd_get_section_flags (abfd, got); - bfd_set_section_flags (abfd, got, SEC_SMALL_DATA | flags); + if (! bfd_set_section_flags (abfd, got, SEC_SMALL_DATA | flags)) + return NULL; } return got; diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 317e7b2..fa807713 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -1,7 +1,5 @@ /* MIPS-specific support for ELF - Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, - 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 - Free Software Foundation, Inc. + Copyright 1993-2013 Free Software Foundation, Inc. Most of the information added by Ian Lance Taylor, Cygnus Support, . @@ -7265,20 +7263,24 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) /* Change alignments of some sections. */ s = bfd_get_linker_section (abfd, ".hash"); if (s != NULL) - bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd)); + (void) bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd)); + s = bfd_get_linker_section (abfd, ".dynsym"); if (s != NULL) - bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd)); + (void) bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd)); + s = bfd_get_linker_section (abfd, ".dynstr"); if (s != NULL) - bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd)); + (void) bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd)); + /* ??? */ s = bfd_get_section_by_name (abfd, ".reginfo"); if (s != NULL) - bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd)); + (void) bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd)); + s = bfd_get_linker_section (abfd, ".dynamic"); if (s != NULL) - bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd)); + (void) bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd)); } if (!info->shared) @@ -13533,7 +13535,8 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *info) /* Structure for saying that BFD machine EXTENSION extends BASE. */ -struct mips_mach_extension { +struct mips_mach_extension +{ unsigned long extension, base; }; @@ -13541,7 +13544,8 @@ struct mips_mach_extension { /* An array describing how BFD machines relate to one another. The entries are ordered topologically with MIPS I extensions listed last. */ -static const struct mips_mach_extension mips_mach_extensions[] = { +static const struct mips_mach_extension mips_mach_extensions[] = +{ /* MIPS64r2 extensions. */ { bfd_mach_mips_octeon2, bfd_mach_mips_octeonp }, { bfd_mach_mips_octeonp, bfd_mach_mips_octeon }, diff --git a/bfd/mach-o.c b/bfd/mach-o.c index c92b530..e1bbd29 100644 --- a/bfd/mach-o.c +++ b/bfd/mach-o.c @@ -1,7 +1,5 @@ /* Mach-O support for BFD. - Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, - 2009, 2010, 2011, 2012 - Free Software Foundation, Inc. + Copyright 1999-2013 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -2693,7 +2691,7 @@ bfd_mach_o_new_section_hook (bfd *abfd, asection *sec) s->flags = xlat->macho_sectype | xlat->macho_secattr; s->align = xlat->sectalign > bfdalign ? xlat->sectalign : bfdalign; - bfd_set_section_alignment (abfd, sec, s->align); + (void) bfd_set_section_alignment (abfd, sec, s->align); bfd_flags = bfd_get_section_flags (abfd, sec); if (bfd_flags == SEC_NO_FLAGS) bfd_set_section_flags (abfd, sec, xlat->bfd_flags); diff --git a/bfd/mmo.c b/bfd/mmo.c index e336723..cd7b0fc 100644 --- a/bfd/mmo.c +++ b/bfd/mmo.c @@ -1,6 +1,5 @@ /* BFD back-end for mmo objects (MMIX-specific object-format). - Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011 - Free Software Foundation, Inc. + Copyright 2001-2013 Free Software Foundation, Inc. Written by Hans-Peter Nilsson (hp@bitrange.com). Infrastructure and other bits originally copied from srec.c and binary.c. @@ -662,8 +661,9 @@ mmo_decide_section (bfd *abfd, bfd_vma vma) if (sec == NULL) return NULL; - if (! sec->user_set_vma) - bfd_set_section_vma (abfd, sec, vma); + if (! sec->user_set_vma && ! bfd_set_section_vma (abfd, sec, vma)) + return NULL; + if (! bfd_set_section_flags (abfd, sec, bfd_get_section_flags (abfd, sec) | SEC_CODE | SEC_LOAD | SEC_ALLOC)) @@ -676,8 +676,9 @@ mmo_decide_section (bfd *abfd, bfd_vma vma) if (sec == NULL) return NULL; - if (! sec->user_set_vma) - bfd_set_section_vma (abfd, sec, vma); + if (! sec->user_set_vma && ! bfd_set_section_vma (abfd, sec, vma)) + return NULL; + if (! bfd_set_section_flags (abfd, sec, bfd_get_section_flags (abfd, sec) | SEC_LOAD | SEC_ALLOC)) @@ -692,8 +693,9 @@ mmo_decide_section (bfd *abfd, bfd_vma vma) /* If there's still no suitable section, make a new one. */ sprintf (sec_name, ".MMIX.sec.%d", abfd->tdata.mmo_data->sec_no++); sec = mmo_make_section (abfd, sec_name); - if (! sec->user_set_vma) - bfd_set_section_vma (abfd, sec, vma); + + if (! sec->user_set_vma && ! bfd_set_section_vma (abfd, sec, vma)) + return NULL; if (! bfd_set_section_flags (abfd, sec, bfd_get_section_flags (abfd, sec) diff --git a/bfd/opncls.c b/bfd/opncls.c index 1217cea..3879a65 100644 --- a/bfd/opncls.c +++ b/bfd/opncls.c @@ -1,7 +1,5 @@ /* opncls.c -- open and close a BFD. - Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, - 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 - Free Software Foundation, Inc. + Copyright 1990-2013 Free Software Foundation, Inc. Written by Cygnus Support. @@ -255,12 +253,13 @@ bfd_fopen (const char *filename, const char *target, const char *mode, int fd) return NULL; } nbfd->opened_once = TRUE; + /* If we opened the file by name, mark it cacheable; we can close it and reopen it later. However, if a file descriptor was provided, then it may have been opened with special flags that make it unsafe to close and reopen the file. */ if (fd == -1) - bfd_set_cacheable (nbfd, TRUE); + (void) bfd_set_cacheable (nbfd, TRUE); return nbfd; } diff --git a/bfd/peicode.h b/bfd/peicode.h index 66c8198..64ca092 100644 --- a/bfd/peicode.h +++ b/bfd/peicode.h @@ -1,7 +1,5 @@ /* Support for the generic parts of PE/PEI, for BFD. - Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 - Free Software Foundation, Inc. + Copyright 1995-2013 Free Software Foundation, Inc. Written by Cygnus Solutions. This file is part of BFD, the Binary File Descriptor library. @@ -610,7 +608,7 @@ pe_ILF_make_a_section (pe_ILF_vars * vars, bfd_set_section_flags (vars->abfd, sec, flags | extra_flags); - bfd_set_section_alignment (vars->abfd, sec, 2); + (void) bfd_set_section_alignment (vars->abfd, sec, 2); /* Check that we will not run out of space. */ BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size); diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c index 3383b0f..4edc226 100644 --- a/bfd/vms-alpha.c +++ b/bfd/vms-alpha.c @@ -1,6 +1,5 @@ /* vms.c -- BFD back-end for EVAX (openVMS/Alpha) files. - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. + Copyright 1996-2013 Free Software Foundation, Inc. Initial version written by Klaus Kaempf (kkaempf@rmi.de) Major rewrite by Adacore. @@ -9118,7 +9117,8 @@ vms_new_section_hook (bfd * abfd, asection *section) vms_debug2 ((1, "vms_new_section_hook (%p, [%d]%s)\n", abfd, section->index, section->name)); - bfd_set_section_alignment (abfd, section, 0); + if (! bfd_set_section_alignment (abfd, section, 0)) + return FALSE; vms_debug2 ((7, "%d: %s\n", section->index, section->name)); -- 2.7.4