diff options
author | Alan Modra <amodra@bigpond.net.au> | 2007-10-15 02:00:11 +0000 |
---|---|---|
committer | Alan Modra <amodra@bigpond.net.au> | 2007-10-15 02:00:11 +0000 |
commit | ee7e2263dd56e7e346f2a158cde159eba3bee878 (patch) | |
tree | a1b9a1062b973f40f753ebe2ff4d76785d285fc3 /bfd/coff-ppc.c | |
parent | 85c1c29c13eebc5dbcce0962fbc29216b43315d8 (diff) | |
download | gdb-ee7e2263dd56e7e346f2a158cde159eba3bee878.tar.gz |
* 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.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/bfd/coff-ppc.c b/bfd/coff-ppc.c index 7e5f1264cce..6f903e84c50 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; } } |