X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Fcoffcode.h;h=af015bb769470186b03bcf5d33fad69aa3eb8017;hb=6812b6077e4a09eab08458428f09c28ec58fc514;hp=0f984fecae4828d90b93552df8962f2815e3cdb3;hpb=326e32d7ce8a83f59192657c48c9b9980466b939;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 0f984fecae..af015bb769 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -1045,7 +1045,7 @@ SUBSUBSECTION */ -static void +static boolean coff_write_relocs (abfd) bfd * abfd; { @@ -1056,7 +1056,8 @@ coff_write_relocs (abfd) struct external_reloc dst; arelent **p = s->orelocation; - bfd_seek (abfd, s->rel_filepos, SEEK_SET); + if (bfd_seek (abfd, s->rel_filepos, SEEK_SET) != 0) + return false; for (i = 0; i < s->reloc_count; i++) { struct internal_reloc n; @@ -1100,9 +1101,12 @@ coff_write_relocs (abfd) n.r_type = q->howto->type; #endif coff_swap_reloc_out (abfd, &n, &dst); - bfd_write ((PTR) & dst, 1, RELSZ, abfd); + if (bfd_write ((PTR) & dst, 1, RELSZ, abfd) != RELSZ) + return false; } } + + return true; } /* Set flags and magic number of a coff file from architecture and machine @@ -1558,10 +1562,12 @@ coff_write_object_contents (abfd) /* Write section headers to the file. */ internal_f.f_nscns = 0; - bfd_seek (abfd, - (file_ptr) ((abfd->flags & EXEC_P) ? - (FILHSZ + AOUTSZ) : FILHSZ), - SEEK_SET); + if (bfd_seek (abfd, + (file_ptr) ((abfd->flags & EXEC_P) ? + (FILHSZ + AOUTSZ) : FILHSZ), + SEEK_SET) + != 0) + return false; { #if 0 @@ -1641,7 +1647,8 @@ coff_write_object_contents (abfd) SCNHDR buff; coff_swap_scnhdr_out (abfd, §ion, &buff); - bfd_write ((PTR) (&buff), 1, SCNHSZ, abfd); + if (bfd_write ((PTR) (&buff), 1, SCNHSZ, abfd) != SCNHSZ) + return false; } @@ -1768,10 +1775,12 @@ coff_write_object_contents (abfd) if (!coff_renumber_symbols (abfd)) return false; coff_mangle_symbols (abfd); - coff_write_symbols (abfd); - if (!coff_write_linenumbers (abfd)) + if (! coff_write_symbols (abfd)) + return false; + if (! coff_write_linenumbers (abfd)) + return false; + if (! coff_write_relocs (abfd)) return false; - coff_write_relocs (abfd); } if (text_sec) { @@ -1797,13 +1806,15 @@ coff_write_object_contents (abfd) { FILHDR buff; coff_swap_filehdr_out (abfd, (PTR) & internal_f, (PTR) & buff); - bfd_write ((PTR) & buff, 1, FILHSZ, abfd); + if (bfd_write ((PTR) & buff, 1, FILHSZ, abfd) != FILHSZ) + return false; } if (abfd->flags & EXEC_P) { AOUTHDR buff; coff_swap_aouthdr_out (abfd, (PTR) & internal_a, (PTR) & buff); - bfd_write ((PTR) & buff, 1, AOUTSZ, abfd); + if (bfd_write ((PTR) & buff, 1, AOUTSZ, abfd) != AOUTSZ) + return false; } return true; } @@ -1833,7 +1844,8 @@ coff_set_section_contents (abfd, section, location, offset, count) if (section->filepos == 0) return true; - bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET); + if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0) + return false; if (count != 0) { @@ -1882,12 +1894,9 @@ buy_and_read (abfd, where, seek_direction, size) bfd_set_error (bfd_error_no_memory); return (NULL); } - bfd_seek (abfd, where, seek_direction); - if (bfd_read (area, 1, size, abfd) != size) - { - bfd_set_error (bfd_error_system_call); - return (NULL); - } /* on error */ + if (bfd_seek (abfd, where, seek_direction) != 0 + || bfd_read (area, 1, size, abfd) != size) + return (NULL); return (area); } /* buy_and_read() */ @@ -1983,7 +1992,8 @@ coff_slurp_symbol_table (abfd) unsigned int number_of_symbols = 0; if (obj_symbols (abfd)) return true; - bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET); + if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) + return false; /* Read in the symbol table */ if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL) @@ -2265,16 +2275,23 @@ SUBSUBSECTION */ #ifndef CALC_ADDEND -#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \ - if (ptr && bfd_asymbol_bfd(ptr) == abfd \ - && !bfd_is_com_section(ptr->section) \ - && !(ptr->flags & BSF_OLD_COMMON)) \ - { \ - cache_ptr->addend = -(ptr->section->vma + ptr->value); \ - } \ - else { \ - cache_ptr->addend = 0; \ - } +#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \ + { \ + coff_symbol_type *coffsym = (coff_symbol_type *) NULL; \ + if (ptr && bfd_asymbol_bfd (ptr) != abfd) \ + coffsym = (obj_symbols (abfd) \ + + (cache_ptr->sym_ptr_ptr - symbols)); \ + else if (ptr) \ + coffsym = coff_symbol_from (abfd, ptr); \ + if (coffsym != (coff_symbol_type *) NULL \ + && coffsym->native->u.syment.n_scnum == 0) \ + cache_ptr->addend = 0; \ + else if (ptr && bfd_asymbol_bfd (ptr) == abfd \ + && ptr->section != (asection *) NULL) \ + cache_ptr->addend = - (ptr->section->vma + ptr->value); \ + else \ + cache_ptr->addend = 0; \ + } #endif static boolean @@ -2406,8 +2423,6 @@ coff_canonicalize_reloc (abfd, section, relptr, symbols) return -1; tblptr = section->relocation; - if (!tblptr) - return -1; for (; count++ < section->reloc_count;) *relptr++ = tblptr++; @@ -2482,39 +2497,27 @@ static CONST bfd_coff_backend_data bfd_coff_std_swap_table = coff_reloc16_extra_cases, coff_reloc16_estimate }; -#define coff_core_file_failing_command _bfd_dummy_core_file_failing_command -#define coff_core_file_failing_signal _bfd_dummy_core_file_failing_signal -#define coff_core_file_matches_executable_p _bfd_dummy_core_file_matches_executable_p -#define coff_slurp_armap bfd_slurp_coff_armap -#define coff_slurp_extended_name_table _bfd_slurp_extended_name_table -#define coff_truncate_arname bfd_dont_truncate_arname -#define coff_openr_next_archived_file bfd_generic_openr_next_archived_file -#define coff_generic_stat_arch_elt bfd_generic_stat_arch_elt -#define coff_get_section_contents bfd_generic_get_section_contents -#define coff_close_and_cleanup bfd_generic_close_and_cleanup - -#define coff_bfd_debug_info_start bfd_void -#define coff_bfd_debug_info_end bfd_void -#define coff_bfd_debug_info_accumulate \ - (void (*) PARAMS ((bfd *, struct sec *))) bfd_void -#define coff_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents -#define coff_bfd_relax_section bfd_generic_relax_section -#ifndef coff_bfd_reloc_type_lookup -#define coff_bfd_reloc_type_lookup \ - ((CONST struct reloc_howto_struct *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr) -#endif -#define coff_bfd_link_hash_table_create _bfd_generic_link_hash_table_create -#define coff_bfd_link_add_symbols _bfd_generic_link_add_symbols -#define coff_bfd_final_link _bfd_generic_final_link +#define coff_close_and_cleanup _bfd_generic_close_and_cleanup +#define coff_bfd_free_cached_info _bfd_generic_bfd_free_cached_info +#define coff_get_section_contents _bfd_generic_get_section_contents -#ifndef coff_bfd_copy_private_section_data #define coff_bfd_copy_private_section_data \ - ((boolean (*) PARAMS ((bfd *, asection *, bfd *, asection *))) bfd_true) -#endif -#ifndef coff_bfd_copy_private_bfd_data -#define coff_bfd_copy_private_bfd_data \ - ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true) -#endif + _bfd_generic_bfd_copy_private_section_data +#define coff_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data + #ifndef coff_bfd_is_local_label #define coff_bfd_is_local_label bfd_generic_is_local_label #endif + +/* The reloc lookup routine must be supplied by each individual COFF + backend. */ +#ifndef coff_bfd_reloc_type_lookup +#define coff_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup +#endif + +#define coff_bfd_get_relocated_section_contents \ + bfd_generic_get_relocated_section_contents +#define coff_bfd_relax_section bfd_generic_relax_section +#define coff_bfd_link_hash_table_create _bfd_generic_link_hash_table_create +#define coff_bfd_link_add_symbols _bfd_generic_link_add_symbols +#define coff_bfd_final_link _bfd_generic_final_link