aboutsummaryrefslogtreecommitdiff
path: root/bfd/coff-ppc.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2007-10-15 02:00:11 +0000
committerAlan Modra <amodra@gmail.com>2007-10-15 02:00:11 +0000
commitb1657152098cd6a327e6d308bae00573b8c33daf (patch)
tree47c0962ef821ea8b44ac58f91776b9deaa79c7d3 /bfd/coff-ppc.c
parent919bea4130fa41aa5fa5580fe361e1c88a6fdf2e (diff)
downloadgdb-b1657152098cd6a327e6d308bae00573b8c33daf.zip
gdb-b1657152098cd6a327e6d308bae00573b8c33daf.tar.gz
gdb-b1657152098cd6a327e6d308bae00573b8c33daf.tar.bz2
* coff-arm.c (arm_emit_base_file_entry): Check fwrite return value.
Return status. Adjust callers. * coff-mcore.c (mcore_emit_base_file_entry): Likewise. * coff-ppc.c (write_base_file_entry): New function. (coff_ppc_relocate_section): Use it. * elf32-arm.c (find_thumb_glue): Check asprintf return status. (find_arm_glue): Likewise. * vms-misc.c (_bfd_vms_output_flush): Check fwrite return value.
Diffstat (limited to 'bfd/coff-ppc.c')
-rw-r--r--bfd/coff-ppc.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/bfd/coff-ppc.c b/bfd/coff-ppc.c
index 7e5f126..6f903e8 100644
--- a/bfd/coff-ppc.c
+++ b/bfd/coff-ppc.c
@@ -982,6 +982,18 @@ static bfd_boolean in_reloc_p(abfd, howto)
&& (howto->type != IMAGE_REL_PPC_TOCREL16_DEFN) ;
}
+static bfd_boolean
+write_base_file_entry (bfd *obfd, struct bfd_link_info *info, bfd_vma addr)
+{
+ if (coff_data (obfd)->pe)
+ addr -= pe_data (obfd)->pe_opthdr.ImageBase;
+ if (fwrite (&addr, sizeof (addr), 1, (FILE *) info->base_file) == 1)
+ return TRUE;
+
+ bfd_set_error (bfd_error_system_call);
+ return FALSE;
+}
+
/* The reloc processing routine for the optimized COFF linker. */
static bfd_boolean
@@ -1237,10 +1249,8 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
bfd_vma addr = (toc_section->output_section->vma
+ toc_section->output_offset + our_toc_offset);
- if (coff_data (output_bfd)->pe)
- addr -= pe_data(output_bfd)->pe_opthdr.ImageBase;
-
- fwrite (&addr, 1,4, (FILE *) info->base_file);
+ if (!write_base_file_entry (output_bfd, info, addr))
+ return FALSE;
}
/* FIXME: this test is conservative. */
@@ -1453,15 +1463,13 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
/* Relocation to a symbol in a section which
isn't absolute - we output the address here
to a file. */
- bfd_vma addr = rel->r_vaddr
- - input_section->vma
- + input_section->output_offset
- + input_section->output_section->vma;
+ bfd_vma addr = (rel->r_vaddr
+ - input_section->vma
+ + input_section->output_offset
+ + input_section->output_section->vma);
- if (coff_data (output_bfd)->pe)
- addr -= pe_data (output_bfd)->pe_opthdr.ImageBase;
-
- fwrite (&addr, 1,4, (FILE *) info->base_file);
+ if (!write_base_file_entry (output_bfd, info, addr))
+ return FALSE;
}
}