diff options
author | Nick Clifton <nickc@redhat.com> | 2005-03-22 16:14:43 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2005-03-22 16:14:43 +0000 |
commit | c8e7bf0d21a314ffac1844b5644b2dc454196570 (patch) | |
tree | 927d3cb38d745a209632aca7ac2e0d593ca2253c /bfd | |
parent | 28a094c2ccbb6382b49c7e60a633bb3f18306d50 (diff) | |
download | fsf-binutils-gdb-c8e7bf0d21a314ffac1844b5644b2dc454196570.zip fsf-binutils-gdb-c8e7bf0d21a314ffac1844b5644b2dc454196570.tar.gz fsf-binutils-gdb-c8e7bf0d21a314ffac1844b5644b2dc454196570.tar.bz2 |
Convert to ISO C90 formatting.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 10 | ||||
-rw-r--r-- | bfd/binary.c | 135 | ||||
-rw-r--r-- | bfd/coff-arm.c | 460 | ||||
-rw-r--r-- | bfd/coffgen.c | 603 | ||||
-rw-r--r-- | bfd/elf32-gen.c | 85 | ||||
-rw-r--r-- | bfd/elf64-gen.c | 84 | ||||
-rw-r--r-- | bfd/hash.c | 201 | ||||
-rw-r--r-- | bfd/ieee.c | 592 |
8 files changed, 852 insertions, 1318 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index dc3a74c..6361566 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,13 @@ +2005-03-22 Nick Clifton <nickc@redhat.com> + + * binary.c: Convert to ISO C90 formatting. + * coff-arm.c: Convert to ISO C90 formatting. + * coffgen.c: Convert to ISO C90 formatting. + * elf32-gen.c: Convert to ISO C90 formatting. + * elf64-gen.c: Convert to ISO C90 formatting. + * hash.c: Convert to ISO C90 formatting. + * ieee.c: Convert to ISO C90 formatting. + 2005-03-22 Daniel Jacobowitz <dan@codesourcery.com> * elf32-arm.c (elf32_arm_final_link_relocate): Don't fail for diff --git a/bfd/binary.c b/bfd/binary.c index 4528672..7dff4be 100644 --- a/bfd/binary.c +++ b/bfd/binary.c @@ -1,6 +1,6 @@ /* BFD back-end for binary objects. Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004 Free Software Foundation, Inc. + 2004, 2005 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com> This file is part of BFD, the Binary File Descriptor library. @@ -41,18 +41,6 @@ a start symbol, an end symbol, and an absolute length symbol. */ #define BIN_SYMS 3 -static bfd_boolean binary_mkobject PARAMS ((bfd *)); -static const bfd_target *binary_object_p PARAMS ((bfd *)); -static bfd_boolean binary_get_section_contents - PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type)); -static long binary_get_symtab_upper_bound PARAMS ((bfd *)); -static char *mangle_name PARAMS ((bfd *, char *)); -static long binary_canonicalize_symtab PARAMS ((bfd *, asymbol **)); -static void binary_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *)); -static bfd_boolean binary_set_section_contents - PARAMS ((bfd *, asection *, const PTR, file_ptr, bfd_size_type)); -static int binary_sizeof_headers PARAMS ((bfd *, bfd_boolean)); - /* Set by external programs - specifies the BFD architecture and machine number to be uses when creating binary BFDs. */ enum bfd_architecture bfd_external_binary_architecture = bfd_arch_unknown; @@ -61,8 +49,7 @@ unsigned long bfd_external_machine = 0; /* Create a binary object. Invoked via bfd_set_format. */ static bfd_boolean -binary_mkobject (abfd) - bfd *abfd ATTRIBUTE_UNUSED; +binary_mkobject (bfd *abfd ATTRIBUTE_UNUSED) { return TRUE; } @@ -72,8 +59,7 @@ binary_mkobject (abfd) being binary. */ static const bfd_target * -binary_object_p (abfd) - bfd *abfd; +binary_object_p (bfd *abfd) { struct stat statbuf; asection *sec; @@ -102,7 +88,7 @@ binary_object_p (abfd) sec->size = statbuf.st_size; sec->filepos = 0; - abfd->tdata.any = (PTR) sec; + abfd->tdata.any = (void *) sec; if (bfd_get_arch_info (abfd) != NULL) { @@ -115,19 +101,18 @@ binary_object_p (abfd) return abfd->xvec; } -#define binary_close_and_cleanup _bfd_generic_close_and_cleanup -#define binary_bfd_free_cached_info _bfd_generic_bfd_free_cached_info -#define binary_new_section_hook _bfd_generic_new_section_hook +#define binary_close_and_cleanup _bfd_generic_close_and_cleanup +#define binary_bfd_free_cached_info _bfd_generic_bfd_free_cached_info +#define binary_new_section_hook _bfd_generic_new_section_hook /* Get contents of the only section. */ static bfd_boolean -binary_get_section_contents (abfd, section, location, offset, count) - bfd *abfd; - asection *section ATTRIBUTE_UNUSED; - PTR location; - file_ptr offset; - bfd_size_type count; +binary_get_section_contents (bfd *abfd, + asection *section ATTRIBUTE_UNUSED, + void * location, + file_ptr offset, + bfd_size_type count) { if (bfd_seek (abfd, offset, SEEK_SET) != 0 || bfd_bread (location, count, abfd) != count) @@ -138,8 +123,7 @@ binary_get_section_contents (abfd, section, location, offset, count) /* Return the amount of memory needed to read the symbol table. */ static long -binary_get_symtab_upper_bound (abfd) - bfd *abfd ATTRIBUTE_UNUSED; +binary_get_symtab_upper_bound (bfd *abfd ATTRIBUTE_UNUSED) { return (BIN_SYMS + 1) * sizeof (asymbol *); } @@ -147,9 +131,7 @@ binary_get_symtab_upper_bound (abfd) /* Create a symbol name based on the bfd's filename. */ static char * -mangle_name (abfd, suffix) - bfd *abfd; - char *suffix; +mangle_name (bfd *abfd, char *suffix) { bfd_size_type size; char *buf; @@ -159,7 +141,7 @@ mangle_name (abfd, suffix) + strlen (suffix) + sizeof "_binary__"); - buf = (char *) bfd_alloc (abfd, size); + buf = bfd_alloc (abfd, size); if (buf == NULL) return ""; @@ -176,16 +158,14 @@ mangle_name (abfd, suffix) /* Return the symbol table. */ static long -binary_canonicalize_symtab (abfd, alocation) - bfd *abfd; - asymbol **alocation; +binary_canonicalize_symtab (bfd *abfd, asymbol **alocation) { asection *sec = (asection *) abfd->tdata.any; asymbol *syms; unsigned int i; bfd_size_type amt = BIN_SYMS * sizeof (asymbol); - syms = (asymbol *) bfd_alloc (abfd, amt); + syms = bfd_alloc (abfd, amt); if (syms == NULL) return 0; @@ -220,33 +200,29 @@ binary_canonicalize_symtab (abfd, alocation) return BIN_SYMS; } -#define binary_make_empty_symbol _bfd_generic_make_empty_symbol -#define binary_print_symbol _bfd_nosymbols_print_symbol +#define binary_make_empty_symbol _bfd_generic_make_empty_symbol +#define binary_print_symbol _bfd_nosymbols_print_symbol /* Get information about a symbol. */ static void -binary_get_symbol_info (ignore_abfd, symbol, ret) - bfd *ignore_abfd ATTRIBUTE_UNUSED; - asymbol *symbol; - symbol_info *ret; +binary_get_symbol_info (bfd *ignore_abfd ATTRIBUTE_UNUSED, + asymbol *symbol, + symbol_info *ret) { bfd_symbol_info (symbol, ret); } +#define binary_bfd_is_local_label_name bfd_generic_is_local_label_name +#define binary_get_lineno _bfd_nosymbols_get_lineno +#define binary_find_nearest_line _bfd_nosymbols_find_nearest_line +#define binary_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol +#define binary_read_minisymbols _bfd_generic_read_minisymbols +#define binary_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol +#define binary_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup +#define binary_get_reloc_upper_bound ((long (*) (bfd *, asection *)) bfd_0l) +#define binary_canonicalize_reloc ((long (*) (bfd *, asection *, arelent **, asymbol **)) bfd_0l) #define binary_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false) -#define binary_bfd_is_local_label_name bfd_generic_is_local_label_name -#define binary_get_lineno _bfd_nosymbols_get_lineno -#define binary_find_nearest_line _bfd_nosymbols_find_nearest_line -#define binary_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol -#define binary_read_minisymbols _bfd_generic_read_minisymbols -#define binary_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol - -#define binary_get_reloc_upper_bound \ - ((long (*) PARAMS ((bfd *, asection *))) bfd_0l) -#define binary_canonicalize_reloc \ - ((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l) -#define binary_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup /* Set the architecture of a binary file. */ #define binary_set_arch_mach _bfd_generic_set_arch_mach @@ -254,12 +230,11 @@ binary_get_symbol_info (ignore_abfd, symbol, ret) /* Write section contents of a binary file. */ static bfd_boolean -binary_set_section_contents (abfd, sec, data, offset, size) - bfd *abfd; - asection *sec; - const PTR data; - file_ptr offset; - bfd_size_type size; +binary_set_section_contents (bfd *abfd, + asection *sec, + const void * data, + file_ptr offset, + bfd_size_type size) { if (size == 0) return TRUE; @@ -328,30 +303,26 @@ binary_set_section_contents (abfd, sec, data, offset, size) /* No space is required for header information. */ static int -binary_sizeof_headers (abfd, exec) - bfd *abfd ATTRIBUTE_UNUSED; - bfd_boolean exec ATTRIBUTE_UNUSED; +binary_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, + bfd_boolean exec ATTRIBUTE_UNUSED) { return 0; } -#define binary_bfd_get_relocated_section_contents \ - bfd_generic_get_relocated_section_contents -#define binary_bfd_relax_section bfd_generic_relax_section -#define binary_bfd_gc_sections bfd_generic_gc_sections -#define binary_bfd_merge_sections bfd_generic_merge_sections -#define binary_bfd_is_group_section bfd_generic_is_group_section -#define binary_bfd_discard_group bfd_generic_discard_group -#define binary_section_already_linked \ - _bfd_generic_section_already_linked -#define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create -#define binary_bfd_link_hash_table_free _bfd_generic_link_hash_table_free -#define binary_bfd_link_just_syms _bfd_generic_link_just_syms -#define binary_bfd_link_add_symbols _bfd_generic_link_add_symbols -#define binary_bfd_final_link _bfd_generic_final_link -#define binary_bfd_link_split_section _bfd_generic_link_split_section -#define binary_get_section_contents_in_window \ - _bfd_generic_get_section_contents_in_window +#define binary_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents +#define binary_bfd_relax_section bfd_generic_relax_section +#define binary_bfd_gc_sections bfd_generic_gc_sections +#define binary_bfd_merge_sections bfd_generic_merge_sections +#define binary_bfd_is_group_section bfd_generic_is_group_section +#define binary_bfd_discard_group bfd_generic_discard_group +#define binary_section_already_linked _bfd_generic_section_already_linked +#define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create +#define binary_bfd_link_hash_table_free _bfd_generic_link_hash_table_free +#define binary_bfd_link_just_syms _bfd_generic_link_just_syms +#define binary_bfd_link_add_symbols _bfd_generic_link_add_symbols +#define binary_bfd_final_link _bfd_generic_final_link +#define binary_bfd_link_split_section _bfd_generic_link_split_section +#define binary_get_section_contents_in_window _bfd_generic_get_section_contents_in_window const bfd_target binary_vec = { @@ -373,7 +344,7 @@ const bfd_target binary_vec = bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ { /* bfd_check_format */ _bfd_dummy_target, - binary_object_p, /* bfd_check_format */ + binary_object_p, _bfd_dummy_target, _bfd_dummy_target, }, diff --git a/bfd/coff-arm.c b/bfd/coff-arm.c index 460292f..77a30c1 100644 --- a/bfd/coff-arm.c +++ b/bfd/coff-arm.c @@ -23,9 +23,7 @@ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" - #include "coff/arm.h" - #include "coff/internal.h" #ifdef COFF_WITH_PE @@ -75,75 +73,10 @@ #endif typedef enum {bunknown, b9, b12, b23} thumb_pcrel_branchtype; -/* some typedefs for holding instructions */ +/* Some typedefs for holding instructions. */ typedef unsigned long int insn32; typedef unsigned short int insn16; - /* Forward declarations for stupid compilers. */ -static bfd_boolean coff_arm_relocate_section - PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, - struct internal_reloc *, struct internal_syment *, asection **)); -static bfd_reloc_status_type aoutarm_fix_pcrel_26_done - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); -static bfd_reloc_status_type aoutarm_fix_pcrel_26 - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); -#ifndef ARM_WINCE -static bfd_reloc_status_type coff_thumb_pcrel_23 - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); -static bfd_reloc_status_type coff_thumb_pcrel_9 - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); -static insn32 insert_thumb_branch - PARAMS ((insn32, int)); -#endif -static bfd_reloc_status_type coff_thumb_pcrel_12 - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); -static bfd_reloc_status_type coff_arm_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); -static bfd_boolean coff_arm_adjust_symndx - PARAMS ((bfd *, struct bfd_link_info *, bfd *, - asection *, struct internal_reloc *, bfd_boolean *)); -static reloc_howto_type * coff_arm_rtype_to_howto - PARAMS ((bfd *, asection *, struct internal_reloc *, - struct coff_link_hash_entry *, struct internal_syment *, - bfd_vma *)); -static bfd_reloc_status_type coff_thumb_pcrel_common - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **, - thumb_pcrel_branchtype)); -static const struct reloc_howto_struct * coff_arm_reloc_type_lookup - PARAMS ((bfd *, bfd_reloc_code_real_type)); -static struct bfd_link_hash_table * coff_arm_link_hash_table_create - PARAMS ((bfd *)); -#ifndef ARM_WINCE -static struct coff_link_hash_entry * find_thumb_glue - PARAMS ((struct bfd_link_info *, const char *, bfd *)); -#endif -static struct coff_link_hash_entry * find_arm_glue - PARAMS ((struct bfd_link_info *, const char *, bfd *)); -#ifndef COFF_IMAGE_WITH_PE -static void record_arm_to_thumb_glue - PARAMS ((struct bfd_link_info *, struct coff_link_hash_entry *)); -#ifndef ARM_WINCE -static void record_thumb_to_arm_glue - PARAMS ((struct bfd_link_info *, struct coff_link_hash_entry *)); -#endif -#endif -static bfd_boolean coff_arm_merge_private_bfd_data - PARAMS ((bfd *, bfd *)); -static bfd_boolean coff_arm_print_private_bfd_data - PARAMS ((bfd *, PTR)); -static bfd_boolean _bfd_coff_arm_set_private_flags - PARAMS ((bfd *, flagword)); -static bfd_boolean coff_arm_copy_private_bfd_data - PARAMS ((bfd *, bfd *)); -static bfd_boolean coff_arm_is_local_label_name - PARAMS ((bfd *, const char *)); -static bfd_boolean coff_arm_link_output_has_begun - PARAMS ((bfd *, struct coff_final_link_info *)); -static bfd_boolean coff_arm_final_link_postscript - PARAMS ((bfd *, struct coff_final_link_info *)); -static void arm_emit_base_file_entry - PARAMS ((struct bfd_link_info *, bfd *, asection *, bfd_vma)); - /* The linker script knows the section names for placement. The entry_names are used to do simple name mangling on the stubs. Given a function name, and its type, the stub can be found. The @@ -158,18 +91,17 @@ static void arm_emit_base_file_entry /* Used by the assembler. */ static bfd_reloc_status_type -coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, - error_message) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol ATTRIBUTE_UNUSED; - PTR data; - asection *input_section ATTRIBUTE_UNUSED; - bfd *output_bfd; - char **error_message ATTRIBUTE_UNUSED; +coff_arm_reloc (bfd *abfd, + arelent *reloc_entry, + asymbol *symbol ATTRIBUTE_UNUSED, + void * data, + asection *input_section ATTRIBUTE_UNUSED, + bfd *output_bfd, + char **error_message ATTRIBUTE_UNUSED) { symvalue diff; - if (output_bfd == (bfd *) NULL) + + if (output_bfd == NULL) return bfd_reloc_continue; diff = reloc_entry->addend; @@ -239,7 +171,7 @@ coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, #define ARM_DISP16 5 #define ARM_DISP32 6 #define ARM_26D 7 -/* 8 is unused */ +/* 8 is unused. */ #define ARM_NEG16 9 #define ARM_NEG32 10 #define ARM_RVA32 11 @@ -263,6 +195,19 @@ coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, #define ARM_SECREL 15 #endif +static bfd_reloc_status_type aoutarm_fix_pcrel_26_done + (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); +static bfd_reloc_status_type aoutarm_fix_pcrel_26 + (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); +static bfd_reloc_status_type coff_thumb_pcrel_9 + (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); +static bfd_reloc_status_type coff_thumb_pcrel_12 + (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); +#ifndef ARM_WINCE +static bfd_reloc_status_type coff_thumb_pcrel_23 + (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); +#endif + static reloc_howto_type aoutarm_std_reloc_howto[] = { #ifdef ARM_WINCE @@ -367,19 +312,19 @@ static reloc_howto_type aoutarm_std_reloc_howto[] = 0xffffffff, PCRELOFFSET), #else /* not ARM_WINCE */ - HOWTO (ARM_8, /* type */ - 0, /* rightshift */ - 0, /* size */ - 8, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_bitfield, /* complain_on_overflow */ - coff_arm_reloc, /* special_function */ - "ARM_8", /* name */ - TRUE, /* partial_inplace */ - 0x000000ff, /* src_mask */ - 0x000000ff, /* dst_mask */ - PCRELOFFSET /* pcrel_offset */), + HOWTO (ARM_8, + 0, + 0, + 8, + FALSE, + 0, + complain_overflow_bitfield, + coff_arm_reloc, + "ARM_8", + TRUE, + 0x000000ff, + 0x000000ff, + PCRELOFFSET), HOWTO (ARM_16, 0, 1, @@ -557,14 +502,12 @@ static reloc_howto_type aoutarm_std_reloc_howto[] = #define NUM_RELOCS NUM_ELEM (aoutarm_std_reloc_howto) #ifdef COFF_WITH_PE -static bfd_boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *)); /* Return TRUE if this relocation should appear in the output .reloc section. */ static bfd_boolean -in_reloc_p (abfd, howto) - bfd * abfd ATTRIBUTE_UNUSED; - reloc_howto_type * howto; +in_reloc_p (bfd * abfd ATTRIBUTE_UNUSED, + reloc_howto_type * howto) { return !howto->pc_relative && howto->type != ARM_RVA32; } @@ -579,13 +522,12 @@ in_reloc_p (abfd, howto) #define coff_rtype_to_howto coff_arm_rtype_to_howto static reloc_howto_type * -coff_arm_rtype_to_howto (abfd, sec, rel, h, sym, addendp) - bfd *abfd ATTRIBUTE_UNUSED; - asection *sec; - struct internal_reloc *rel; - struct coff_link_hash_entry *h ATTRIBUTE_UNUSED; - struct internal_syment *sym ATTRIBUTE_UNUSED; - bfd_vma *addendp; +coff_arm_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED, + asection *sec, + struct internal_reloc *rel, + struct coff_link_hash_entry *h ATTRIBUTE_UNUSED, + struct internal_syment *sym ATTRIBUTE_UNUSED, + bfd_vma *addendp) { reloc_howto_type * howto; @@ -603,15 +545,13 @@ coff_arm_rtype_to_howto (abfd, sec, rel, h, sym, addendp) /* Used by the assembler. */ static bfd_reloc_status_type -aoutarm_fix_pcrel_26_done (abfd, reloc_entry, symbol, data, input_section, - output_bfd, error_message) - bfd *abfd ATTRIBUTE_UNUSED; - arelent *reloc_entry ATTRIBUTE_UNUSED; - asymbol *symbol ATTRIBUTE_UNUSED; - PTR data ATTRIBUTE_UNUSED; - asection *input_section ATTRIBUTE_UNUSED; - bfd *output_bfd ATTRIBUTE_UNUSED; - char **error_message ATTRIBUTE_UNUSED; +aoutarm_fix_pcrel_26_done (bfd *abfd ATTRIBUTE_UNUSED, + arelent *reloc_entry ATTRIBUTE_UNUSED, + asymbol *symbol ATTRIBUTE_UNUSED, + void * data ATTRIBUTE_UNUSED, + asection *input_section ATTRIBUTE_UNUSED, + bfd *output_bfd ATTRIBUTE_UNUSED, + char **error_message ATTRIBUTE_UNUSED) { /* This is dead simple at present. */ return bfd_reloc_ok; @@ -620,15 +560,13 @@ aoutarm_fix_pcrel_26_done (abfd, reloc_entry, symbol, data, input_section, /* Used by the assembler. */ static bfd_reloc_status_type -aoutarm_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section, - output_bfd, error_message) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol; - PTR data; - asection *input_section; - bfd *output_bfd; - char **error_message ATTRIBUTE_UNUSED; +aoutarm_fix_pcrel_26 (bfd *abfd, + arelent *reloc_entry, + asymbol *symbol, + void * data, + asection *input_section, + bfd *output_bfd, + char **error_message ATTRIBUTE_UNUSED) { bfd_vma relocation; bfd_size_type addr = reloc_entry->address; @@ -680,16 +618,14 @@ aoutarm_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section, } static bfd_reloc_status_type -coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, input_section, - output_bfd, error_message, btype) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol; - PTR data; - asection *input_section; - bfd *output_bfd; - char **error_message ATTRIBUTE_UNUSED; - thumb_pcrel_branchtype btype; +coff_thumb_pcrel_common (bfd *abfd, + arelent *reloc_entry, + asymbol *symbol, + void * data, + asection *input_section, + bfd *output_bfd, + char **error_message ATTRIBUTE_UNUSED, + thumb_pcrel_branchtype btype) { bfd_vma relocation = 0; bfd_size_type addr = reloc_entry->address; @@ -701,7 +637,6 @@ coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, input_section, /* NOTE: This routine is currently used by GAS, but not by the link phase. */ - switch (btype) { case b9: @@ -809,15 +744,13 @@ coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, input_section, #ifndef ARM_WINCE static bfd_reloc_status_type -coff_thumb_pcrel_23 (abfd, reloc_entry, symbol, data, input_section, - output_bfd, error_message) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol; - PTR data; - asection *input_section; - bfd *output_bfd; - char **error_message; +coff_thumb_pcrel_23 (bfd *abfd, + arelent *reloc_entry, + asymbol *symbol, + void * data, + asection *input_section, + bfd *output_bfd, + char **error_message) { return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message, @@ -825,15 +758,13 @@ coff_thumb_pcrel_23 (abfd, reloc_entry, symbol, data, input_section, } static bfd_reloc_status_type -coff_thumb_pcrel_9 (abfd, reloc_entry, symbol, data, input_section, - output_bfd, error_message) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol; - PTR data; - asection *input_section; - bfd *output_bfd; - char **error_message; +coff_thumb_pcrel_9 (bfd *abfd, + arelent *reloc_entry, + asymbol *symbol, + void * data, + asection *input_section, + bfd *output_bfd, + char **error_message) { return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message, @@ -842,15 +773,13 @@ coff_thumb_pcrel_9 (abfd, reloc_entry, symbol, data, input_section, #endif /* not ARM_WINCE */ static bfd_reloc_status_type -coff_thumb_pcrel_12 (abfd, reloc_entry, symbol, data, input_section, - output_bfd, error_message) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol; - PTR data; - asection *input_section; - bfd *output_bfd; - char **error_message; +coff_thumb_pcrel_12 (bfd *abfd, + arelent *reloc_entry, + asymbol *symbol, + void * data, + asection *input_section, + bfd *output_bfd, + char **error_message) { return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message, @@ -858,9 +787,7 @@ coff_thumb_pcrel_12 (abfd, reloc_entry, symbol, data, input_section, } static const struct reloc_howto_struct * -coff_arm_reloc_type_lookup (abfd, code) - bfd * abfd; - bfd_reloc_code_real_type code; +coff_arm_reloc_type_lookup (bfd * abfd, bfd_reloc_code_real_type code) { #define ASTD(i,j) case i: return aoutarm_std_reloc_howto + j @@ -871,7 +798,7 @@ coff_arm_reloc_type_lookup (abfd, code) code = BFD_RELOC_32; break; default: - return (const struct reloc_howto_struct *) 0; + return NULL; } switch (code) @@ -896,17 +823,17 @@ coff_arm_reloc_type_lookup (abfd, code) ASTD (BFD_RELOC_THUMB_PCREL_BRANCH23, ARM_THUMB23); ASTD (BFD_RELOC_THUMB_PCREL_BLX, ARM_THUMB23); #endif - default: return (const struct reloc_howto_struct *) 0; + default: return NULL; } } -#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2) -#define COFF_PAGE_SIZE 0x1000 -/* Turn a howto into a reloc nunmber */ +#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER 2 +#define COFF_PAGE_SIZE 0x1000 +/* Turn a howto into a reloc nunmber. */ #define SELECT_RELOC(x,howto) { x.r_type = howto->type; } -#define BADMAG(x) ARMBADMAG(x) -#define ARM 1 /* Customize coffcode.h */ +#define BADMAG(x) ARMBADMAG(x) +#define ARM 1 /* Customize coffcode.h. */ #ifndef ARM_WINCE /* Make sure that the 'r_offset' field is copied properly @@ -943,21 +870,20 @@ struct coff_arm_link_hash_table /* Create an ARM coff linker hash table. */ static struct bfd_link_hash_table * -coff_arm_link_hash_table_create (abfd) - bfd * abfd; +coff_arm_link_hash_table_create (bfd * abfd) { struct coff_arm_link_hash_table * ret; bfd_size_type amt = sizeof (struct coff_arm_link_hash_table); - ret = (struct coff_arm_link_hash_table *) bfd_malloc (amt); - if (ret == (struct coff_arm_link_hash_table *) NULL) + ret = bfd_malloc (amt); + if (ret == NULL) return NULL; if (! _bfd_coff_link_hash_table_init (& ret->root, abfd, _bfd_coff_link_hash_newfunc)) { free (ret); - return (struct bfd_link_hash_table *) NULL; + return NULL; } ret->thumb_glue_size = 0; @@ -968,11 +894,10 @@ coff_arm_link_hash_table_create (abfd) } static void -arm_emit_base_file_entry (info, output_bfd, input_section, reloc_offset) - struct bfd_link_info *info; - bfd *output_bfd; - asection *input_section; - bfd_vma reloc_offset; +arm_emit_base_file_entry (struct bfd_link_info *info, + bfd *output_bfd, + asection *input_section, + bfd_vma reloc_offset) { bfd_vma addr = reloc_offset - input_section->vma @@ -1018,18 +943,16 @@ arm_emit_base_file_entry (info, output_bfd, input_section, reloc_offset) #define HI_LOW_ORDER 0xF000F800 static insn32 -insert_thumb_branch (br_insn, rel_off) - insn32 br_insn; - int rel_off; +insert_thumb_branch (insn32 br_insn, int rel_off) { unsigned int low_bits; unsigned int high_bits; - BFD_ASSERT((rel_off & 1) != 1); + BFD_ASSERT ((rel_off & 1) != 1); - rel_off >>= 1; /* half word aligned address */ - low_bits = rel_off & 0x000007FF; /* the bottom 11 bits */ - high_bits = (rel_off >> 11) & 0x000007FF; /* the top 11 bits */ + rel_off >>= 1; /* Half word aligned address. */ + low_bits = rel_off & 0x000007FF; /* The bottom 11 bits. */ + high_bits = (rel_off >> 11) & 0x000007FF; /* The top 11 bits. */ if ((br_insn & LOW_HI_ORDER) == LOW_HI_ORDER) br_insn = LOW_HI_ORDER | (low_bits << 16) | high_bits; @@ -1045,16 +968,15 @@ insert_thumb_branch (br_insn, rel_off) static struct coff_link_hash_entry * -find_thumb_glue (info, name, input_bfd) - struct bfd_link_info *info; - const char *name; - bfd *input_bfd; +find_thumb_glue (struct bfd_link_info *info, + const char *name, + bfd *input_bfd) { char *tmp_name; struct coff_link_hash_entry *myh; bfd_size_type amt = strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1; - tmp_name = (char *) bfd_malloc (amt); + tmp_name = bfd_malloc (amt); BFD_ASSERT (tmp_name); @@ -1075,16 +997,15 @@ find_thumb_glue (info, name, input_bfd) #endif /* not ARM_WINCE */ static struct coff_link_hash_entry * -find_arm_glue (info, name, input_bfd) - struct bfd_link_info *info; - const char *name; - bfd *input_bfd; +find_arm_glue (struct bfd_link_info *info, + const char *name, + bfd *input_bfd) { char *tmp_name; struct coff_link_hash_entry * myh; bfd_size_type amt = strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1; - tmp_name = (char *) bfd_malloc (amt); + tmp_name = bfd_malloc (amt); BFD_ASSERT (tmp_name); @@ -1193,16 +1114,14 @@ static const insn32 t2a6_bx_insn = 0xe12fff1e; is different from the original. */ static bfd_boolean -coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, - contents, relocs, syms, sections) - bfd *output_bfd; - struct bfd_link_info *info; - bfd *input_bfd; - asection *input_section; - bfd_byte *contents; - struct internal_reloc *relocs; - struct internal_syment *syms; - asection **sections; +coff_arm_relocate_section (bfd *output_bfd, + struct bfd_link_info *info, + bfd *input_bfd, + asection *input_section, + bfd_byte *contents, + struct internal_reloc *relocs, + struct internal_syment *syms, + asection **sections) { struct internal_reloc * rel; struct internal_reloc * relend; @@ -1285,7 +1204,7 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, addend -= rel->r_vaddr - input_section->vma; #ifdef ARM_WINCE /* FIXME: I don't know why, but the hack is necessary for correct - generation of bl's instruction offset. */ + generation of bl's instruction offset. */ addend -= 8; #endif howto = &fake_arm26_reloc; @@ -1453,7 +1372,7 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, || h->class == C_STAT || h->class == C_LABEL) { - /* Thumb code calling an ARM function */ + /* Thumb code calling an ARM function. */ asection * s = 0; bfd_vma my_offset; unsigned long int tmp; @@ -1532,13 +1451,19 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, s->contents + my_offset + 2); ret_offset = - ((bfd_signed_vma) h_val) /* Address of destination of the stub. */ + /* Address of destination of the stub. */ + ((bfd_signed_vma) h_val) - ((bfd_signed_vma) - (s->output_offset /* Offset from the start of the current section to the start of the stubs. */ - + my_offset /* Offset of the start of this stub from the start of the stubs. */ - + s->output_section->vma) /* Address of the start of the current section. */ - + 4 /* The branch instruction is 4 bytes into the stub. */ - + 8); /* ARM branches work from the pc of the instruction + 8. */ + /* Offset from the start of the current section to the start of the stubs. */ + (s->output_offset + /* Offset of the start of this stub from the start of the stubs. */ + + my_offset + /* Address of the start of the current section. */ + + s->output_section->vma) + /* The branch instruction is 4 bytes into the stub. */ + + 4 + /* ARM branches work from the pc of the instruction + 8. */ + + 8); bfd_put_32 (output_bfd, (bfd_vma) t2a3_b_insn | ((ret_offset >> 2) & 0x00FFFFFF), @@ -1610,7 +1535,7 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, if (done) rstat = bfd_reloc_ok; #ifndef ARM_WINCE - /* Only perform this fix during the final link, not a relocatable link. nickc@cygnus.com */ + /* Only perform this fix during the final link, not a relocatable link. */ else if (! info->relocatable && howto->type == ARM_THUMB23) { @@ -1734,16 +1659,12 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, contents, rel->r_vaddr - input_section->vma, val, addend); - /* FIXME: - Is this the best way to fix up thumb addresses? krk@cygnus.com - Probably not, but it works, and if it works it don't need fixing! nickc@cygnus.com */ - /* Only perform this fix during the final link, not a relocatable link. nickc@cygnus.com */ + /* Only perform this fix during the final link, not a relocatable link. */ if (! info->relocatable && (rel->r_type == ARM_32 || rel->r_type == ARM_RVA32)) { /* Determine if we need to set the bottom bit of a relocated address because the address is the address of a Thumb code symbol. */ - int patchit = FALSE; if (h != NULL @@ -1756,7 +1677,6 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, && sym->n_scnum > N_UNDEF) { /* No hash entry - use the symbol instead. */ - if ( sym->n_sclass == C_THUMBSTATFUNC || sym->n_sclass == C_THUMBEXTFUNC) patchit = TRUE; @@ -1813,8 +1733,7 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, #ifndef COFF_IMAGE_WITH_PE bfd_boolean -bfd_arm_allocate_interworking_sections (info) - struct bfd_link_info * info; +bfd_arm_allocate_interworking_sections (struct bfd_link_info * info) { asection * s; bfd_byte * foo; @@ -1833,8 +1752,7 @@ bfd_arm_allocate_interworking_sections (info) BFD_ASSERT (s != NULL); - foo = (bfd_byte *) bfd_alloc (globals->bfd_of_glue_owner, - globals->arm_glue_size); + foo = bfd_alloc (globals->bfd_of_glue_owner, globals->arm_glue_size); s->size = globals->arm_glue_size; s->contents = foo; @@ -1849,8 +1767,7 @@ bfd_arm_allocate_interworking_sections (info) BFD_ASSERT (s != NULL); - foo = (bfd_byte *) bfd_alloc (globals->bfd_of_glue_owner, - globals->thumb_glue_size); + foo = bfd_alloc (globals->bfd_of_glue_owner, globals->thumb_glue_size); s->size = globals->thumb_glue_size; s->contents = foo; @@ -1860,9 +1777,8 @@ bfd_arm_allocate_interworking_sections (info) } static void -record_arm_to_thumb_glue (info, h) - struct bfd_link_info * info; - struct coff_link_hash_entry * h; +record_arm_to_thumb_glue (struct bfd_link_info * info, + struct coff_link_hash_entry * h) { const char * name = h->root.root.string; register asection * s; @@ -1884,7 +1800,7 @@ record_arm_to_thumb_glue (info, h) BFD_ASSERT (s != NULL); amt = strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1; - tmp_name = (char *) bfd_malloc (amt); + tmp_name = bfd_malloc (amt); BFD_ASSERT (tmp_name); @@ -1896,13 +1812,13 @@ record_arm_to_thumb_glue (info, h) if (myh != NULL) { free (tmp_name); - return; /* we've already seen this guy */ + /* We've already seen this guy. */ + return; } /* The only trick here is using globals->arm_glue_size as the value. Even though the section isn't allocated yet, this is where we will be putting it. */ - bh = NULL; val = globals->arm_glue_size + 1; bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name, @@ -1917,12 +1833,11 @@ record_arm_to_thumb_glue (info, h) #ifndef ARM_WINCE static void -record_thumb_to_arm_glue (info, h) - struct bfd_link_info * info; - struct coff_link_hash_entry * h; +record_thumb_to_arm_glue (struct bfd_link_info * info, + struct coff_link_hash_entry * h) { const char * name = h->root.root.string; - register asection * s; + asection * s; char * tmp_name; struct coff_link_hash_entry * myh; struct bfd_link_hash_entry * bh; @@ -1941,7 +1856,7 @@ record_thumb_to_arm_glue (info, h) BFD_ASSERT (s != NULL); amt = strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1; - tmp_name = (char *) bfd_malloc (amt); + tmp_name = bfd_malloc (amt); BFD_ASSERT (tmp_name); @@ -1953,7 +1868,8 @@ record_thumb_to_arm_glue (info, h) if (myh != NULL) { free (tmp_name); - return; /* we've already seen this guy */ + /* We've already seen this guy. */ + return; } bh = NULL; @@ -1973,7 +1889,7 @@ record_thumb_to_arm_glue (info, h) #define BACK_FROM_ARM "__%s_back_from_arm" amt = strlen (name) + strlen (CHANGE_TO_ARM) + 1; - tmp_name = (char *) bfd_malloc (amt); + tmp_name = bfd_malloc (amt); BFD_ASSERT (tmp_name); @@ -1997,9 +1913,8 @@ record_thumb_to_arm_glue (info, h) {armcoff/pe}.em */ bfd_boolean -bfd_arm_get_bfd_for_interworking (abfd, info) - bfd * abfd; - struct bfd_link_info * info; +bfd_arm_get_bfd_for_interworking (bfd * abfd, + struct bfd_link_info * info) { struct coff_arm_link_hash_table * globals; flagword flags; @@ -2052,10 +1967,9 @@ bfd_arm_get_bfd_for_interworking (abfd, info) } bfd_boolean -bfd_arm_process_before_allocation (abfd, info, support_old_code) - bfd * abfd; - struct bfd_link_info * info; - int support_old_code; +bfd_arm_process_before_allocation (bfd * abfd, + struct bfd_link_info * info, + int support_old_code) { asection * sec; struct coff_arm_link_hash_table * globals; @@ -2067,7 +1981,6 @@ bfd_arm_process_before_allocation (abfd, info, support_old_code) /* Here we have a bfd that is to be included on the link. We have a hook to do reloc rummaging, before section sizes are nailed down. */ - _bfd_coff_get_external_symbols (abfd); globals = coff_arm_hash_table (info); @@ -2093,7 +2006,6 @@ bfd_arm_process_before_allocation (abfd, info, support_old_code) /* Load the relocs. */ /* FIXME: there may be a storage leak here. */ - i = _bfd_coff_read_internal_relocs (abfd, sec, 1, 0, 0, 0); BFD_ASSERT (i != 0); @@ -2186,13 +2098,12 @@ bfd_arm_process_before_allocation (abfd, info, support_old_code) into ARM_26D relocs. */ static bfd_boolean -coff_arm_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp) - bfd *obfd ATTRIBUTE_UNUSED; - struct bfd_link_info *info ATTRIBUTE_UNUSED; - bfd *ibfd; - asection *sec; - struct internal_reloc *irel; - bfd_boolean *adjustedp; +coff_arm_adjust_symndx (bfd *obfd ATTRIBUTE_UNUSED, + struct bfd_link_info *info ATTRIBUTE_UNUSED, + bfd *ibfd, + asection *sec, + struct internal_reloc *irel, + bfd_boolean *adjustedp) { if (irel->r_type == ARM_26) { @@ -2215,9 +2126,7 @@ coff_arm_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp) targets, eg different CPUs or different APCS's. */ static bfd_boolean -coff_arm_merge_private_bfd_data (ibfd, obfd) - bfd * ibfd; - bfd * obfd; +coff_arm_merge_private_bfd_data (bfd * ibfd, bfd * obfd) { BFD_ASSERT (ibfd != NULL && obfd != NULL); @@ -2330,9 +2239,7 @@ coff_arm_merge_private_bfd_data (ibfd, obfd) /* Display the flags field. */ static bfd_boolean -coff_arm_print_private_bfd_data (abfd, ptr) - bfd * abfd; - PTR ptr; +coff_arm_print_private_bfd_data (bfd * abfd, void * ptr) { FILE * file = (FILE *) ptr; @@ -2377,9 +2284,7 @@ coff_arm_print_private_bfd_data (abfd, ptr) called from both coffcode.h and peicode.h. */ static bfd_boolean -_bfd_coff_arm_set_private_flags (abfd, flags) - bfd * abfd; - flagword flags; +_bfd_coff_arm_set_private_flags (bfd * abfd, flagword flags) { flagword flag; @@ -2428,9 +2333,7 @@ _bfd_coff_arm_set_private_flags (abfd, flags) from one instance of a BFD to another. */ static bfd_boolean -coff_arm_copy_private_bfd_data (src, dest) - bfd * src; - bfd * dest; +coff_arm_copy_private_bfd_data (bfd * src, bfd * dest) { BFD_ASSERT (src != NULL && dest != NULL); @@ -2442,7 +2345,7 @@ coff_arm_copy_private_bfd_data (src, dest) if (src->xvec != dest->xvec) return TRUE; - /* copy the flags field */ + /* Copy the flags field. */ if (APCS_SET (src)) { if (APCS_SET (dest)) @@ -2502,10 +2405,10 @@ Warning: Clearing the interworking flag of %B because non-interworking code in % non-local. b) Allow other prefixes than ".", e.g. an empty prefix would cause all labels of the form Lxxx to be stripped. */ + static bfd_boolean -coff_arm_is_local_label_name (abfd, name) - bfd * abfd ATTRIBUTE_UNUSED; - const char * name; +coff_arm_is_local_label_name (bfd * abfd ATTRIBUTE_UNUSED, + const char * name) { #ifdef USER_LABEL_PREFIX if (USER_LABEL_PREFIX[0] != 0) @@ -2540,23 +2443,18 @@ coff_arm_is_local_label_name (abfd, name) the glue section is written last. This does depend on bfd_make_section attaching a new section to the - end of the section list for the bfd. - - krk@cygnus.com */ + end of the section list for the bfd. */ static bfd_boolean -coff_arm_link_output_has_begun (sub, info) - bfd * sub; - struct coff_final_link_info * info; +coff_arm_link_output_has_begun (bfd * sub, struct coff_final_link_info * info) { return (sub->output_has_begun || sub == coff_arm_hash_table (info->info)->bfd_of_glue_owner); } static bfd_boolean -coff_arm_final_link_postscript (abfd, pfinfo) - bfd * abfd ATTRIBUTE_UNUSED; - struct coff_final_link_info * pfinfo; +coff_arm_final_link_postscript (bfd * abfd ATTRIBUTE_UNUSED, + struct coff_final_link_info * pfinfo) { struct coff_arm_link_hash_table * globals; diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 426721a..d303bec 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -4,21 +4,21 @@ Free Software Foundation, Inc. Written by Cygnus Support. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Most of this hacked by Steve Chamberlain, sac@cygnus.com. Split out of coffcode.h by Ian Taylor, ian@cygnus.com. */ @@ -43,42 +43,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "coff/internal.h" #include "libcoff.h" -static void coff_fix_symbol_name - PARAMS ((bfd *, asymbol *, combined_entry_type *, bfd_size_type *, - asection **, bfd_size_type *)); -static bfd_boolean coff_write_symbol - PARAMS ((bfd *, asymbol *, combined_entry_type *, bfd_vma *, - bfd_size_type *, asection **, bfd_size_type *)); -static bfd_boolean coff_write_alien_symbol - PARAMS ((bfd *, asymbol *, bfd_vma *, bfd_size_type *, - asection **, bfd_size_type *)); -static bfd_boolean coff_write_native_symbol - PARAMS ((bfd *, coff_symbol_type *, bfd_vma *, bfd_size_type *, - asection **, bfd_size_type *)); -static void coff_pointerize_aux - PARAMS ((bfd *, combined_entry_type *, combined_entry_type *, - unsigned int, combined_entry_type *)); -static bfd_boolean make_a_section_from_file - PARAMS ((bfd *, struct internal_scnhdr *, unsigned int)); -static const bfd_target *coff_real_object_p - PARAMS ((bfd *, unsigned, struct internal_filehdr *, - struct internal_aouthdr *)); -static void fixup_symbol_value - PARAMS ((bfd *, coff_symbol_type *, struct internal_syment *)); -static char *build_debug_section - PARAMS ((bfd *)); -static char *copy_name - PARAMS ((bfd *, char *, size_t)); - -#define STRING_SIZE_SIZE (4) - /* Take a section header read from a coff file (in HOST byte order), and make a BFD "section" out of it. This is used by ECOFF. */ + static bfd_boolean -make_a_section_from_file (abfd, hdr, target_index) - bfd *abfd; - struct internal_scnhdr *hdr; - unsigned int target_index; +make_a_section_from_file (bfd *abfd, + struct internal_scnhdr *hdr, + unsigned int target_index) { asection *return_section; char *name; @@ -142,7 +113,7 @@ make_a_section_from_file (abfd, hdr, target_index) return_section->lineno_count = hdr->s_nlnno; return_section->userdata = NULL; - return_section->next = (asection *) NULL; + return_section->next = NULL; return_section->target_index = target_index; if (! bfd_coff_styp_to_sec_flags_hook (abfd, hdr, name, return_section, @@ -158,7 +129,7 @@ make_a_section_from_file (abfd, hdr, target_index) if (hdr->s_nreloc != 0) return_section->flags |= SEC_RELOC; - /* FIXME: should this check 'hdr->s_size > 0' */ + /* FIXME: should this check 'hdr->s_size > 0'. */ if (hdr->s_scnptr != 0) return_section->flags |= SEC_HAS_CONTENTS; @@ -169,17 +140,16 @@ make_a_section_from_file (abfd, hdr, target_index) ECOFF as well. */ static const bfd_target * -coff_real_object_p (abfd, nscns, internal_f, internal_a) - bfd *abfd; - unsigned nscns; - struct internal_filehdr *internal_f; - struct internal_aouthdr *internal_a; +coff_real_object_p (bfd *abfd, + unsigned nscns, + struct internal_filehdr *internal_f, + struct internal_aouthdr *internal_a) { flagword oflags = abfd->flags; bfd_vma ostart = bfd_get_start_address (abfd); - PTR tdata; - PTR tdata_save; - bfd_size_type readsize; /* length of file_info */ + void * tdata; + void * tdata_save; + bfd_size_type readsize; /* Length of file_info. */ unsigned int scnhsz; char *external_sections; @@ -208,22 +178,22 @@ coff_real_object_p (abfd, nscns, internal_f, internal_a) /* Set up the tdata area. ECOFF uses its own routine, and overrides abfd->flags. */ tdata_save = abfd->tdata.any; - tdata = bfd_coff_mkobject_hook (abfd, (PTR) internal_f, (PTR) internal_a); + tdata = bfd_coff_mkobject_hook (abfd, (void *) internal_f, (void *) internal_a); if (tdata == NULL) goto fail2; scnhsz = bfd_coff_scnhsz (abfd); readsize = (bfd_size_type) nscns * scnhsz; - external_sections = (char *) bfd_alloc (abfd, readsize); + external_sections = bfd_alloc (abfd, readsize); if (!external_sections) goto fail; - if (bfd_bread ((PTR) external_sections, readsize, abfd) != readsize) + if (bfd_bread ((void *) external_sections, readsize, abfd) != readsize) goto fail; /* Set the arch/mach *before* swapping in sections; section header swapping may depend on arch/mach info. */ - if (! bfd_coff_set_arch_mach_hook (abfd, (PTR) internal_f)) + if (! bfd_coff_set_arch_mach_hook (abfd, (void *) internal_f)) goto fail; /* Now copy data as required; construct all asections etc. */ @@ -234,8 +204,8 @@ coff_real_object_p (abfd, nscns, internal_f, internal_a) { struct internal_scnhdr tmp; bfd_coff_swap_scnhdr_in (abfd, - (PTR) (external_sections + i * scnhsz), - (PTR) & tmp); + (void *) (external_sections + i * scnhsz), + (void *) & tmp); if (! make_a_section_from_file (abfd, &tmp, i + 1)) goto fail; } @@ -256,17 +226,16 @@ coff_real_object_p (abfd, nscns, internal_f, internal_a) not a COFF file. This is also used by ECOFF. */ const bfd_target * -coff_object_p (abfd) - bfd *abfd; +coff_object_p (bfd *abfd) { bfd_size_type filhsz; bfd_size_type aoutsz; unsigned int nscns; - PTR filehdr; + void * filehdr; struct internal_filehdr internal_f; struct internal_aouthdr internal_a; - /* figure out how much to read */ + /* Figure out how much to read. */ filhsz = bfd_coff_filhsz (abfd); aoutsz = bfd_coff_aoutsz (abfd); @@ -301,7 +270,7 @@ coff_object_p (abfd) if (internal_f.f_opthdr) { - PTR opthdr; + void * opthdr; opthdr = bfd_alloc (abfd, aoutsz); if (opthdr == NULL) @@ -312,7 +281,7 @@ coff_object_p (abfd) bfd_release (abfd, opthdr); return NULL; } - bfd_coff_swap_aouthdr_in (abfd, opthdr, (PTR) &internal_a); + bfd_coff_swap_aouthdr_in (abfd, opthdr, (void *) &internal_a); bfd_release (abfd, opthdr); } @@ -325,9 +294,7 @@ coff_object_p (abfd) /* Get the BFD section from a COFF symbol section number. */ asection * -coff_section_from_bfd_index (abfd, index) - bfd *abfd; - int index; +coff_section_from_bfd_index (bfd *abfd, int index) { struct bfd_section *answer = abfd->sections; @@ -353,8 +320,7 @@ coff_section_from_bfd_index (abfd, index) /* Get the upper bound of a COFF symbol table. */ long -coff_get_symtab_upper_bound (abfd) - bfd *abfd; +coff_get_symtab_upper_bound (bfd *abfd) { if (!bfd_coff_slurp_symbol_table (abfd)) return -1; @@ -365,9 +331,7 @@ coff_get_symtab_upper_bound (abfd) /* Canonicalize a COFF symbol table. */ long -coff_canonicalize_symtab (abfd, alocation) - bfd *abfd; - asymbol **alocation; +coff_canonicalize_symtab (bfd *abfd, asymbol **alocation) { unsigned int counter; coff_symbol_type *symbase; @@ -390,10 +354,9 @@ coff_canonicalize_symtab (abfd, alocation) >= SYMNMLEN + 1. */ const char * -_bfd_coff_internal_syment_name (abfd, sym, buf) - bfd *abfd; - const struct internal_syment *sym; - char *buf; +_bfd_coff_internal_syment_name (bfd *abfd, + const struct internal_syment *sym, + char *buf) { /* FIXME: It's not clear this will work correctly if sizeof (_n_zeroes) != 4. */ @@ -430,14 +393,12 @@ _bfd_coff_internal_syment_name (abfd, sym, buf) value must be INTERNAL_RELOCS. The function returns NULL on error. */ struct internal_reloc * -_bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs, - require_internal, internal_relocs) - bfd *abfd; - asection *sec; - bfd_boolean cache; - bfd_byte *external_relocs; - bfd_boolean require_internal; - struct internal_reloc *internal_relocs; +_bfd_coff_read_internal_relocs (bfd *abfd, + asection *sec, + bfd_boolean cache, + bfd_byte *external_relocs, + bfd_boolean require_internal, + struct internal_reloc *internal_relocs) { bfd_size_type relsz; bfd_byte *free_external = NULL; @@ -462,7 +423,7 @@ _bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs, amt = sec->reloc_count * relsz; if (external_relocs == NULL) { - free_external = (bfd_byte *) bfd_malloc (amt); + free_external = bfd_malloc (amt); if (free_external == NULL && sec->reloc_count > 0) goto error_return; external_relocs = free_external; @@ -476,7 +437,7 @@ _bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs, { amt = sec->reloc_count; amt *= sizeof (struct internal_reloc); - free_internal = (struct internal_reloc *) bfd_malloc (amt); + free_internal = bfd_malloc (amt); if (free_internal == NULL && sec->reloc_count > 0) goto error_return; internal_relocs = free_internal; @@ -487,7 +448,7 @@ _bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs, erel_end = erel + relsz * sec->reloc_count; irel = internal_relocs; for (; erel < erel_end; erel += relsz, irel++) - bfd_coff_swap_reloc_in (abfd, (PTR) erel, (PTR) irel); + bfd_coff_swap_reloc_in (abfd, (void *) erel, (void *) irel); if (free_external != NULL) { @@ -500,7 +461,7 @@ _bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs, if (coff_section_data (abfd, sec) == NULL) { amt = sizeof (struct coff_section_tdata); - sec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt); + sec->used_by_bfd = bfd_zalloc (abfd, amt); if (sec->used_by_bfd == NULL) goto error_return; coff_section_data (abfd, sec)->contents = NULL; @@ -521,8 +482,7 @@ _bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs, /* Set lineno_count for the output sections of a COFF file. */ int -coff_count_linenumbers (abfd) - bfd *abfd; +coff_count_linenumbers (bfd *abfd) { unsigned int limit = bfd_get_symcount (abfd); unsigned int i; @@ -583,9 +543,8 @@ coff_count_linenumbers (abfd) area of the symbol if there is one. */ coff_symbol_type * -coff_symbol_from (ignore_abfd, symbol) - bfd *ignore_abfd ATTRIBUTE_UNUSED; - asymbol *symbol; +coff_symbol_from (bfd *ignore_abfd ATTRIBUTE_UNUSED, + asymbol *symbol) { if (!bfd_family_coff (bfd_asymbol_bfd (symbol))) return (coff_symbol_type *) NULL; @@ -597,16 +556,14 @@ coff_symbol_from (ignore_abfd, symbol) } static void -fixup_symbol_value (abfd, coff_symbol_ptr, syment) - bfd *abfd; - coff_symbol_type *coff_symbol_ptr; - struct internal_syment *syment; +fixup_symbol_value (bfd *abfd, + coff_symbol_type *coff_symbol_ptr, + struct internal_syment *syment) { - - /* Normalize the symbol flags */ + /* Normalize the symbol flags. */ if (bfd_is_com_section (coff_symbol_ptr->symbol.section)) { - /* a common symbol is undefined with a value */ + /* A common symbol is undefined with a value. */ syment->n_scnum = N_UNDEF; syment->n_value = coff_symbol_ptr->symbol.value; } @@ -655,14 +612,12 @@ fixup_symbol_value (abfd, coff_symbol_ptr, syment) do that here too. */ bfd_boolean -coff_renumber_symbols (bfd_ptr, first_undef) - bfd *bfd_ptr; - int *first_undef; +coff_renumber_symbols (bfd *bfd_ptr, int *first_undef) { unsigned int symbol_count = bfd_get_symcount (bfd_ptr); asymbol **symbol_ptr_ptr = bfd_ptr->outsymbols; unsigned int native_index = 0; - struct internal_syment *last_file = (struct internal_syment *) NULL; + struct internal_syment *last_file = NULL; unsigned int symbol_index; /* COFF demands that undefined symbols come after all other symbols. @@ -681,7 +636,7 @@ coff_renumber_symbols (bfd_ptr, first_undef) bfd_size_type amt; amt = sizeof (asymbol *) * ((bfd_size_type) symbol_count + 1); - newsyms = (asymbol **) bfd_alloc (bfd_ptr, amt); + newsyms = bfd_alloc (bfd_ptr, amt); if (!newsyms) return FALSE; bfd_ptr->outsymbols = newsyms; @@ -724,26 +679,22 @@ coff_renumber_symbols (bfd_ptr, first_undef) if (s->u.syment.n_sclass == C_FILE) { - if (last_file != (struct internal_syment *) NULL) + if (last_file != NULL) last_file->n_value = native_index; last_file = &(s->u.syment); } else - { - - /* Modify the symbol values according to their section and - type */ + /* Modify the symbol values according to their section and + type. */ + fixup_symbol_value (bfd_ptr, coff_symbol_ptr, &(s->u.syment)); - fixup_symbol_value (bfd_ptr, coff_symbol_ptr, &(s->u.syment)); - } for (i = 0; i < s->u.syment.n_numaux + 1; i++) s[i].offset = native_index++; } else - { - native_index++; - } + native_index++; } + obj_conv_table_size (bfd_ptr) = native_index; return TRUE; @@ -754,8 +705,7 @@ coff_renumber_symbols (bfd_ptr, first_undef) symbol table. */ void -coff_mangle_symbols (bfd_ptr) - bfd *bfd_ptr; +coff_mangle_symbols (bfd *bfd_ptr) { unsigned int symbol_count = bfd_get_symcount (bfd_ptr); asymbol **symbol_ptr_ptr = bfd_ptr->outsymbols; @@ -818,22 +768,20 @@ coff_mangle_symbols (bfd_ptr) } static void -coff_fix_symbol_name (abfd, symbol, native, string_size_p, - debug_string_section_p, debug_string_size_p) - bfd *abfd; - asymbol *symbol; - combined_entry_type *native; - bfd_size_type *string_size_p; - asection **debug_string_section_p; - bfd_size_type *debug_string_size_p; +coff_fix_symbol_name (bfd *abfd, + asymbol *symbol, + combined_entry_type *native, + bfd_size_type *string_size_p, + asection **debug_string_section_p, + bfd_size_type *debug_string_size_p) { unsigned int name_length; union internal_auxent *auxent; char *name = (char *) (symbol->name); - if (name == (char *) NULL) + if (name == NULL) { - /* coff symbols always have names, so we'll make one up */ + /* COFF symbols always have names, so we'll make one up. */ symbol->name = "strange"; name = (char *) symbol->name; } @@ -861,9 +809,7 @@ coff_fix_symbol_name (abfd, symbol, native, string_size_p, if (bfd_coff_long_filenames (abfd)) { if (name_length <= filnmlen) - { - strncpy (auxent->x_file.x_fname, name, filnmlen); - } + strncpy (auxent->x_file.x_fname, name, filnmlen); else { auxent->x_file.x_n.x_offset = *string_size_p + STRING_SIZE_SIZE; @@ -881,10 +827,9 @@ coff_fix_symbol_name (abfd, symbol, native, string_size_p, else { if (name_length <= SYMNMLEN && !bfd_coff_force_symnames_in_strings (abfd)) - { - /* This name will fit into the symbol neatly */ - strncpy (native->u.syment._n._n_name, symbol->name, SYMNMLEN); - } + /* This name will fit into the symbol neatly. */ + strncpy (native->u.syment._n._n_name, symbol->name, SYMNMLEN); + else if (!bfd_coff_symname_in_debug (abfd, &native->u.syment)) { native->u.syment._n._n_n._n_offset = (*string_size_p @@ -913,12 +858,12 @@ coff_fix_symbol_name (abfd, symbol, native, string_size_p, if (!bfd_set_section_contents (abfd, *debug_string_section_p, - (PTR) buf, + (void *) buf, (file_ptr) *debug_string_size_p, (bfd_size_type) prefix_len) || !bfd_set_section_contents (abfd, *debug_string_section_p, - (PTR) symbol->name, + (void *) symbol->name, (file_ptr) (*debug_string_size_p + prefix_len), (bfd_size_type) name_length + 1)) @@ -942,20 +887,18 @@ coff_fix_symbol_name (abfd, symbol, native, string_size_p, /* Write a symbol out to a COFF file. */ static bfd_boolean -coff_write_symbol (abfd, symbol, native, written, string_size_p, - debug_string_section_p, debug_string_size_p) - bfd *abfd; - asymbol *symbol; - combined_entry_type *native; - bfd_vma *written; - bfd_size_type *string_size_p; - asection **debug_string_section_p; - bfd_size_type *debug_string_size_p; +coff_write_symbol (bfd *abfd, + asymbol *symbol, + combined_entry_type *native, + bfd_vma *written, + bfd_size_type *string_size_p, + asection **debug_string_section_p, + bfd_size_type *debug_string_size_p) { unsigned int numaux = native->u.syment.n_numaux; int type = native->u.syment.n_type; int class = native->u.syment.n_sclass; - PTR buf; + void * buf; bfd_size_type symesz; if (native->u.syment.n_sclass == C_FILE) @@ -963,22 +906,17 @@ coff_write_symbol (abfd, symbol, native, written, string_size_p, if (symbol->flags & BSF_DEBUGGING && bfd_is_abs_section (symbol->section)) - { - native->u.syment.n_scnum = N_DEBUG; - } + native->u.syment.n_scnum = N_DEBUG; + else if (bfd_is_abs_section (symbol->section)) - { - native->u.syment.n_scnum = N_ABS; - } + native->u.syment.n_scnum = N_ABS; + else if (bfd_is_und_section (symbol->section)) - { - native->u.syment.n_scnum = N_UNDEF; - } + native->u.syment.n_scnum = N_UNDEF; + else - { - native->u.syment.n_scnum = - symbol->section->output_section->target_index; - } + native->u.syment.n_scnum = + symbol->section->output_section->target_index; coff_fix_symbol_name (abfd, symbol, native, string_size_p, debug_string_section_p, debug_string_size_p); @@ -1005,9 +943,7 @@ coff_write_symbol (abfd, symbol, native, written, string_size_p, { bfd_coff_swap_aux_out (abfd, &((native + j + 1)->u.auxent), - type, - class, - (int) j, + type, class, (int) j, native->u.syment.n_numaux, buf); if (bfd_bwrite (buf, auxesz, abfd) != auxesz) @@ -1028,14 +964,12 @@ coff_write_symbol (abfd, symbol, native, written, string_size_p, or we may be linking a non COFF file to a COFF file. */ static bfd_boolean -coff_write_alien_symbol (abfd, symbol, written, string_size_p, - debug_string_section_p, debug_string_size_p) - bfd *abfd; - asymbol *symbol; - bfd_vma *written; - bfd_size_type *string_size_p; - asection **debug_string_section_p; - bfd_size_type *debug_string_size_p; +coff_write_alien_symbol (bfd *abfd, + asymbol *symbol, + bfd_vma *written, + bfd_size_type *string_size_p, + asection **debug_string_section_p, + bfd_size_type *debug_string_size_p) { combined_entry_type *native; combined_entry_type dummy; @@ -1096,14 +1030,12 @@ coff_write_alien_symbol (abfd, symbol, written, string_size_p, /* Write a native symbol to a COFF file. */ static bfd_boolean -coff_write_native_symbol (abfd, symbol, written, string_size_p, - debug_string_section_p, debug_string_size_p) - bfd *abfd; - coff_symbol_type *symbol; - bfd_vma *written; - bfd_size_type *string_size_p; - asection **debug_string_section_p; - bfd_size_type *debug_string_size_p; +coff_write_native_symbol (bfd *abfd, + coff_symbol_type *symbol, + bfd_vma *written, + bfd_size_type *string_size_p, + asection **debug_string_section_p, + bfd_size_type *debug_string_size_p) { combined_entry_type *native = symbol->native; alent *lineno = symbol->lineno; @@ -1114,6 +1046,7 @@ coff_write_native_symbol (abfd, symbol, written, string_size_p, if (lineno && !symbol->done_lineno && symbol->symbol.section->owner != NULL) { unsigned int count = 0; + lineno[count].u.offset = *written; if (native->u.syment.n_numaux) { @@ -1147,8 +1080,7 @@ coff_write_native_symbol (abfd, symbol, written, string_size_p, /* Write out the COFF symbols. */ bfd_boolean -coff_write_symbols (abfd) - bfd *abfd; +coff_write_symbols (bfd *abfd) { bfd_size_type string_size; asection *debug_string_section; @@ -1180,12 +1112,11 @@ coff_write_symbols (abfd) } } - /* Seek to the right place */ + /* Seek to the right place. */ if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) return FALSE; - /* Output all the symbols we have */ - + /* Output all the symbols we have. */ written = 0; for (p = abfd->outsymbols, i = 0; i < limit; i++, p++) { @@ -1211,8 +1142,7 @@ coff_write_symbols (abfd) obj_raw_syment_count (abfd) = written; - /* Now write out strings */ - + /* Now write out strings. */ if (string_size != 0) { unsigned int size = string_size + STRING_SIZE_SIZE; @@ -1223,7 +1153,7 @@ coff_write_symbols (abfd) #else #error Change H_PUT_32 #endif - if (bfd_bwrite ((PTR) buffer, (bfd_size_type) sizeof (buffer), abfd) + if (bfd_bwrite ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd) != sizeof (buffer)) return FALSE; @@ -1265,18 +1195,16 @@ coff_write_symbols (abfd) if (c_symbol == NULL || c_symbol->native == NULL) - { - /* This is not a COFF symbol, so it certainly is not a - file name, nor does it go in the .debug section. */ - maxlen = bfd_coff_force_symnames_in_strings (abfd) ? 0 : SYMNMLEN; - } + /* This is not a COFF symbol, so it certainly is not a + file name, nor does it go in the .debug section. */ + maxlen = bfd_coff_force_symnames_in_strings (abfd) ? 0 : SYMNMLEN; + else if (bfd_coff_symname_in_debug (abfd, &c_symbol->native->u.syment)) - { - /* This symbol name is in the XCOFF .debug section. - Don't write it into the string table. */ - maxlen = name_length; - } + /* This symbol name is in the XCOFF .debug section. + Don't write it into the string table. */ + maxlen = name_length; + else if (c_symbol->native->u.syment.n_sclass == C_FILE && c_symbol->native->u.syment.n_numaux > 0) { @@ -1292,7 +1220,7 @@ coff_write_symbols (abfd) if (name_length > maxlen) { - if (bfd_bwrite ((PTR) (q->name), (bfd_size_type) name_length + 1, + if (bfd_bwrite ((void *) (q->name), (bfd_size_type) name_length + 1, abfd) != name_length + 1) return FALSE; } @@ -1311,7 +1239,7 @@ coff_write_symbols (abfd) #else #error Change H_PUT_32 #endif - if (bfd_bwrite ((PTR) buffer, (bfd_size_type) STRING_SIZE_SIZE, abfd) + if (bfd_bwrite ((void *) buffer, (bfd_size_type) STRING_SIZE_SIZE, abfd) != STRING_SIZE_SIZE) return FALSE; } @@ -1331,12 +1259,11 @@ coff_write_symbols (abfd) } bfd_boolean -coff_write_linenumbers (abfd) - bfd *abfd; +coff_write_linenumbers (bfd *abfd) { asection *s; bfd_size_type linesz; - PTR buff; + void * buff; linesz = bfd_coff_linesz (abfd); buff = bfd_alloc (abfd, linesz); @@ -1349,7 +1276,7 @@ coff_write_linenumbers (abfd) asymbol **q = abfd->outsymbols; if (bfd_seek (abfd, s->line_filepos, SEEK_SET) != 0) return FALSE; - /* Find all the linenumbers in this section */ + /* Find all the linenumbers in this section. */ while (*q) { asymbol *p = *q; @@ -1360,9 +1287,9 @@ coff_write_linenumbers (abfd) (bfd_asymbol_bfd (p), p)); if (l) { - /* Found a linenumber entry, output */ + /* Found a linenumber entry, output. */ struct internal_lineno out; - memset ((PTR) & out, 0, sizeof (out)); + memset ((void *) & out, 0, sizeof (out)); out.l_lnno = 0; out.l_addr.l_symndx = l->u.offset; bfd_coff_swap_lineno_out (abfd, &out, buff); @@ -1391,9 +1318,7 @@ coff_write_linenumbers (abfd) } alent * -coff_get_lineno (ignore_abfd, symbol) - bfd *ignore_abfd ATTRIBUTE_UNUSED; - asymbol *symbol; +coff_get_lineno (bfd *ignore_abfd ATTRIBUTE_UNUSED, asymbol *symbol) { return coffsymbol (symbol)->lineno; } @@ -1402,12 +1327,11 @@ coff_get_lineno (ignore_abfd, symbol) pointers to syments. */ static void -coff_pointerize_aux (abfd, table_base, symbol, indaux, auxent) - bfd *abfd; - combined_entry_type *table_base; - combined_entry_type *symbol; - unsigned int indaux; - combined_entry_type *auxent; +coff_pointerize_aux (bfd *abfd, + combined_entry_type *table_base, + combined_entry_type *symbol, + unsigned int indaux, + combined_entry_type *auxent) { unsigned int type = symbol->u.syment.n_type; unsigned int class = symbol->u.syment.n_sclass; @@ -1419,15 +1343,16 @@ coff_pointerize_aux (abfd, table_base, symbol, indaux, auxent) return; } - /* Don't bother if this is a file or a section */ + /* Don't bother if this is a file or a section. */ if (class == C_STAT && type == T_NULL) return; if (class == C_FILE) return; - /* Otherwise patch up */ -#define N_TMASK coff_data (abfd)->local_n_tmask + /* Otherwise patch up. */ +#define N_TMASK coff_data (abfd)->local_n_tmask #define N_BTSHFT coff_data (abfd)->local_n_btshft + if ((ISFCN (type) || ISTAG (class) || class == C_BLOCK || class == C_FCN) && auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l > 0) { @@ -1450,8 +1375,7 @@ coff_pointerize_aux (abfd, table_base, symbol, indaux, auxent) we didn't want to go to the trouble until someone needed it. */ static char * -build_debug_section (abfd) - bfd *abfd; +build_debug_section (bfd *abfd) { char *debug_section; file_ptr position; @@ -1466,7 +1390,7 @@ build_debug_section (abfd) } sec_size = sect->size; - debug_section = (PTR) bfd_alloc (abfd, sec_size); + debug_section = bfd_alloc (abfd, sec_size); if (debug_section == NULL) return NULL; @@ -1485,25 +1409,20 @@ build_debug_section (abfd) /* Return a pointer to a malloc'd copy of 'name'. 'name' may not be \0-terminated, but will not exceed 'maxlen' characters. The copy *will* be \0-terminated. */ + static char * -copy_name (abfd, name, maxlen) - bfd *abfd; - char *name; - size_t maxlen; +copy_name (bfd *abfd, char *name, size_t maxlen) { size_t len; char *newname; for (len = 0; len < maxlen; ++len) - { - if (name[len] == '\0') - { - break; - } - } + if (name[len] == '\0') + break; + + if ((newname = bfd_alloc (abfd, (bfd_size_type) len + 1)) == NULL) + return NULL; - if ((newname = (PTR) bfd_alloc (abfd, (bfd_size_type) len + 1)) == NULL) - return (NULL); strncpy (newname, name, len); newname[len] = '\0'; return newname; @@ -1512,12 +1431,11 @@ copy_name (abfd, name, maxlen) /* Read in the external symbols. */ bfd_boolean -_bfd_coff_get_external_symbols (abfd) - bfd *abfd; +_bfd_coff_get_external_symbols (bfd *abfd) { bfd_size_type symesz; bfd_size_type size; - PTR syms; + void * syms; if (obj_coff_external_syms (abfd) != NULL) return TRUE; @@ -1526,7 +1444,7 @@ _bfd_coff_get_external_symbols (abfd) size = obj_raw_syment_count (abfd) * symesz; - syms = (PTR) bfd_malloc (size); + syms = bfd_malloc (size); if (syms == NULL && size != 0) return FALSE; @@ -1548,8 +1466,7 @@ _bfd_coff_get_external_symbols (abfd) detecting a missing string table in an archive. */ const char * -_bfd_coff_read_string_table (abfd) - bfd *abfd; +_bfd_coff_read_string_table (bfd *abfd) { char extstrsize[STRING_SIZE_SIZE]; bfd_size_type strsize; @@ -1596,7 +1513,7 @@ _bfd_coff_read_string_table (abfd) return NULL; } - strings = (char *) bfd_malloc (strsize); + strings = bfd_malloc (strsize); if (strings == NULL) return NULL; @@ -1615,8 +1532,7 @@ _bfd_coff_read_string_table (abfd) /* Free up the external symbols and strings read from a COFF file. */ bfd_boolean -_bfd_coff_free_symbols (abfd) - bfd *abfd; +_bfd_coff_free_symbols (bfd *abfd) { if (obj_coff_external_syms (abfd) != NULL && ! obj_coff_keep_syms (abfd)) @@ -1639,8 +1555,7 @@ _bfd_coff_free_symbols (abfd) terminated string. */ combined_entry_type * -coff_get_normalized_symtab (abfd) - bfd *abfd; +coff_get_normalized_symtab (bfd *abfd) { combined_entry_type *internal; combined_entry_type *internal_ptr; @@ -1657,7 +1572,7 @@ coff_get_normalized_symtab (abfd) return obj_raw_syments (abfd); size = obj_raw_syment_count (abfd) * sizeof (combined_entry_type); - internal = (combined_entry_type *) bfd_zalloc (abfd, size); + internal = bfd_zalloc (abfd, size); if (internal == NULL && size != 0) return NULL; internal_end = internal + obj_raw_syment_count (abfd); @@ -1667,22 +1582,22 @@ coff_get_normalized_symtab (abfd) raw_src = (char *) obj_coff_external_syms (abfd); - /* mark the end of the symbols */ + /* Mark the end of the symbols. */ symesz = bfd_coff_symesz (abfd); raw_end = (char *) raw_src + obj_raw_syment_count (abfd) * symesz; /* FIXME SOMEDAY. A string table size of zero is very weird, but probably possible. If one shows up, it will probably kill us. */ - /* Swap all the raw entries */ + /* Swap all the raw entries. */ for (internal_ptr = internal; raw_src < raw_end; raw_src += symesz, internal_ptr++) { unsigned int i; - bfd_coff_swap_sym_in (abfd, (PTR) raw_src, - (PTR) & internal_ptr->u.syment); + bfd_coff_swap_sym_in (abfd, (void *) raw_src, + (void *) & internal_ptr->u.syment); symbol_ptr = internal_ptr; for (i = 0; @@ -1691,7 +1606,7 @@ coff_get_normalized_symtab (abfd) { internal_ptr++; raw_src += symesz; - bfd_coff_swap_aux_in (abfd, (PTR) raw_src, + bfd_coff_swap_aux_in (abfd, (void *) raw_src, symbol_ptr->u.syment.n_type, symbol_ptr->u.syment.n_sclass, (int) i, symbol_ptr->u.syment.n_numaux, @@ -1712,11 +1627,11 @@ coff_get_normalized_symtab (abfd) if (internal_ptr->u.syment.n_sclass == C_FILE && internal_ptr->u.syment.n_numaux > 0) { - /* make a file symbol point to the name in the auxent, since - the text ".file" is redundant */ + /* Make a file symbol point to the name in the auxent, since + the text ".file" is redundant. */ if ((internal_ptr + 1)->u.auxent.x_file.x_n.x_zeroes == 0) { - /* the filename is a long one, point into the string table */ + /* The filename is a long one, point into the string table. */ if (string_table == NULL) { string_table = _bfd_coff_read_string_table (abfd); @@ -1736,21 +1651,17 @@ coff_get_normalized_symtab (abfd) multiple AUX entries. */ if (internal_ptr->u.syment.n_numaux > 1 && coff_data (abfd)->pe) - { - internal_ptr->u.syment._n._n_n._n_offset = - ((long) - copy_name (abfd, - (internal_ptr + 1)->u.auxent.x_file.x_fname, - internal_ptr->u.syment.n_numaux * symesz)); - } + internal_ptr->u.syment._n._n_n._n_offset = + ((long) + copy_name (abfd, + (internal_ptr + 1)->u.auxent.x_file.x_fname, + internal_ptr->u.syment.n_numaux * symesz)); else - { - internal_ptr->u.syment._n._n_n._n_offset = - ((long) - copy_name (abfd, - (internal_ptr + 1)->u.auxent.x_file.x_fname, - (size_t) bfd_coff_filnmlen (abfd))); - } + internal_ptr->u.syment._n._n_n._n_offset = + ((long) + copy_name (abfd, + (internal_ptr + 1)->u.auxent.x_file.x_fname, + (size_t) bfd_coff_filnmlen (abfd))); } } else @@ -1761,15 +1672,15 @@ coff_get_normalized_symtab (abfd) size_t i; char *newstring; - /* find the length of this string without walking into memory + /* Find the length of this string without walking into memory that isn't ours. */ for (i = 0; i < 8; ++i) if (internal_ptr->u.syment._n._n_name[i] == '\0') break; - newstring = (PTR) bfd_zalloc (abfd, (bfd_size_type) (i + 1)); + newstring = bfd_zalloc (abfd, (bfd_size_type) (i + 1)); if (newstring == NULL) - return (NULL); + return NULL; strncpy (newstring, internal_ptr->u.syment._n._n_name, i); internal_ptr->u.syment._n._n_n._n_offset = (long int) newstring; internal_ptr->u.syment._n._n_n._n_zeroes = 0; @@ -1807,13 +1718,11 @@ coff_get_normalized_symtab (abfd) BFD_ASSERT (obj_raw_syment_count (abfd) == (unsigned int) (internal_ptr - internal)); - return (internal); -} /* coff_get_normalized_symtab() */ + return internal; +} long -coff_get_reloc_upper_bound (abfd, asect) - bfd *abfd; - sec_ptr asect; +coff_get_reloc_upper_bound (bfd *abfd, sec_ptr asect) { if (bfd_get_format (abfd) != bfd_object) { @@ -1824,69 +1733,66 @@ coff_get_reloc_upper_bound (abfd, asect) } asymbol * -coff_make_empty_symbol (abfd) - bfd *abfd; +coff_make_empty_symbol (bfd *abfd) { bfd_size_type amt = sizeof (coff_symbol_type); - coff_symbol_type *new = (coff_symbol_type *) bfd_zalloc (abfd, amt); + coff_symbol_type *new = bfd_zalloc (abfd, amt); + if (new == NULL) - return (NULL); + return NULL; new->symbol.section = 0; new->native = 0; - new->lineno = (alent *) NULL; + new->lineno = NULL; new->done_lineno = FALSE; new->symbol.the_bfd = abfd; - return &new->symbol; + + return & new->symbol; } /* Make a debugging symbol. */ asymbol * -coff_bfd_make_debug_symbol (abfd, ptr, sz) - bfd *abfd; - PTR ptr ATTRIBUTE_UNUSED; - unsigned long sz ATTRIBUTE_UNUSED; +coff_bfd_make_debug_symbol (bfd *abfd, + void * ptr ATTRIBUTE_UNUSED, + unsigned long sz ATTRIBUTE_UNUSED) { bfd_size_type amt = sizeof (coff_symbol_type); - coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, amt); + coff_symbol_type *new = bfd_alloc (abfd, amt); + if (new == NULL) - return (NULL); + return NULL; /* @@ The 10 is a guess at a plausible maximum number of aux entries (but shouldn't be a constant). */ amt = sizeof (combined_entry_type) * 10; - new->native = (combined_entry_type *) bfd_zalloc (abfd, amt); + new->native = bfd_zalloc (abfd, amt); if (!new->native) - return (NULL); + return NULL; new->symbol.section = bfd_abs_section_ptr; new->symbol.flags = BSF_DEBUGGING; - new->lineno = (alent *) NULL; + new->lineno = NULL; new->done_lineno = FALSE; new->symbol.the_bfd = abfd; - return &new->symbol; + + return & new->symbol; } void -coff_get_symbol_info (abfd, symbol, ret) - bfd *abfd; - asymbol *symbol; - symbol_info *ret; +coff_get_symbol_info (bfd *abfd, asymbol *symbol, symbol_info *ret) { bfd_symbol_info (symbol, ret); + if (coffsymbol (symbol)->native != NULL && coffsymbol (symbol)->native->fix_value) - { - ret->value = coffsymbol (symbol)->native->u.syment.n_value - - (unsigned long) obj_raw_syments (abfd); - } + ret->value = coffsymbol (symbol)->native->u.syment.n_value - + (unsigned long) obj_raw_syments (abfd); } /* Return the COFF syment for a symbol. */ bfd_boolean -bfd_coff_get_syment (abfd, symbol, psyment) - bfd *abfd; - asymbol *symbol; - struct internal_syment *psyment; +bfd_coff_get_syment (bfd *abfd, + asymbol *symbol, + struct internal_syment *psyment) { coff_symbol_type *csym; @@ -1911,11 +1817,10 @@ bfd_coff_get_syment (abfd, symbol, psyment) /* Return the COFF auxent for a symbol. */ bfd_boolean -bfd_coff_get_auxent (abfd, symbol, indx, pauxent) - bfd *abfd; - asymbol *symbol; - int indx; - union internal_auxent *pauxent; +bfd_coff_get_auxent (bfd *abfd, + asymbol *symbol, + int indx, + union internal_auxent *pauxent) { coff_symbol_type *csym; combined_entry_type *ent; @@ -1955,13 +1860,12 @@ bfd_coff_get_auxent (abfd, symbol, indx, pauxent) /* Print out information about COFF symbol. */ void -coff_print_symbol (abfd, filep, symbol, how) - bfd *abfd; - PTR filep; - asymbol *symbol; - bfd_print_symbol_type how; +coff_print_symbol (bfd *abfd, + void * filep, + asymbol *symbol, + bfd_print_symbol_type how) { - FILE *file = (FILE *) filep; + FILE * file = (FILE *) filep; switch (how) { @@ -2002,7 +1906,7 @@ coff_print_symbol (abfd, filep, symbol, how) (unsigned long) val, symbol->name); #else - /* Print out the wide, 64 bit, symbol value */ + /* Print out the wide, 64 bit, symbol value. */ fprintf (file, "(sec %2d)(fl 0x%02x)(ty %3x)(scl %3d) (nx %d) 0x%016llx %s", combined->u.syment.n_scnum, @@ -2037,7 +1941,7 @@ coff_print_symbol (abfd, filep, symbol, how) case C_STAT: if (combined->u.syment.n_type == T_NULL) - /* probably a section symbol? */ + /* Probably a section symbol ? */ { fprintf (file, "AUX scnlen 0x%lx nreloc %d nlnno %d", (long) auxp->u.auxent.x_scn.x_scnlen, @@ -2052,7 +1956,7 @@ coff_print_symbol (abfd, filep, symbol, how) auxp->u.auxent.x_scn.x_comdat); break; } - /* else fall through */ + /* Otherwise fall through. */ case C_EXT: if (ISFCN (combined->u.syment.n_type)) { @@ -2070,7 +1974,7 @@ coff_print_symbol (abfd, filep, symbol, how) llnos, next); break; } - /* else fall through */ + /* Otherwise fall through. */ default: fprintf (file, "AUX lnno %d size 0x%x tagndx %ld", auxp->u.auxent.x_sym.x_misc.x_lnsz.x_lnno, @@ -2101,7 +2005,7 @@ coff_print_symbol (abfd, filep, symbol, how) } else { - bfd_print_symbol_vandf (abfd, (PTR) file, symbol); + bfd_print_symbol_vandf (abfd, (void *) file, symbol); fprintf (file, " %-5s %s %s %s", symbol->section->name, coffsymbol (symbol)->native ? "n" : "g", @@ -2117,9 +2021,8 @@ coff_print_symbol (abfd, filep, symbol, how) override it. */ bfd_boolean -_bfd_coff_is_local_label_name (abfd, name) - bfd *abfd ATTRIBUTE_UNUSED; - const char *name; +_bfd_coff_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED, + const char *name) { return name[0] == '.' && name[1] == 'L'; } @@ -2129,21 +2032,19 @@ _bfd_coff_is_local_label_name (abfd, name) nearest to the wanted location. */ bfd_boolean -coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr, - functionname_ptr, line_ptr) - bfd *abfd; - asection *section; - asymbol **symbols; - bfd_vma offset; - const char **filename_ptr; - const char **functionname_ptr; - unsigned int *line_ptr; +coff_find_nearest_line (bfd *abfd, + asection *section, + asymbol **symbols, + bfd_vma offset, + const char **filename_ptr, + const char **functionname_ptr, + unsigned int *line_ptr) { bfd_boolean found; unsigned int i; unsigned int line_base; coff_data_type *cof = coff_data (abfd); - /* Run through the raw syments if available */ + /* Run through the raw syments if available. */ combined_entry_type *p; combined_entry_type *pend; alent *l; @@ -2172,7 +2073,7 @@ coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr, *functionname_ptr = 0; *line_ptr = 0; - /* Don't try and find line numbers in a non coff file */ + /* Don't try and find line numbers in a non coff file. */ if (!bfd_family_coff (abfd)) return FALSE; @@ -2242,8 +2143,8 @@ coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr, } } - /* Now wander though the raw linenumbers of the section */ - /* If we have been called on this section before, and the offset we + /* Now wander though the raw linenumbers of the section. */ + /* If we have been called on this section before, and th. e offset we want is further down then we can prime the lookup loop. */ sec_data = coff_section_data (abfd, section); if (sec_data != NULL @@ -2270,7 +2171,7 @@ coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr, { if (l->line_number == 0) { - /* Get the symbol this line number points at */ + /* Get the symbol this line number points at. */ coff_symbol_type *coff = (coff_symbol_type *) (l->u.sym); if (coff->symbol.value > offset) break; @@ -2324,7 +2225,7 @@ coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr, if (sec_data == NULL && section->owner == abfd) { amt = sizeof (struct coff_section_tdata); - section->used_by_bfd = (PTR) bfd_zalloc (abfd, amt); + section->used_by_bfd = bfd_zalloc (abfd, amt); sec_data = (struct coff_section_tdata *) section->used_by_bfd; } if (sec_data != NULL) @@ -2339,31 +2240,25 @@ coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr, } int -coff_sizeof_headers (abfd, reloc) - bfd *abfd; - bfd_boolean reloc; +coff_sizeof_headers (bfd *abfd, bfd_boolean reloc) { size_t size; if (! reloc) - { - size = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd); - } + size = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd); else - { - size = bfd_coff_filhsz (abfd); - } + size = bfd_coff_filhsz (abfd); size += abfd->section_count * bfd_coff_scnhsz (abfd); return size; } /* Change the class of a coff symbol held by BFD. */ + bfd_boolean -bfd_coff_set_symbol_class (abfd, symbol, class) - bfd * abfd; - asymbol * symbol; - unsigned int class; +bfd_coff_set_symbol_class (bfd * abfd, + asymbol * symbol, + unsigned int class) { coff_symbol_type * csym; @@ -2383,7 +2278,7 @@ bfd_coff_set_symbol_class (abfd, symbol, class) combined_entry_type * native; bfd_size_type amt = sizeof (* native); - native = (combined_entry_type *) bfd_zalloc (abfd, amt); + native = bfd_zalloc (abfd, amt); if (native == NULL) return FALSE; @@ -2417,9 +2312,7 @@ bfd_coff_set_symbol_class (abfd, symbol, class) csym->native = native; } else - { - csym->native->u.syment.n_sclass = class; - } + csym->native->u.syment.n_sclass = class; return TRUE; } diff --git a/bfd/elf32-gen.c b/bfd/elf32-gen.c index 09cc5a1..818e3a9 100644 --- a/bfd/elf32-gen.c +++ b/bfd/elf32-gen.c @@ -1,22 +1,22 @@ /* Generic support for 32-bit ELF - Copyright 1993, 1995, 1998, 1999, 2001, 2002, 2004 + Copyright 1993, 1995, 1998, 1999, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" @@ -41,53 +41,48 @@ static reloc_howto_type dummy = 0, /* dst_mask */ FALSE); /* pcrel_offset */ -static void elf_generic_info_to_howto - PARAMS ((bfd *, arelent *, Elf_Internal_Rela *)); -static void elf_generic_info_to_howto_rel - PARAMS ((bfd *, arelent *, Elf_Internal_Rela *)); -static bfd_boolean elf32_generic_link_add_symbols - PARAMS ((bfd *, struct bfd_link_info *)); - static void -elf_generic_info_to_howto (abfd, bfd_reloc, elf_reloc) - bfd *abfd ATTRIBUTE_UNUSED; - arelent *bfd_reloc; - Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED; +elf_generic_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, + arelent *bfd_reloc, + Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED) { bfd_reloc->howto = &dummy; } static void -elf_generic_info_to_howto_rel (abfd, bfd_reloc, elf_reloc) - bfd *abfd ATTRIBUTE_UNUSED; - arelent *bfd_reloc; - Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED; +elf_generic_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, + arelent *bfd_reloc, + Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED) { bfd_reloc->howto = &dummy; } -static bfd_boolean -elf32_generic_link_add_symbols (abfd, info) - bfd *abfd; - struct bfd_link_info *info; +static void +check_for_relocs (bfd * abfd, asection * o, void * failed) { - asection *o; + if ((o->flags & SEC_RELOC) != 0) + { + Elf_Internal_Ehdr *ehdrp; - /* Check if there are any relocations. */ - for (o = abfd->sections; o != NULL; o = o->next) - if ((o->flags & SEC_RELOC) != 0) - { - Elf_Internal_Ehdr *ehdrp; + ehdrp = elf_elfheader (abfd); + _bfd_error_handler (_("%B: Relocations in generic ELF (EM: %d)"), + abfd, ehdrp->e_machine); - ehdrp = elf_elfheader (abfd); - (*_bfd_error_handler) (_("%B: Relocations in generic ELF (EM: %d)"), - abfd, - ehdrp->e_machine); + bfd_set_error (bfd_error_wrong_format); + * (bfd_boolean *) failed = TRUE; + } +} - bfd_set_error (bfd_error_wrong_format); - return FALSE; - } +static bfd_boolean +elf32_generic_link_add_symbols (bfd *abfd, struct bfd_link_info *info) +{ + bfd_boolean failed = FALSE; + + /* Check if there are any relocations. */ + bfd_map_over_sections (abfd, check_for_relocs, & failed); + if (failed) + return FALSE; return bfd_elf_link_add_symbols (abfd, info); } diff --git a/bfd/elf64-gen.c b/bfd/elf64-gen.c index 6b9e22f..6d59176 100644 --- a/bfd/elf64-gen.c +++ b/bfd/elf64-gen.c @@ -1,22 +1,22 @@ /* Generic support for 64-bit ELF - Copyright 1993, 1995, 1998, 1999, 2001, 2002, 2004 + Copyright 1993, 1995, 1998, 1999, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" @@ -41,52 +41,48 @@ static reloc_howto_type dummy = 0, /* dst_mask */ FALSE); /* pcrel_offset */ -static void elf_generic_info_to_howto - PARAMS ((bfd *, arelent *, Elf_Internal_Rela *)); -static void elf_generic_info_to_howto_rel - PARAMS ((bfd *, arelent *, Elf_Internal_Rela *)); -static bfd_boolean elf64_generic_link_add_symbols - PARAMS ((bfd *, struct bfd_link_info *)); - static void -elf_generic_info_to_howto (abfd, bfd_reloc, elf_reloc) - bfd *abfd ATTRIBUTE_UNUSED; - arelent *bfd_reloc; - Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED; +elf_generic_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, + arelent *bfd_reloc, + Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED) { bfd_reloc->howto = &dummy; } static void -elf_generic_info_to_howto_rel (abfd, bfd_reloc, elf_reloc) - bfd *abfd ATTRIBUTE_UNUSED; - arelent *bfd_reloc; - Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED; +elf_generic_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, + arelent *bfd_reloc, + Elf_Internal_Rela *elf_reloc ATTRIBUTE_UNUSED) { bfd_reloc->howto = &dummy; } -static bfd_boolean -elf64_generic_link_add_symbols (abfd, info) - bfd *abfd; - struct bfd_link_info *info; +static void +check_for_relocs (bfd * abfd, asection * o, void * failed) { - asection *o; + if ((o->flags & SEC_RELOC) != 0) + { + Elf_Internal_Ehdr *ehdrp; - /* Check if there are any relocations. */ - for (o = abfd->sections; o != NULL; o = o->next) - if ((o->flags & SEC_RELOC) != 0) - { - Elf_Internal_Ehdr *ehdrp; + ehdrp = elf_elfheader (abfd); + _bfd_error_handler (_("%B: Relocations in generic ELF (EM: %d)"), + abfd, ehdrp->e_machine); - ehdrp = elf_elfheader (abfd); - (*_bfd_error_handler) (_("%B: Relocations in generic ELF (EM: %d)"), - abfd, ehdrp->e_machine); + bfd_set_error (bfd_error_wrong_format); + * (bfd_boolean *) failed = TRUE; + } +} - bfd_set_error (bfd_error_wrong_format); - return FALSE; - } +static bfd_boolean +elf64_generic_link_add_symbols (bfd *abfd, struct bfd_link_info *info) +{ + bfd_boolean failed = FALSE; + + /* Check if there are any relocations. */ + bfd_map_over_sections (abfd, check_for_relocs, & failed); + if (failed) + return FALSE; return bfd_elf_link_add_symbols (abfd, info); } @@ -1,5 +1,5 @@ /* hash.c -- hash table routines for BFD - Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002, 2003, 2004 + Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. Written by Steve Chamberlain <sac@cygnus.com> @@ -230,20 +230,18 @@ SUBSUBSECTION EXAMPLE .struct bfd_hash_entry * -.@var{function_name} (entry, table, string) -. struct bfd_hash_entry *entry; -. struct bfd_hash_table *table; -. const char *string; +.@var{function_name} (struct bfd_hash_entry *entry, +. struct bfd_hash_table *table, +. const char *string) .{ . struct @var{entry_type} *ret = (@var{entry_type} *) entry; . . {* Allocate the structure if it has not already been allocated by a . derived class. *} -. if (ret == (@var{entry_type} *) NULL) +. if (ret == NULL) . { -. ret = ((@var{entry_type} *) -. bfd_hash_allocate (table, sizeof (@var{entry_type}))); -. if (ret == (@var{entry_type} *) NULL) +. ret = bfd_hash_allocate (table, sizeof (* ret)); +. if (ret == NULL) . return NULL; . } . @@ -306,31 +304,29 @@ static size_t bfd_default_hash_table_size = DEFAULT_SIZE; /* Create a new hash table, given a number of entries. */ bfd_boolean -bfd_hash_table_init_n (table, newfunc, size) - struct bfd_hash_table *table; - struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *, - struct bfd_hash_table *, - const char *)); - unsigned int size; +bfd_hash_table_init_n (struct bfd_hash_table *table, + struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *, + struct bfd_hash_table *, + const char *), + unsigned int size) { unsigned int alloc; alloc = size * sizeof (struct bfd_hash_entry *); - table->memory = (PTR) objalloc_create (); + table->memory = (void *) objalloc_create (); if (table->memory == NULL) { bfd_set_error (bfd_error_no_memory); return FALSE; } - table->table = ((struct bfd_hash_entry **) - objalloc_alloc ((struct objalloc *) table->memory, alloc)); + table->table = objalloc_alloc ((struct objalloc *) table->memory, alloc); if (table->table == NULL) { bfd_set_error (bfd_error_no_memory); return FALSE; } - memset ((PTR) table->table, 0, alloc); + memset ((void *) table->table, 0, alloc); table->size = size; table->newfunc = newfunc; return TRUE; @@ -339,11 +335,10 @@ bfd_hash_table_init_n (table, newfunc, size) /* Create a new hash table with the default number of entries. */ bfd_boolean -bfd_hash_table_init (table, newfunc) - struct bfd_hash_table *table; - struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *, - struct bfd_hash_table *, - const char *)); +bfd_hash_table_init (struct bfd_hash_table *table, + struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *, + struct bfd_hash_table *, + const char *)) { return bfd_hash_table_init_n (table, newfunc, bfd_default_hash_table_size); } @@ -351,25 +346,23 @@ bfd_hash_table_init (table, newfunc) /* Free a hash table. */ void -bfd_hash_table_free (table) - struct bfd_hash_table *table; +bfd_hash_table_free (struct bfd_hash_table *table) { - objalloc_free ((struct objalloc *) table->memory); + objalloc_free (table->memory); table->memory = NULL; } /* Look up a string in a hash table. */ struct bfd_hash_entry * -bfd_hash_lookup (table, string, create, copy) - struct bfd_hash_table *table; - const char *string; - bfd_boolean create; - bfd_boolean copy; +bfd_hash_lookup (struct bfd_hash_table *table, + const char *string, + bfd_boolean create, + bfd_boolean copy) { - register const unsigned char *s; - register unsigned long hash; - register unsigned int c; + const unsigned char *s; + unsigned long hash; + unsigned int c; struct bfd_hash_entry *hashp; unsigned int len; unsigned int index; @@ -388,7 +381,7 @@ bfd_hash_lookup (table, string, create, copy) index = hash % table->size; for (hashp = table->table[index]; - hashp != (struct bfd_hash_entry *) NULL; + hashp != NULL; hashp = hashp->next) { if (hashp->hash == hash @@ -397,21 +390,20 @@ bfd_hash_lookup (table, string, create, copy) } if (! create) - return (struct bfd_hash_entry *) NULL; + return NULL; - hashp = (*table->newfunc) ((struct bfd_hash_entry *) NULL, table, string); - if (hashp == (struct bfd_hash_entry *) NULL) - return (struct bfd_hash_entry *) NULL; + hashp = (*table->newfunc) (NULL, table, string); + if (hashp == NULL) + return NULL; if (copy) { char *new; - new = (char *) objalloc_alloc ((struct objalloc *) table->memory, - len + 1); + new = objalloc_alloc ((struct objalloc *) table->memory, len + 1); if (!new) { bfd_set_error (bfd_error_no_memory); - return (struct bfd_hash_entry *) NULL; + return NULL; } memcpy (new, string, len + 1); string = new; @@ -427,17 +419,16 @@ bfd_hash_lookup (table, string, create, copy) /* Replace an entry in a hash table. */ void -bfd_hash_replace (table, old, nw) - struct bfd_hash_table *table; - struct bfd_hash_entry *old; - struct bfd_hash_entry *nw; +bfd_hash_replace (struct bfd_hash_table *table, + struct bfd_hash_entry *old, + struct bfd_hash_entry *nw) { unsigned int index; struct bfd_hash_entry **pph; index = old->hash % table->size; for (pph = &table->table[index]; - (*pph) != (struct bfd_hash_entry *) NULL; + (*pph) != NULL; pph = &(*pph)->next) { if (*pph == old) @@ -450,28 +441,13 @@ bfd_hash_replace (table, old, nw) abort (); } -/* Base method for creating a new hash table entry. */ - -struct bfd_hash_entry * -bfd_hash_newfunc (entry, table, string) - struct bfd_hash_entry *entry; - struct bfd_hash_table *table; - const char *string ATTRIBUTE_UNUSED; -{ - if (entry == (struct bfd_hash_entry *) NULL) - entry = ((struct bfd_hash_entry *) - bfd_hash_allocate (table, sizeof (struct bfd_hash_entry))); - return entry; -} - /* Allocate space in a hash table. */ -PTR -bfd_hash_allocate (table, size) - struct bfd_hash_table *table; - unsigned int size; +void * +bfd_hash_allocate (struct bfd_hash_table *table, + unsigned int size) { - PTR ret; + void * ret; ret = objalloc_alloc ((struct objalloc *) table->memory, size); if (ret == NULL && size != 0) @@ -479,13 +455,24 @@ bfd_hash_allocate (table, size) return ret; } +/* Base method for creating a new hash table entry. */ + +struct bfd_hash_entry * +bfd_hash_newfunc (struct bfd_hash_entry *entry, + struct bfd_hash_table *table, + const char *string ATTRIBUTE_UNUSED) +{ + if (entry == NULL) + entry = bfd_hash_allocate (table, sizeof (* entry)); + return entry; +} + /* Traverse a hash table. */ void -bfd_hash_traverse (table, func, info) - struct bfd_hash_table *table; - bfd_boolean (*func) PARAMS ((struct bfd_hash_entry *, PTR)); - PTR info; +bfd_hash_traverse (struct bfd_hash_table *table, + bfd_boolean (*func) (struct bfd_hash_entry *, void *), + void * info) { unsigned int i; @@ -494,10 +481,8 @@ bfd_hash_traverse (table, func, info) struct bfd_hash_entry *p; for (p = table->table[i]; p != NULL; p = p->next) - { - if (! (*func) (p, info)) - return; - } + if (! (*func) (p, info)) + return; } } @@ -558,30 +543,25 @@ struct bfd_strtab_hash bfd_boolean xcoff; }; -static struct bfd_hash_entry *strtab_hash_newfunc - PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); - /* Routine to create an entry in a strtab. */ static struct bfd_hash_entry * -strtab_hash_newfunc (entry, table, string) - struct bfd_hash_entry *entry; - struct bfd_hash_table *table; - const char *string; +strtab_hash_newfunc (struct bfd_hash_entry *entry, + struct bfd_hash_table *table, + const char *string) { struct strtab_hash_entry *ret = (struct strtab_hash_entry *) entry; /* Allocate the structure if it has not already been allocated by a subclass. */ - if (ret == (struct strtab_hash_entry *) NULL) - ret = ((struct strtab_hash_entry *) - bfd_hash_allocate (table, sizeof (struct strtab_hash_entry))); - if (ret == (struct strtab_hash_entry *) NULL) + if (ret == NULL) + ret = bfd_hash_allocate (table, sizeof (* entry)); + if (ret == NULL) return NULL; /* Call the allocation method of the superclass. */ - ret = ((struct strtab_hash_entry *) - bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string)); + ret = (struct strtab_hash_entry *) + bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string); if (ret) { @@ -602,16 +582,16 @@ strtab_hash_newfunc (entry, table, string) /* Create a new strtab. */ struct bfd_strtab_hash * -_bfd_stringtab_init () +_bfd_stringtab_init (void) { struct bfd_strtab_hash *table; - bfd_size_type amt = sizeof (struct bfd_strtab_hash); + bfd_size_type amt = sizeof (* table); - table = (struct bfd_strtab_hash *) bfd_malloc (amt); + table = bfd_malloc (amt); if (table == NULL) return NULL; - if (! bfd_hash_table_init (&table->table, strtab_hash_newfunc)) + if (! bfd_hash_table_init (& table->table, strtab_hash_newfunc)) { free (table); return NULL; @@ -630,7 +610,7 @@ _bfd_stringtab_init () string. */ struct bfd_strtab_hash * -_bfd_xcoff_stringtab_init () +_bfd_xcoff_stringtab_init (void) { struct bfd_strtab_hash *ret; @@ -643,8 +623,7 @@ _bfd_xcoff_stringtab_init () /* Free a strtab. */ void -_bfd_stringtab_free (table) - struct bfd_strtab_hash *table; +_bfd_stringtab_free (struct bfd_strtab_hash *table) { bfd_hash_table_free (&table->table); free (table); @@ -655,13 +634,12 @@ _bfd_stringtab_free (table) table, and we don't eliminate duplicate strings. */ bfd_size_type -_bfd_stringtab_add (tab, str, hash, copy) - struct bfd_strtab_hash *tab; - const char *str; - bfd_boolean hash; - bfd_boolean copy; +_bfd_stringtab_add (struct bfd_strtab_hash *tab, + const char *str, + bfd_boolean hash, + bfd_boolean copy) { - register struct strtab_hash_entry *entry; + struct strtab_hash_entry *entry; if (hash) { @@ -671,9 +649,7 @@ _bfd_stringtab_add (tab, str, hash, copy) } else { - entry = ((struct strtab_hash_entry *) - bfd_hash_allocate (&tab->table, - sizeof (struct strtab_hash_entry))); + entry = bfd_hash_allocate (&tab->table, sizeof (* entry)); if (entry == NULL) return (bfd_size_type) -1; if (! copy) @@ -682,7 +658,7 @@ _bfd_stringtab_add (tab, str, hash, copy) { char *n; - n = (char *) bfd_hash_allocate (&tab->table, strlen (str) + 1); + n = bfd_hash_allocate (&tab->table, strlen (str) + 1); if (n == NULL) return (bfd_size_type) -1; entry->root.string = n; @@ -713,8 +689,7 @@ _bfd_stringtab_add (tab, str, hash, copy) /* Get the number of bytes in a strtab. */ bfd_size_type -_bfd_stringtab_size (tab) - struct bfd_strtab_hash *tab; +_bfd_stringtab_size (struct bfd_strtab_hash *tab) { return tab->size; } @@ -723,12 +698,10 @@ _bfd_stringtab_size (tab) the file. */ bfd_boolean -_bfd_stringtab_emit (abfd, tab) - register bfd *abfd; - struct bfd_strtab_hash *tab; +_bfd_stringtab_emit (bfd *abfd, struct bfd_strtab_hash *tab) { - register bfd_boolean xcoff; - register struct strtab_hash_entry *entry; + bfd_boolean xcoff; + struct strtab_hash_entry *entry; xcoff = tab->xcoff; @@ -746,11 +719,11 @@ _bfd_stringtab_emit (abfd, tab) /* The output length includes the null byte. */ bfd_put_16 (abfd, (bfd_vma) len, buf); - if (bfd_bwrite ((PTR) buf, (bfd_size_type) 2, abfd) != 2) + if (bfd_bwrite ((void *) buf, (bfd_size_type) 2, abfd) != 2) return FALSE; } - if (bfd_bwrite ((PTR) str, (bfd_size_type) len, abfd) != len) + if (bfd_bwrite ((void *) str, (bfd_size_type) len, abfd) != len) return FALSE; } @@ -40,181 +40,34 @@ struct output_buffer_struct int buffer; }; -static bfd_boolean ieee_write_byte - PARAMS ((bfd *, int)); -static bfd_boolean ieee_write_2bytes - PARAMS ((bfd *, int)); -static bfd_boolean ieee_write_int - PARAMS ((bfd *, bfd_vma)); -static bfd_boolean ieee_write_id - PARAMS ((bfd *, const char *)); -static unsigned short read_2bytes - PARAMS ((common_header_type *)); -static void bfd_get_string - PARAMS ((common_header_type *, char *, size_t)); -static char *read_id - PARAMS ((common_header_type *)); -static bfd_boolean ieee_write_expression - PARAMS ((bfd *, bfd_vma, asymbol *, bfd_boolean, unsigned int)); -static void ieee_write_int5 - PARAMS ((bfd_byte *, bfd_vma)); -static bfd_boolean ieee_write_int5_out - PARAMS ((bfd *, bfd_vma)); -static bfd_boolean parse_int - PARAMS ((common_header_type *, bfd_vma *)); -static int parse_i - PARAMS ((common_header_type *, bfd_boolean *)); -static bfd_vma must_parse_int - PARAMS ((common_header_type *)); -static void parse_expression - PARAMS ((ieee_data_type *, bfd_vma *, ieee_symbol_index_type *, - bfd_boolean *, unsigned int *, asection **)); -static file_ptr ieee_part_after - PARAMS ((ieee_data_type *, file_ptr)); -static ieee_symbol_type *get_symbol - PARAMS ((bfd *, ieee_data_type *, ieee_symbol_type *, unsigned int *, - ieee_symbol_type ***, unsigned int *, int)); -static bfd_boolean ieee_slurp_external_symbols - PARAMS ((bfd *)); -static bfd_boolean ieee_slurp_symbol_table - PARAMS ((bfd *)); -static long ieee_get_symtab_upper_bound - PARAMS ((bfd *)); -static long ieee_canonicalize_symtab - PARAMS ((bfd *, asymbol **)); -static asection *get_section_entry - PARAMS ((bfd *, ieee_data_type *i, unsigned int)); -static void ieee_slurp_sections - PARAMS ((bfd *)); -static bfd_boolean ieee_slurp_debug - PARAMS ((bfd *)); -const bfd_target *ieee_archive_p - PARAMS ((bfd *)); -const bfd_target *ieee_object_p - PARAMS ((bfd *)); -static void ieee_get_symbol_info - PARAMS ((bfd *, asymbol *, symbol_info *)); -static void ieee_print_symbol - PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type)); -static bfd_boolean do_one - PARAMS ((ieee_data_type *, ieee_per_section_type *, unsigned char *, - asection *, int)); -static bfd_boolean ieee_slurp_section_data - PARAMS ((bfd *)); -static bfd_boolean ieee_new_section_hook - PARAMS ((bfd *, asection *)); -static long ieee_get_reloc_upper_bound - PARAMS ((bfd *, sec_ptr)); -static bfd_boolean ieee_get_section_contents - PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type)); -static long ieee_canonicalize_reloc - PARAMS ((bfd *, sec_ptr, arelent **, asymbol **)); -static int comp - PARAMS ((const PTR, const PTR)); -static bfd_boolean ieee_write_section_part - PARAMS ((bfd *)); -static bfd_boolean do_with_relocs - PARAMS ((bfd *, asection *)); -static bfd_boolean do_as_repeat - PARAMS ((bfd *, asection *)); -static bfd_boolean do_without_relocs - PARAMS ((bfd *, asection *)); -static bfd_boolean ieee_mkobject - PARAMS ((bfd *)); -static void fill - PARAMS ((void)); -static void flush - PARAMS ((void)); -static void write_int - PARAMS ((int)); -static void copy_id - PARAMS ((void)); -static void copy_expression - PARAMS ((void)); -static void fill_int - PARAMS ((struct output_buffer_struct *)); -static void drop_int - PARAMS ((struct output_buffer_struct *)); -static void copy_int - PARAMS ((void)); -static void f1_record - PARAMS ((void)); -static void f0_record - PARAMS ((void)); -static void copy_till_end - PARAMS ((void)); -static void f2_record - PARAMS ((void)); -static void f8_record - PARAMS ((void)); -static void e2_record - PARAMS ((void)); -static void block - PARAMS ((void)); -static void relocate_debug - PARAMS ((bfd *, bfd *)); -static bfd_boolean ieee_write_debug_part - PARAMS ((bfd *)); -static bfd_boolean ieee_write_data_part - PARAMS ((bfd *)); -static bfd_boolean init_for_output - PARAMS ((bfd *)); -static bfd_boolean ieee_set_section_contents - PARAMS ((bfd *, sec_ptr, const PTR, file_ptr, bfd_size_type)); -static bfd_boolean ieee_write_external_part - PARAMS ((bfd *)); -static bfd_boolean ieee_write_me_part - PARAMS ((bfd *)); -static bfd_boolean ieee_write_processor - PARAMS ((bfd *)); -static bfd_boolean ieee_write_object_contents - PARAMS ((bfd *)); -static asymbol *ieee_make_empty_symbol - PARAMS ((bfd *)); -static bfd *ieee_openr_next_archived_file - PARAMS ((bfd *, bfd *)); -static bfd_boolean ieee_find_nearest_line - PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **, - const char **, unsigned int *)); -static int ieee_generic_stat_arch_elt - PARAMS ((bfd *, struct stat *)); -static int ieee_sizeof_headers - PARAMS ((bfd *, bfd_boolean)); - /* Functions for writing to ieee files in the strange way that the - standard requires. */ + standard requires. */ static bfd_boolean -ieee_write_byte (abfd, barg) - bfd *abfd; - int barg; +ieee_write_byte (bfd *abfd, int barg) { bfd_byte byte; byte = barg; - if (bfd_bwrite ((PTR) &byte, (bfd_size_type) 1, abfd) != 1) + if (bfd_bwrite ((void *) &byte, (bfd_size_type) 1, abfd) != 1) return FALSE; return TRUE; } static bfd_boolean -ieee_write_2bytes (abfd, bytes) - bfd *abfd; - int bytes; +ieee_write_2bytes (bfd *abfd, int bytes) { bfd_byte buffer[2]; buffer[0] = bytes >> 8; buffer[1] = bytes & 0xff; - if (bfd_bwrite ((PTR) buffer, (bfd_size_type) 2, abfd) != 2) + if (bfd_bwrite ((void *) buffer, (bfd_size_type) 2, abfd) != 2) return FALSE; return TRUE; } static bfd_boolean -ieee_write_int (abfd, value) - bfd *abfd; - bfd_vma value; +ieee_write_int (bfd *abfd, bfd_vma value) { if (value <= 127) { @@ -264,9 +117,7 @@ ieee_write_int (abfd, value) } static bfd_boolean -ieee_write_id (abfd, id) - bfd *abfd; - const char *id; +ieee_write_id (bfd *abfd, const char *id) { size_t length = strlen (id); @@ -296,7 +147,7 @@ ieee_write_id (abfd, id) return FALSE; } - if (bfd_bwrite ((PTR) id, (bfd_size_type) length, abfd) != length) + if (bfd_bwrite ((void *) id, (bfd_size_type) length, abfd) != length) return FALSE; return TRUE; } @@ -304,13 +155,12 @@ ieee_write_id (abfd, id) /* Functions for reading from ieee files in the strange way that the standard requires. */ -#define this_byte(ieee) *((ieee)->input_p) -#define next_byte(ieee) ((ieee)->input_p++) +#define this_byte(ieee) *((ieee)->input_p) +#define next_byte(ieee) ((ieee)->input_p++) #define this_byte_and_next(ieee) (*((ieee)->input_p++)) static unsigned short -read_2bytes (ieee) - common_header_type *ieee; +read_2bytes (common_header_type *ieee) { unsigned char c1 = this_byte_and_next (ieee); unsigned char c2 = this_byte_and_next (ieee); @@ -319,10 +169,7 @@ read_2bytes (ieee) } static void -bfd_get_string (ieee, string, length) - common_header_type *ieee; - char *string; - size_t length; +bfd_get_string (common_header_type *ieee, char *string, size_t length) { size_t i; @@ -331,22 +178,20 @@ bfd_get_string (ieee, string, length) } static char * -read_id (ieee) - common_header_type *ieee; +read_id (common_header_type *ieee) { size_t length; char *string; length = this_byte_and_next (ieee); if (length <= 0x7f) - { - /* Simple string of length 0 to 127. */ - } + /* Simple string of length 0 to 127. */ + ; + else if (length == 0xde) - { - /* Length is next byte, allowing 0..255. */ - length = this_byte_and_next (ieee); - } + /* Length is next byte, allowing 0..255. */ + length = this_byte_and_next (ieee); + else if (length == 0xdf) { /* Length is next two bytes, allowing 0..65535. */ @@ -364,12 +209,11 @@ read_id (ieee) } static bfd_boolean -ieee_write_expression (abfd, value, symbol, pcrel, index) - bfd *abfd; - bfd_vma value; - asymbol *symbol; - bfd_boolean pcrel; - unsigned int index; +ieee_write_expression (bfd *abfd, + bfd_vma value, + asymbol *symbol, + bfd_boolean pcrel, + unsigned int index) { unsigned int term_count = 0; @@ -396,7 +240,6 @@ ieee_write_expression (abfd, value, symbol, pcrel, index) else if (! bfd_is_abs_section (symbol->section)) { /* Ref to defined symbol - */ - if (symbol->flags & BSF_GLOBAL) { if (! ieee_write_byte (abfd, ieee_variable_I_enum) @@ -462,9 +305,7 @@ ieee_write_expression (abfd, value, symbol, pcrel, index) /* Writes any integer into the buffer supplied and always takes 5 bytes. */ static void -ieee_write_int5 (buffer, value) - bfd_byte *buffer; - bfd_vma value; +ieee_write_int5 (bfd_byte *buffer, bfd_vma value) { buffer[0] = (bfd_byte) ieee_number_repeat_4_enum; buffer[1] = (value >> 24) & 0xff; @@ -474,22 +315,18 @@ ieee_write_int5 (buffer, value) } static bfd_boolean -ieee_write_int5_out (abfd, value) - bfd *abfd; - bfd_vma value; +ieee_write_int5_out (bfd *abfd, bfd_vma value) { bfd_byte b[5]; ieee_write_int5 (b, value); - if (bfd_bwrite ((PTR) b, (bfd_size_type) 5, abfd) != 5) + if (bfd_bwrite ((void *) b, (bfd_size_type) 5, abfd) != 5) return FALSE; return TRUE; } static bfd_boolean -parse_int (ieee, value_ptr) - common_header_type *ieee; - bfd_vma *value_ptr; +parse_int (common_header_type *ieee, bfd_vma *value_ptr) { int value = this_byte (ieee); int result; @@ -518,9 +355,7 @@ parse_int (ieee, value_ptr) } static int -parse_i (ieee, ok) - common_header_type *ieee; - bfd_boolean *ok; +parse_i (common_header_type *ieee, bfd_boolean *ok) { bfd_vma x; *ok = parse_int (ieee, &x); @@ -528,8 +363,7 @@ parse_i (ieee, ok) } static bfd_vma -must_parse_int (ieee) - common_header_type *ieee; +must_parse_int (common_header_type *ieee)a { bfd_vma result; BFD_ASSERT (parse_int (ieee, &result)); @@ -649,29 +483,28 @@ static reloc_howto_type rel8_howto = static ieee_symbol_index_type NOSYMBOL = {0, 0}; static void -parse_expression (ieee, value, symbol, pcrel, extra, section) - ieee_data_type *ieee; - bfd_vma *value; - ieee_symbol_index_type *symbol; - bfd_boolean *pcrel; - unsigned int *extra; - asection **section; +parse_expression (ieee_data_type *ieee, + bfd_vma *value, + ieee_symbol_index_type *symbol, + bfd_boolean *pcrel, + unsigned int *extra, + asection **section) { + bfd_boolean loop = TRUE; + ieee_value_type stack[10]; + ieee_value_type *sp = stack; + asection *dummy; + #define POS sp[1] #define TOS sp[0] #define NOS sp[-1] #define INC sp++; #define DEC sp--; - bfd_boolean loop = TRUE; - ieee_value_type stack[10]; - /* The stack pointer always points to the next unused location. */ -#define PUSH(x,y,z) TOS.symbol=x;TOS.section=y;TOS.value=z;INC; -#define POP(x,y,z) DEC;x=TOS.symbol;y=TOS.section;z=TOS.value; - ieee_value_type *sp = stack; - asection *dummy; +#define PUSH(x,y,z) TOS.symbol = x; TOS.section = y; TOS.value = z; INC; +#define POP(x,y,z) DEC; x = TOS.symbol; y = TOS.section; z = TOS.value; while (loop && ieee->h.input_p < ieee->h.last_byte) { @@ -710,6 +543,7 @@ parse_expression (ieee, value, symbol, pcrel, extra, section) /* Push the address of variable n. */ { ieee_symbol_index_type sy; + next_byte (&(ieee->h)); sy.index = (int) must_parse_int (&(ieee->h)); sy.letter = 'I'; @@ -721,6 +555,7 @@ parse_expression (ieee, value, symbol, pcrel, extra, section) /* Push the address of external variable n. */ { ieee_symbol_index_type sy; + next_byte (&(ieee->h)); sy.index = (int) (must_parse_int (&(ieee->h))); sy.letter = 'X'; @@ -733,6 +568,7 @@ parse_expression (ieee, value, symbol, pcrel, extra, section) bfd_vma value1, value2; asection *section1, *section_dummy; ieee_symbol_index_type sy; + next_byte (&(ieee->h)); POP (sy, section1, value1); @@ -747,6 +583,7 @@ parse_expression (ieee, value, symbol, pcrel, extra, section) asection *section2; ieee_symbol_index_type sy1; ieee_symbol_index_type sy2; + next_byte (&(ieee->h)); POP (sy1, section1, value1); @@ -759,6 +596,7 @@ parse_expression (ieee, value, symbol, pcrel, extra, section) default: { bfd_vma va; + BFD_ASSERT (this_byte (&(ieee->h)) < (int) ieee_variable_A_enum || this_byte (&(ieee->h)) > (int) ieee_variable_Z_enum); if (parse_int (&(ieee->h), &va)) @@ -766,10 +604,8 @@ parse_expression (ieee, value, symbol, pcrel, extra, section) PUSH (NOSYMBOL, bfd_abs_section_ptr, va); } else - { - /* Thats all that we can understand. */ - loop = FALSE; - } + /* Thats all that we can understand. */ + loop = FALSE; } } } @@ -784,6 +620,7 @@ parse_expression (ieee, value, symbol, pcrel, extra, section) { asection *section1; ieee_symbol_index_type sy1; + POP (sy1, section1, *extra); } @@ -808,9 +645,7 @@ parse_expression (ieee, value, symbol, pcrel, extra, section) /* Find the first part of the ieee file after HERE. */ static file_ptr -ieee_part_after (ieee, here) - ieee_data_type *ieee; - file_ptr here; +ieee_part_after (ieee_data_type *ieee, file_ptr here) { int part; file_ptr after = ieee->w.r.me_record; @@ -828,14 +663,13 @@ static unsigned int last_index; static char last_type; /* Is the index for an X or a D. */ static ieee_symbol_type * -get_symbol (abfd, ieee, last_symbol, symbol_count, pptr, max_index, this_type) - bfd *abfd ATTRIBUTE_UNUSED; - ieee_data_type *ieee; - ieee_symbol_type *last_symbol; - unsigned int *symbol_count; - ieee_symbol_type ***pptr; - unsigned int *max_index; - int this_type; +get_symbol (bfd *abfd ATTRIBUTE_UNUSED, + ieee_data_type *ieee, + ieee_symbol_type *last_symbol, + unsigned int *symbol_count, + ieee_symbol_type ***pptr, + unsigned int *max_index, + int this_type) { /* Need a new symbol. */ unsigned int new_index = must_parse_int (&(ieee->h)); @@ -845,7 +679,7 @@ get_symbol (abfd, ieee, last_symbol, symbol_count, pptr, max_index, this_type) ieee_symbol_type *new_symbol; bfd_size_type amt = sizeof (ieee_symbol_type); - new_symbol = (ieee_symbol_type *) bfd_alloc (ieee->h.abfd, amt); + new_symbol = bfd_alloc (ieee->h.abfd, amt); if (!new_symbol) return NULL; @@ -865,17 +699,17 @@ get_symbol (abfd, ieee, last_symbol, symbol_count, pptr, max_index, this_type) } static bfd_boolean -ieee_slurp_external_symbols (abfd) - bfd *abfd; +ieee_slurp_external_symbols (bfd *abfd) { ieee_data_type *ieee = IEEE_DATA (abfd); file_ptr offset = ieee->w.r.external_part; ieee_symbol_type **prev_symbols_ptr = &ieee->external_symbols; ieee_symbol_type **prev_reference_ptr = &ieee->external_reference; - ieee_symbol_type *symbol = (ieee_symbol_type *) NULL; + ieee_symbol_type *symbol = NULL; unsigned int symbol_count = 0; bfd_boolean loop = TRUE; + last_index = 0xffffff; ieee->symbol_table_full = TRUE; @@ -889,14 +723,14 @@ ieee_slurp_external_symbols (abfd) next_byte (&(ieee->h)); symbol = get_symbol (abfd, ieee, symbol, &symbol_count, - &prev_symbols_ptr, - &ieee->external_symbol_max_index, 'I'); + & prev_symbols_ptr, + & ieee->external_symbol_max_index, 'I'); if (symbol == NULL) return FALSE; symbol->symbol.the_bfd = abfd; symbol->symbol.name = read_id (&(ieee->h)); - symbol->symbol.udata.p = (PTR) NULL; + symbol->symbol.udata.p = NULL; symbol->symbol.flags = BSF_NO_FLAGS; break; case ieee_external_symbol_enum: @@ -912,7 +746,7 @@ ieee_slurp_external_symbols (abfd) symbol->symbol.the_bfd = abfd; symbol->symbol.name = read_id (&(ieee->h)); - symbol->symbol.udata.p = (PTR) NULL; + symbol->symbol.udata.p = NULL; symbol->symbol.flags = BSF_NO_FLAGS; break; case ieee_attribute_record_enum >> 8: @@ -921,6 +755,7 @@ ieee_slurp_external_symbols (abfd) unsigned int symbol_type_index; unsigned int symbol_attribute_def; bfd_vma value; + switch (read_2bytes (&ieee->h)) { case ieee_attribute_record_enum: @@ -995,6 +830,7 @@ ieee_slurp_external_symbols (abfd) ieee_symbol_index_type symbol_ignore; bfd_boolean pcrel_ignore; unsigned int extra; + next_byte (&(ieee->h)); next_byte (&(ieee->h)); @@ -1036,6 +872,7 @@ ieee_slurp_external_symbols (abfd) { bfd_vma size; bfd_vma value; + next_byte (&(ieee->h)); /* Throw away the external reference index. */ (void) must_parse_int (&(ieee->h)); @@ -1043,9 +880,7 @@ ieee_slurp_external_symbols (abfd) size = must_parse_int (&(ieee->h)); /* Fetch the default value if available. */ if (! parse_int (&(ieee->h), &value)) - { - value = 0; - } + value = 0; /* This turns into a common. */ symbol->symbol.section = bfd_com_section_ptr; symbol->symbol.value = size; @@ -1063,7 +898,7 @@ ieee_slurp_external_symbols (abfd) symbol->symbol.the_bfd = abfd; symbol->symbol.name = read_id (&(ieee->h)); - symbol->symbol.udata.p = (PTR) NULL; + symbol->symbol.udata.p = NULL; symbol->symbol.section = bfd_und_section_ptr; symbol->symbol.value = (bfd_vma) 0; symbol->symbol.flags = 0; @@ -1083,9 +918,7 @@ ieee_slurp_external_symbols (abfd) ieee->external_symbol_min_index + 1; } else - { - ieee->external_symbol_count = 0; - } + ieee->external_symbol_count = 0; if (ieee->external_reference_max_index != 0) { @@ -1094,28 +927,23 @@ ieee_slurp_external_symbols (abfd) ieee->external_reference_min_index + 1; } else - { - ieee->external_reference_count = 0; - } + ieee->external_reference_count = 0; abfd->symcount = ieee->external_reference_count + ieee->external_symbol_count; if (symbol_count != abfd->symcount) - { - /* There are gaps in the table -- */ - ieee->symbol_table_full = FALSE; - } + /* There are gaps in the table -- */ + ieee->symbol_table_full = FALSE; - *prev_symbols_ptr = (ieee_symbol_type *) NULL; - *prev_reference_ptr = (ieee_symbol_type *) NULL; + *prev_symbols_ptr = NULL; + *prev_reference_ptr = NULL; return TRUE; } static bfd_boolean -ieee_slurp_symbol_table (abfd) - bfd *abfd; +ieee_slurp_symbol_table (bfd *abfd) { if (! IEEE_DATA (abfd)->read_symbols) { @@ -1143,9 +971,7 @@ ieee_get_symtab_upper_bound (abfd) extern const bfd_target ieee_vec; static long -ieee_canonicalize_symtab (abfd, location) - bfd *abfd; - asymbol **location; +ieee_canonicalize_symtab (bfd *abfd, asymbol **location) { ieee_symbol_type *symp; static bfd dummy_bfd; @@ -1165,6 +991,7 @@ ieee_canonicalize_symtab (abfd, location) if (abfd->symcount) { ieee_data_type *ieee = IEEE_DATA (abfd); + dummy_bfd.xvec = &ieee_vec; if (! ieee_slurp_symbol_table (abfd)) return -1; @@ -1204,10 +1031,7 @@ ieee_canonicalize_symtab (abfd, location) } static asection * -get_section_entry (abfd, ieee, index) - bfd *abfd; - ieee_data_type *ieee; - unsigned int index; +get_section_entry (bfd *abfd, ieee_data_type *ieee, unsigned int index) { if (index >= ieee->section_table_size) { @@ -1223,7 +1047,7 @@ get_section_entry (abfd, ieee, index) amt = c; amt *= sizeof (asection *); - n = (asection **) bfd_realloc (ieee->section_table, amt); + n = bfd_realloc (ieee->section_table, amt); if (n == NULL) return NULL; @@ -1252,8 +1076,7 @@ get_section_entry (abfd, ieee, index) } static void -ieee_slurp_sections (abfd) - bfd *abfd; +ieee_slurp_sections (bfd *abfd) { ieee_data_type *ieee = IEEE_DATA (abfd); file_ptr offset = ieee->w.r.section_part; @@ -1262,6 +1085,7 @@ ieee_slurp_sections (abfd) if (offset != 0) { bfd_byte section_type[3]; + ieee_seek (ieee, offset); while (TRUE) { @@ -1271,6 +1095,7 @@ ieee_slurp_sections (abfd) { asection *section; unsigned int section_index; + next_byte (&(ieee->h)); section_index = must_parse_int (&(ieee->h)); @@ -1288,7 +1113,8 @@ ieee_slurp_sections (abfd) section->flags = SEC_ALLOC; switch (section_type[1]) { - case 0xD3: /* AS Absolute section attributes. */ + /* AS Absolute section attributes. */ + case 0xD3: next_byte (&(ieee->h)); section_type[2] = this_byte (&(ieee->h)); switch (section_type[2]) @@ -1313,7 +1139,9 @@ ieee_slurp_sections (abfd) } } break; - case 0xC3: /* Named relocatable sections (type C). */ + + /* Named relocatable sections (type C). */ + case 0xC3: section_type[1] = this_byte (&(ieee->h)); section->flags = SEC_ALLOC; switch (section_type[1]) @@ -1343,6 +1171,7 @@ ieee_slurp_sections (abfd) /* Skip these fields, which we don't care about. */ { bfd_vma parent, brother, context; + parse_int (&(ieee->h), &parent); parse_int (&(ieee->h), &brother); parse_int (&(ieee->h), &context); @@ -1354,13 +1183,13 @@ ieee_slurp_sections (abfd) unsigned int section_index; bfd_vma value; asection *section; + next_byte (&(ieee->h)); section_index = must_parse_int (&ieee->h); section = get_section_entry (abfd, ieee, section_index); if (section_index > ieee->section_count) - { - ieee->section_count = section_index; - } + ieee->section_count = section_index; + section->alignment_power = bfd_log2 (must_parse_int (&ieee->h)); (void) parse_int (&(ieee->h), &value); @@ -1422,8 +1251,7 @@ ieee_slurp_sections (abfd) out. */ static bfd_boolean -ieee_slurp_debug (abfd) - bfd *abfd; +ieee_slurp_debug (bfd *abfd) { ieee_data_type *ieee = IEEE_DATA (abfd); asection *sec; @@ -1447,8 +1275,7 @@ ieee_slurp_debug (abfd) /* Archive stuff. */ const bfd_target * -ieee_archive_p (abfd) - bfd *abfd; +ieee_archive_p (bfd *abfd) { char *library; unsigned int i; @@ -1460,14 +1287,14 @@ ieee_archive_p (abfd) ieee_ar_obstack_type *elts = NULL; bfd_size_type amt = sizeof (ieee_ar_data_type); - abfd->tdata.ieee_ar_data = (ieee_ar_data_type *) bfd_alloc (abfd, amt); + abfd->tdata.ieee_ar_data = bfd_alloc (abfd, amt); if (!abfd->tdata.ieee_ar_data) goto error_ret_restore; ieee = IEEE_AR_DATA (abfd); /* Ignore the return value here. It doesn't matter if we don't read the entire buffer. We might have a very small ieee file. */ - bfd_bread ((PTR) buffer, (bfd_size_type) sizeof (buffer), abfd); + bfd_bread ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd); ieee->h.first_byte = buffer; ieee->h.input_p = buffer; @@ -1493,7 +1320,7 @@ ieee_archive_p (abfd) must_parse_int (&(ieee->h)); alc_elts = 10; - elts = (ieee_ar_obstack_type *) bfd_malloc (alc_elts * sizeof *elts); + elts = bfd_malloc (alc_elts * sizeof *elts); if (elts == NULL) goto error_return; @@ -1512,8 +1339,7 @@ ieee_archive_p (abfd) ieee_ar_obstack_type *n; alc_elts *= 2; - n = ((ieee_ar_obstack_type *) - bfd_realloc (elts, alc_elts * sizeof *elts)); + n = bfd_realloc (elts, alc_elts * sizeof (* elts)); if (n == NULL) goto error_return; elts = n; @@ -1535,7 +1361,7 @@ ieee_archive_p (abfd) goto error_return; /* Again ignore return value of bfd_bread. */ - bfd_bread ((PTR) buffer, (bfd_size_type) sizeof (buffer), abfd); + bfd_bread ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd); ieee->h.first_byte = buffer; ieee->h.input_p = buffer; } @@ -1543,7 +1369,7 @@ ieee_archive_p (abfd) amt = ieee->element_count; amt *= sizeof *ieee->elements; - ieee->elements = (ieee_ar_obstack_type *) bfd_alloc (abfd, amt); + ieee->elements = bfd_alloc (abfd, amt); if (ieee->elements == NULL) goto error_return; @@ -1558,7 +1384,7 @@ ieee_archive_p (abfd) goto error_return; /* Again ignore return value of bfd_bread. */ - bfd_bread ((PTR) buffer, (bfd_size_type) sizeof (buffer), abfd); + bfd_bread ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd); ieee->h.first_byte = buffer; ieee->h.input_p = buffer; @@ -1590,8 +1416,7 @@ ieee_archive_p (abfd) } const bfd_target * -ieee_object_p (abfd) - bfd *abfd; +ieee_object_p (bfd *abfd) { char *processor; unsigned int part; @@ -1608,7 +1433,7 @@ ieee_object_p (abfd) goto fail; /* Read the first few bytes in to see if it makes sense. Ignore bfd_bread return value; The file might be very small. */ - bfd_bread ((PTR) buffer, (bfd_size_type) sizeof (buffer), abfd); + bfd_bread ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd); ieee->h.input_p = buffer; if (this_byte_and_next (&(ieee->h)) != Module_Beginning) @@ -1643,14 +1468,14 @@ ieee_object_p (abfd) m68k family. Code for other processors can be added here. */ if ((processor[0] == '6') && (processor[1] == '8')) { - if (processor[2] == '3') /* 683xx integrated processors */ + if (processor[2] == '3') /* 683xx integrated processors. */ { switch (processor[3]) { case '0': /* 68302, 68306, 68307 */ case '2': /* 68322, 68328 */ case '5': /* 68356 */ - strcpy (family, "68000"); /* MC68000-based controllers */ + strcpy (family, "68000"); /* MC68000-based controllers. */ break; case '3': /* 68330, 68331, 68332, 68333, @@ -1667,7 +1492,7 @@ ieee_object_p (abfd) strcpy (family, "68332"); /* CPU32 and CPU32+ */ break; - default: /* Does not exist yet */ + default: /* Does not exist yet. */ strcpy (family, "68332"); /* Guess it will be CPU32 */ } } @@ -1743,15 +1568,14 @@ ieee_object_p (abfd) record. */ amt = ieee->w.r.me_record + 1; - IEEE_DATA (abfd)->h.first_byte = - (unsigned char *) bfd_alloc (ieee->h.abfd, amt); + IEEE_DATA (abfd)->h.first_byte = bfd_alloc (ieee->h.abfd, amt); if (!IEEE_DATA (abfd)->h.first_byte) goto fail; if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) goto fail; /* FIXME: Check return value. I'm not sure whether it needs to read the entire buffer or not. */ - bfd_bread ((PTR) (IEEE_DATA (abfd)->h.first_byte), + bfd_bread ((void *) (IEEE_DATA (abfd)->h.first_byte), (bfd_size_type) ieee->w.r.me_record + 1, abfd); ieee_slurp_sections (abfd); @@ -1760,7 +1584,7 @@ ieee_object_p (abfd) goto fail; /* Parse section data to activate file and section flags implied by - section contents. */ + section contents. */ if (! ieee_slurp_section_data (abfd)) goto fail; @@ -1774,10 +1598,9 @@ fail: } static void -ieee_get_symbol_info (ignore_abfd, symbol, ret) - bfd *ignore_abfd ATTRIBUTE_UNUSED; - asymbol *symbol; - symbol_info *ret; +ieee_get_symbol_info (bfd *ignore_abfd ATTRIBUTE_UNUSED, + asymbol *symbol, + symbol_info *ret) { bfd_symbol_info (symbol, ret); if (symbol->name[0] == ' ') @@ -1787,11 +1610,10 @@ ieee_get_symbol_info (ignore_abfd, symbol, ret) } static void -ieee_print_symbol (abfd, afile, symbol, how) - bfd *abfd; - PTR afile; - asymbol *symbol; - bfd_print_symbol_type how; +ieee_print_symbol (bfd *abfd, + void * afile, + asymbol *symbol, + bfd_print_symbol_type how) { FILE *file = (FILE *) afile; @@ -1811,12 +1633,10 @@ ieee_print_symbol (abfd, afile, symbol, how) : symbol->section->name); if (symbol->name[0] == ' ') - { - fprintf (file, "* empty table entry "); - } + fprintf (file, "* empty table entry "); else { - bfd_print_symbol_vandf (abfd, (PTR) file, symbol); + bfd_print_symbol_vandf (abfd, (void *) file, symbol); fprintf (file, " %-5s %04x %02x %s", section_name, @@ -1830,12 +1650,11 @@ ieee_print_symbol (abfd, afile, symbol, how) } static bfd_boolean -do_one (ieee, current_map, location_ptr, s, iterations) - ieee_data_type *ieee; - ieee_per_section_type *current_map; - unsigned char *location_ptr; - asection *s; - int iterations; +do_one (ieee_data_type *ieee, + ieee_per_section_type *current_map, + unsigned char *location_ptr, + asection *s, + int iterations) { switch (this_byte (&(ieee->h))) { @@ -1876,7 +1695,7 @@ do_one (ieee, current_map, location_ptr, s, iterations) ieee_reloc_type *r; bfd_size_type amt = sizeof (ieee_reloc_type); - r = (ieee_reloc_type *) bfd_alloc (ieee->h.abfd, amt); + r = bfd_alloc (ieee->h.abfd, amt); if (!r) return FALSE; @@ -2004,9 +1823,11 @@ do_one (ieee, current_map, location_ptr, s, iterations) default: { bfd_vma this_size; + if (parse_int (&(ieee->h), &this_size)) { unsigned int i; + for (i = 0; i < this_size; i++) { location_ptr[current_map->pc++] = this_byte (&(ieee->h)); @@ -2014,14 +1835,12 @@ do_one (ieee, current_map, location_ptr, s, iterations) } } else - { - loop = FALSE; - } + loop = FALSE; } } /* Prevent more than the first load-item of an LR record - from being repeated (MRI convention). */ + from being repeated (MRI convention). */ if (iterations != 1) loop = FALSE; } @@ -2033,15 +1852,14 @@ do_one (ieee, current_map, location_ptr, s, iterations) /* Read in all the section data and relocation stuff too. */ static bfd_boolean -ieee_slurp_section_data (abfd) - bfd *abfd; +ieee_slurp_section_data (bfd *abfd) { bfd_byte *location_ptr = (bfd_byte *) NULL; ieee_data_type *ieee = IEEE_DATA (abfd); unsigned int section_number; - - ieee_per_section_type *current_map = (ieee_per_section_type *) NULL; + ieee_per_section_type *current_map = NULL; asection *s; + /* Seek to the start of the data area. */ if (ieee->read_data) return TRUE; @@ -2052,9 +1870,10 @@ ieee_slurp_section_data (abfd) for (s = abfd->sections; s != (asection *) NULL; s = s->next) { ieee_per_section_type *per = ieee_per_section (s); + if ((s->flags & SEC_DEBUGGING) != 0) continue; - per->data = (bfd_byte *) bfd_alloc (ieee->h.abfd, s->size); + per->data = bfd_alloc (ieee->h.abfd, s->size); if (!per->data) return FALSE; per->reloc_tail_ptr = @@ -2162,23 +1981,18 @@ ieee_slurp_section_data (abfd) } static bfd_boolean -ieee_new_section_hook (abfd, newsect) - bfd *abfd; - asection *newsect; +ieee_new_section_hook (bfd *abfd, asection *newsect) { - newsect->used_by_bfd - = (PTR) bfd_alloc (abfd, (bfd_size_type) sizeof (ieee_per_section_type)); + newsect->used_by_bfd = bfd_alloc (abfd, (bfd_size_type) sizeof (ieee_per_section_type)); if (!newsect->used_by_bfd) return FALSE; - ieee_per_section (newsect)->data = (bfd_byte *) NULL; + ieee_per_section (newsect)->data = NULL; ieee_per_section (newsect)->section = newsect; return TRUE; } static long -ieee_get_reloc_upper_bound (abfd, asect) - bfd *abfd; - sec_ptr asect; +ieee_get_reloc_upper_bound (bfd *abfd, sec_ptr asect) { if ((asect->flags & SEC_DEBUGGING) != 0) return 0; @@ -2188,28 +2002,26 @@ ieee_get_reloc_upper_bound (abfd, asect) } static bfd_boolean -ieee_get_section_contents (abfd, section, location, offset, count) - bfd *abfd; - sec_ptr section; - PTR location; - file_ptr offset; - bfd_size_type count; +ieee_get_section_contents (bfd *abfd, + sec_ptr section, + void * location, + file_ptr offset, + bfd_size_type count) { ieee_per_section_type *p = ieee_per_section (section); if ((section->flags & SEC_DEBUGGING) != 0) return _bfd_generic_get_section_contents (abfd, section, location, offset, count); ieee_slurp_section_data (abfd); - (void) memcpy ((PTR) location, (PTR) (p->data + offset), (unsigned) count); + (void) memcpy ((void *) location, (void *) (p->data + offset), (unsigned) count); return TRUE; } static long -ieee_canonicalize_reloc (abfd, section, relptr, symbols) - bfd *abfd; - sec_ptr section; - arelent **relptr; - asymbol **symbols; +ieee_canonicalize_reloc (bfd *abfd, + sec_ptr section, + arelent **relptr, + asymbol **symbols) { ieee_reloc_type *src = (ieee_reloc_type *) (section->relocation); ieee_data_type *ieee = IEEE_DATA (abfd); @@ -2242,14 +2054,12 @@ ieee_canonicalize_reloc (abfd, section, relptr, symbols) *relptr++ = &src->relent; src = src->next; } - *relptr = (arelent *) NULL; + *relptr = NULL; return section->reloc_count; } static int -comp (ap, bp) - const PTR ap; - const PTR bp; +comp (const void * ap, const void * bp) { arelent *a = *((arelent **) ap); arelent *b = *((arelent **) bp); @@ -2259,11 +2069,11 @@ comp (ap, bp) /* Write the section headers. */ static bfd_boolean -ieee_write_section_part (abfd) - bfd *abfd; +ieee_write_section_part (bfd *abfd) { ieee_data_type *ieee = IEEE_DATA (abfd); asection *s; + ieee->w.r.section_part = bfd_tell (abfd); for (s = abfd->sections; s != (asection *) NULL; s = s->next) { @@ -2345,11 +2155,8 @@ ieee_write_section_part (abfd) return TRUE; } - static bfd_boolean -do_with_relocs (abfd, s) - bfd *abfd; - asection *s; +do_with_relocs (bfd *abfd, asection *s) { unsigned int number_of_maus_in_address = bfd_arch_bits_per_address (abfd) / bfd_arch_bits_per_byte (abfd); @@ -2403,7 +2210,7 @@ do_with_relocs (abfd, s) /* Output a stream of bytes. */ if (! ieee_write_int (abfd, run)) return FALSE; - if (bfd_bwrite ((PTR) (stream + current_byte_index), run, abfd) + if (bfd_bwrite ((void *) (stream + current_byte_index), run, abfd) != run) return FALSE; current_byte_index += run; @@ -2418,11 +2225,10 @@ do_with_relocs (abfd, s) /* Output the data stream as the longest sequence of bytes possible, allowing for the a reasonable packet size and relocation stuffs. */ - - if ((PTR) stream == (PTR) NULL) + if (stream == NULL) { /* Outputting a section without data, fill it up. */ - stream = (unsigned char *) bfd_zalloc (abfd, s->size); + stream = bfd_zalloc (abfd, s->size); if (!stream) return FALSE; } @@ -2448,7 +2254,7 @@ do_with_relocs (abfd, s) /* Output a stream of bytes. */ if (! ieee_write_int (abfd, run)) return FALSE; - if (bfd_bwrite ((PTR) (stream + current_byte_index), run, abfd) + if (bfd_bwrite ((void *) (stream + current_byte_index), run, abfd) != run) return FALSE; current_byte_index += run; @@ -2465,7 +2271,6 @@ do_with_relocs (abfd, s) switch (r->howto->size) { case 2: - ov = bfd_get_signed_32 (abfd, stream + current_byte_index); current_byte_index += 4; @@ -2496,8 +2301,6 @@ do_with_relocs (abfd, s) ieee_function_either_open_b_enum)) return FALSE; -/* abort();*/ - if (r->sym_ptr_ptr != (asymbol **) NULL) { if (! ieee_write_expression (abfd, r->addend + ov, @@ -2542,9 +2345,7 @@ do_with_relocs (abfd, s) bytes. */ static bfd_boolean -do_as_repeat (abfd, s) - bfd *abfd; - asection *s; +do_as_repeat (bfd *abfd, asection *s) { if (s->size) { @@ -2582,9 +2383,7 @@ do_as_repeat (abfd, s) } static bfd_boolean -do_without_relocs (abfd, s) - bfd *abfd; - asection *s; +do_without_relocs (bfd *abfd, asection *s) { bfd_byte *stream = ieee_per_section (s)->data; @@ -2625,8 +2424,7 @@ static bfd *output_bfd; static int output_buffer; static bfd_boolean -ieee_mkobject (abfd) - bfd *abfd; +ieee_mkobject (bfd *abfd) { bfd_size_type amt; @@ -2640,38 +2438,37 @@ ieee_mkobject (abfd) output_bfd = NULL; output_buffer = 0; amt = sizeof (ieee_data_type); - abfd->tdata.ieee_data = (ieee_data_type *) bfd_zalloc (abfd, amt); + abfd->tdata.ieee_data = bfd_zalloc (abfd, amt); return abfd->tdata.ieee_data != NULL; } static void -fill () +fill (void) { bfd_size_type amt = input_ptr_end - input_ptr_start; /* FIXME: Check return value. I'm not sure whether it needs to read the entire buffer or not. */ - bfd_bread ((PTR) input_ptr_start, amt, input_bfd); + bfd_bread ((void *) input_ptr_start, amt, input_bfd); input_ptr = input_ptr_start; } static void -flush () +flush (void) { bfd_size_type amt = output_ptr - output_ptr_start; - if (bfd_bwrite ((PTR) (output_ptr_start), amt, output_bfd) != amt) + if (bfd_bwrite ((void *) (output_ptr_start), amt, output_bfd) != amt) abort (); output_ptr = output_ptr_start; output_buffer++; } #define THIS() ( *input_ptr ) -#define NEXT() { input_ptr++; if (input_ptr == input_ptr_end) fill(); } -#define OUT(x) { *output_ptr++ = (x); if(output_ptr == output_ptr_end) flush(); } +#define NEXT() { input_ptr++; if (input_ptr == input_ptr_end) fill (); } +#define OUT(x) { *output_ptr++ = (x); if (output_ptr == output_ptr_end) flush (); } static void -write_int (value) - int value; +write_int (int value) { if (value >= 0 && value <= 127) { @@ -2680,6 +2477,7 @@ write_int (value) else { unsigned int length; + /* How many significant bytes ? */ /* FIXME FOR LONGER INTS. */ if (value & 0xff000000) @@ -2822,7 +2620,7 @@ copy_expression () } /* Drop the int in the buffer, and copy a null into the gap, which we - will overwrite later */ + will overwrite later. */ static void fill_int (buf) @@ -3291,7 +3089,7 @@ relocate_debug (output, input) input_bfd = input; /* FIXME: Check return value. I'm not sure whether it needs to read the entire buffer or not. */ - bfd_bread ((PTR) input_ptr_start, (bfd_size_type) IBS, input); + bfd_bread ((void *) input_ptr_start, (bfd_size_type) IBS, input); block (); } @@ -3378,7 +3176,7 @@ ieee_write_data_part (abfd) continue; /* Sort the reloc records so we can insert them in the correct - places */ + places. */ if (s->reloc_count != 0) { if (! do_with_relocs (abfd, s)) @@ -3408,7 +3206,7 @@ init_for_output (abfd) if (s->size != 0) { bfd_size_type size = s->size; - ieee_per_section (s)->data = (bfd_byte *) (bfd_alloc (abfd, size)); + ieee_per_section (s)->data = bfd_alloc (abfd, size); if (!ieee_per_section (s)->data) return FALSE; } @@ -3425,7 +3223,7 @@ static bfd_boolean ieee_set_section_contents (abfd, section, location, offset, count) bfd *abfd; sec_ptr section; - const PTR location; + const void * location; file_ptr offset; bfd_size_type count; { @@ -3434,7 +3232,7 @@ ieee_set_section_contents (abfd, section, location, offset, count) if (section->contents == NULL) { bfd_size_type size = section->size; - section->contents = (unsigned char *) bfd_alloc (abfd, size); + section->contents = bfd_alloc (abfd, size); if (section->contents == NULL) return FALSE; } @@ -3449,8 +3247,8 @@ ieee_set_section_contents (abfd, section, location, offset, count) if (!init_for_output (abfd)) return FALSE; } - memcpy ((PTR) (ieee_per_section (section)->data + offset), - (PTR) location, + memcpy ((void *) (ieee_per_section (section)->data + offset), + (void *) location, (unsigned int) count); return TRUE; } @@ -3512,9 +3310,9 @@ ieee_write_external_part (abfd) || ! ieee_write_id (abfd, p->name) || ! ieee_write_2bytes (abfd, ieee_attribute_record_enum) || ! ieee_write_int (abfd, (bfd_vma) public_index) - || ! ieee_write_byte (abfd, 15) /* instruction address */ - || ! ieee_write_byte (abfd, 19) /* static symbol */ - || ! ieee_write_byte (abfd, 1)) /* one of them */ + || ! ieee_write_byte (abfd, 15) /* Instruction address. */ + || ! ieee_write_byte (abfd, 19) /* Static symbol. */ + || ! ieee_write_byte (abfd, 1)) /* One of them. */ return FALSE; /* Write out the value. */ @@ -3585,9 +3383,9 @@ static const unsigned char envi[] = /* 0xf1, 0xce, 0x21, 00, 50, 0x82, 0x07, 0xc7, 0x09, 0x11, 0x11, 0x19, 0x2c, */ - 0xf1, 0xce, 0x21, 00, 52, 0x00, /* exec ok */ + 0xf1, 0xce, 0x21, 00, 52, 0x00, /* exec ok. */ - 0xf1, 0xce, 0x21, 0, 53, 0x03,/* host unix */ + 0xf1, 0xce, 0x21, 0, 53, 0x03,/* host unix. */ /* 0xf1, 0xce, 0x21, 0, 54, 2,1,1 tool & version # */ }; @@ -3741,12 +3539,12 @@ ieee_write_object_contents (abfd) return FALSE; if (abfd->flags & EXEC_P) { - if (! ieee_write_byte (abfd, 0x1)) /* Absolute */ + if (! ieee_write_byte (abfd, 0x1)) /* Absolute. */ return FALSE; } else { - if (! ieee_write_byte (abfd, 0x2)) /* Relocateable */ + if (! ieee_write_byte (abfd, 0x2)) /* Relocateable. */ return FALSE; } @@ -3815,7 +3613,7 @@ ieee_write_object_contents (abfd) return TRUE; } -/* Native-level interface to symbols. */ +/* Native-level interface to symbols. */ /* We read the symbols into a buffer, which is discarded when this function exits. We read the strings into a buffer large enough to @@ -3826,7 +3624,7 @@ ieee_make_empty_symbol (abfd) bfd *abfd; { bfd_size_type amt = sizeof (ieee_symbol_type); - ieee_symbol_type *new = (ieee_symbol_type *) bfd_zalloc (abfd, amt); + ieee_symbol_type *new = bfd_zalloc (abfd, amt); if (!new) return NULL; @@ -4013,7 +3811,7 @@ const bfd_target ieee_vec = }, /* ieee_close_and_cleanup, ieee_bfd_free_cached_info, ieee_new_section_hook, - ieee_get_section_contents, ieee_get_section_contents_in_window */ + ieee_get_section_contents, ieee_get_section_contents_in_window. */ BFD_JUMP_TABLE_GENERIC (ieee), BFD_JUMP_TABLE_COPY (_bfd_generic), @@ -4023,21 +3821,21 @@ const bfd_target ieee_vec = ieee_construct_extended_name_table, ieee_truncate_arname, ieee_write_armap, ieee_read_ar_hdr, ieee_openr_next_archived_file, ieee_get_elt_at_index, ieee_generic_stat_arch_elt, - ieee_update_armap_timestamp */ + ieee_update_armap_timestamp. */ BFD_JUMP_TABLE_ARCHIVE (ieee), /* ieee_get_symtab_upper_bound, ieee_canonicalize_symtab, ieee_make_empty_symbol, ieee_print_symbol, ieee_get_symbol_info, ieee_bfd_is_local_label_name, ieee_get_lineno, ieee_find_nearest_line, ieee_bfd_make_debug_symbol, - ieee_read_minisymbols, ieee_minisymbol_to_symbol */ + ieee_read_minisymbols, ieee_minisymbol_to_symbol. */ BFD_JUMP_TABLE_SYMBOLS (ieee), /* ieee_get_reloc_upper_bound, ieee_canonicalize_reloc, - ieee_bfd_reloc_type_lookup */ + ieee_bfd_reloc_type_lookup. */ BFD_JUMP_TABLE_RELOCS (ieee), - /* ieee_set_arch_mach, ieee_set_section_contents */ + /* ieee_set_arch_mach, ieee_set_section_contents. */ BFD_JUMP_TABLE_WRITE (ieee), /* ieee_sizeof_headers, ieee_bfd_get_relocated_section_contents, @@ -4045,12 +3843,12 @@ const bfd_target ieee_vec = _bfd_generic_link_hash_table_free, ieee_bfd_link_add_symbols, ieee_bfd_final_link, ieee_bfd_link_split_section, ieee_bfd_gc_sections, - ieee_bfd_merge_sections */ + ieee_bfd_merge_sections. */ BFD_JUMP_TABLE_LINK (ieee), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), NULL, - (PTR) 0 + (void *) 0 }; |