X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Fsom.c;h=0bf44d8e8df6fda5d75524ad84e31110ccd6d6cf;hb=ab3acfbe8d9b5c7eab7a3701ca9a0c23ae07acb0;hp=0ea13532546743c03ebf0ec103617b388b86bb30;hpb=dc810e3900d47ab2eea86d50231ff2e70b596847;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/som.c b/bfd/som.c index 0ea1353254..0bf44d8e8d 100644 --- a/bfd/som.c +++ b/bfd/som.c @@ -1,6 +1,6 @@ /* bfd back-end for HP PA-RISC SOM objects. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001 + 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by the Center for Software Science at the @@ -31,12 +31,12 @@ #include "libbfd.h" #include "som.h" +#include "safe-ctype.h" #include #include #include #include -#include /* Magic not defined in standard HP-UX header files until 8.0 */ @@ -150,122 +150,149 @@ struct som_misc_symbol_info { /* Forward declarations */ -static boolean som_mkobject PARAMS ((bfd *)); -static const bfd_target * som_object_setup PARAMS ((bfd *, - struct header *, - struct som_exec_auxhdr *, - unsigned long)); -static boolean setup_sections PARAMS ((bfd *, struct header *, unsigned long)); -static const bfd_target * som_object_p PARAMS ((bfd *)); -static boolean som_write_object_contents PARAMS ((bfd *)); -static boolean som_slurp_string_table PARAMS ((bfd *)); -static unsigned int som_slurp_symbol_table PARAMS ((bfd *)); -static long som_get_symtab_upper_bound PARAMS ((bfd *)); -static long som_canonicalize_reloc PARAMS ((bfd *, sec_ptr, - arelent **, asymbol **)); -static long som_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); -static unsigned int som_set_reloc_info PARAMS ((unsigned char *, unsigned int, - arelent *, asection *, - asymbol **, boolean)); -static boolean som_slurp_reloc_table PARAMS ((bfd *, asection *, - asymbol **, boolean)); -static long som_get_symtab PARAMS ((bfd *, asymbol **)); -static asymbol * som_make_empty_symbol PARAMS ((bfd *)); -static void som_print_symbol PARAMS ((bfd *, PTR, - asymbol *, bfd_print_symbol_type)); -static boolean som_new_section_hook PARAMS ((bfd *, asection *)); -static boolean som_bfd_copy_private_symbol_data PARAMS ((bfd *, asymbol *, - bfd *, asymbol *)); -static boolean som_bfd_copy_private_section_data PARAMS ((bfd *, asection *, - bfd *, asection *)); -static boolean som_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *)); +static bfd_boolean som_mkobject + PARAMS ((bfd *)); +static const bfd_target * som_object_setup + PARAMS ((bfd *, struct header *, struct som_exec_auxhdr *, unsigned long)); +static bfd_boolean setup_sections + PARAMS ((bfd *, struct header *, unsigned long)); +static const bfd_target * som_object_p + PARAMS ((bfd *)); +static bfd_boolean som_write_object_contents + PARAMS ((bfd *)); +static bfd_boolean som_slurp_string_table + PARAMS ((bfd *)); +static unsigned int som_slurp_symbol_table + PARAMS ((bfd *)); +static long som_get_symtab_upper_bound + PARAMS ((bfd *)); +static long som_canonicalize_reloc + PARAMS ((bfd *, sec_ptr, arelent **, asymbol **)); +static long som_get_reloc_upper_bound + PARAMS ((bfd *, sec_ptr)); +static unsigned int som_set_reloc_info + PARAMS ((unsigned char *, unsigned int, arelent *, asection *, + asymbol **, bfd_boolean)); +static bfd_boolean som_slurp_reloc_table + PARAMS ((bfd *, asection *, asymbol **, bfd_boolean)); +static long som_get_symtab + PARAMS ((bfd *, asymbol **)); +static asymbol * som_make_empty_symbol + PARAMS ((bfd *)); +static void som_print_symbol + PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type)); +static bfd_boolean som_new_section_hook + PARAMS ((bfd *, asection *)); +static bfd_boolean som_bfd_copy_private_symbol_data + PARAMS ((bfd *, asymbol *, bfd *, asymbol *)); +static bfd_boolean som_bfd_copy_private_section_data + PARAMS ((bfd *, asection *, bfd *, asection *)); +static bfd_boolean som_bfd_copy_private_bfd_data + PARAMS ((bfd *, bfd *)); #define som_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data #define som_bfd_set_private_flags _bfd_generic_bfd_set_private_flags -static boolean som_bfd_is_local_label_name PARAMS ((bfd *, const char *)); -static boolean som_set_section_contents PARAMS ((bfd *, sec_ptr, PTR, - file_ptr, bfd_size_type)); -static boolean som_get_section_contents PARAMS ((bfd *, sec_ptr, PTR, - file_ptr, bfd_size_type)); -static boolean som_set_arch_mach PARAMS ((bfd *, enum bfd_architecture, - unsigned long)); -static boolean som_find_nearest_line PARAMS ((bfd *, asection *, - asymbol **, bfd_vma, - const char **, - const char **, - unsigned int *)); -static void som_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *)); -static asection * bfd_section_from_som_symbol PARAMS ((bfd *, - struct symbol_dictionary_record *)); -static int log2 PARAMS ((unsigned int)); -static bfd_reloc_status_type hppa_som_reloc PARAMS ((bfd *, arelent *, - asymbol *, PTR, - asection *, bfd *, - char **)); -static void som_initialize_reloc_queue PARAMS ((struct reloc_queue *)); -static void som_reloc_queue_insert PARAMS ((unsigned char *, unsigned int, - struct reloc_queue *)); -static void som_reloc_queue_fix PARAMS ((struct reloc_queue *, unsigned int)); -static int som_reloc_queue_find PARAMS ((unsigned char *, unsigned int, - struct reloc_queue *)); -static unsigned char * try_prev_fixup PARAMS ((bfd *, int *, unsigned char *, - unsigned int, - struct reloc_queue *)); - -static unsigned char * som_reloc_skip PARAMS ((bfd *, unsigned int, - unsigned char *, unsigned int *, - struct reloc_queue *)); -static unsigned char * som_reloc_addend PARAMS ((bfd *, bfd_vma, - unsigned char *, - unsigned int *, - struct reloc_queue *)); -static unsigned char * som_reloc_call PARAMS ((bfd *, unsigned char *, - unsigned int *, - arelent *, int, - struct reloc_queue *)); -static unsigned long som_count_spaces PARAMS ((bfd *)); -static unsigned long som_count_subspaces PARAMS ((bfd *)); -static int compare_syms PARAMS ((const void *, const void *)); -static int compare_subspaces PARAMS ((const void *, const void *)); -static unsigned long som_compute_checksum PARAMS ((bfd *)); -static boolean som_prep_headers PARAMS ((bfd *)); -static int som_sizeof_headers PARAMS ((bfd *, boolean)); -static boolean som_finish_writing PARAMS ((bfd *)); -static boolean som_build_and_write_symbol_table PARAMS ((bfd *)); -static void som_prep_for_fixups PARAMS ((bfd *, asymbol **, unsigned long)); -static boolean som_write_fixups PARAMS ((bfd *, unsigned long, unsigned int *)); -static boolean som_write_space_strings PARAMS ((bfd *, unsigned long, - unsigned int *)); -static boolean som_write_symbol_strings PARAMS ((bfd *, unsigned long, - asymbol **, unsigned int, - unsigned *, - COMPUNIT *)); -static boolean som_begin_writing PARAMS ((bfd *)); +static bfd_boolean som_bfd_is_local_label_name + PARAMS ((bfd *, const char *)); +static bfd_boolean som_set_section_contents + PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type)); +static bfd_boolean som_get_section_contents + PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type)); +static bfd_boolean som_set_arch_mach + PARAMS ((bfd *, enum bfd_architecture, unsigned long)); +static bfd_boolean som_find_nearest_line + PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **, + const char **, unsigned int *)); +static void som_get_symbol_info + PARAMS ((bfd *, asymbol *, symbol_info *)); +static asection * bfd_section_from_som_symbol + PARAMS ((bfd *, struct symbol_dictionary_record *)); +static int log2 + PARAMS ((unsigned int)); +static bfd_reloc_status_type hppa_som_reloc + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +static void som_initialize_reloc_queue + PARAMS ((struct reloc_queue *)); +static void som_reloc_queue_insert + PARAMS ((unsigned char *, unsigned int, struct reloc_queue *)); +static void som_reloc_queue_fix + PARAMS ((struct reloc_queue *, unsigned int)); +static int som_reloc_queue_find + PARAMS ((unsigned char *, unsigned int, struct reloc_queue *)); +static unsigned char * try_prev_fixup + PARAMS ((bfd *, int *, unsigned char *, unsigned int, struct reloc_queue *)); + +static unsigned char * som_reloc_skip + PARAMS ((bfd *, unsigned int, unsigned char *, unsigned int *, + struct reloc_queue *)); +static unsigned char * som_reloc_addend + PARAMS ((bfd *, bfd_vma, unsigned char *, unsigned int *, + struct reloc_queue *)); +static unsigned char * som_reloc_call + PARAMS ((bfd *, unsigned char *, unsigned int *, arelent *, int, + struct reloc_queue *)); +static unsigned long som_count_spaces + PARAMS ((bfd *)); +static unsigned long som_count_subspaces + PARAMS ((bfd *)); +static int compare_syms + PARAMS ((const void *, const void *)); +static int compare_subspaces + PARAMS ((const void *, const void *)); +static unsigned long som_compute_checksum + PARAMS ((bfd *)); +static bfd_boolean som_prep_headers + PARAMS ((bfd *)); +static int som_sizeof_headers + PARAMS ((bfd *, bfd_boolean)); +static bfd_boolean som_finish_writing + PARAMS ((bfd *)); +static bfd_boolean som_build_and_write_symbol_table + PARAMS ((bfd *)); +static void som_prep_for_fixups + PARAMS ((bfd *, asymbol **, unsigned long)); +static bfd_boolean som_write_fixups + PARAMS ((bfd *, unsigned long, unsigned int *)); +static bfd_boolean som_write_space_strings + PARAMS ((bfd *, unsigned long, unsigned int *)); +static bfd_boolean som_write_symbol_strings + PARAMS ((bfd *, unsigned long, asymbol **, unsigned int, unsigned *, + COMPUNIT *)); +static bfd_boolean som_begin_writing + PARAMS ((bfd *)); static reloc_howto_type * som_bfd_reloc_type_lookup - PARAMS ((bfd *, bfd_reloc_code_real_type)); -static char som_section_type PARAMS ((const char *)); -static int som_decode_symclass PARAMS ((asymbol *)); -static boolean som_bfd_count_ar_symbols PARAMS ((bfd *, struct lst_header *, - symindex *)); - -static boolean som_bfd_fill_in_ar_symbols PARAMS ((bfd *, struct lst_header *, - carsym **syms)); -static boolean som_slurp_armap PARAMS ((bfd *)); -static boolean som_write_armap PARAMS ((bfd *, unsigned int, struct orl *, - unsigned int, int)); -static void som_bfd_derive_misc_symbol_info PARAMS ((bfd *, asymbol *, - struct som_misc_symbol_info *)); -static boolean som_bfd_prep_for_ar_write PARAMS ((bfd *, unsigned int *, - unsigned int *)); -static unsigned int som_bfd_ar_symbol_hash PARAMS ((asymbol *)); -static boolean som_bfd_ar_write_symbol_stuff PARAMS ((bfd *, unsigned int, - unsigned int, - struct lst_header, - unsigned int)); -static boolean som_is_space PARAMS ((asection *)); -static boolean som_is_subspace PARAMS ((asection *)); -static boolean som_is_container PARAMS ((asection *, asection *)); -static boolean som_bfd_free_cached_info PARAMS ((bfd *)); -static boolean som_bfd_link_split_section PARAMS ((bfd *, asection *)); + PARAMS ((bfd *, bfd_reloc_code_real_type)); +static char som_section_type + PARAMS ((const char *)); +static int som_decode_symclass + PARAMS ((asymbol *)); +static bfd_boolean som_bfd_count_ar_symbols + PARAMS ((bfd *, struct lst_header *, symindex *)); + +static bfd_boolean som_bfd_fill_in_ar_symbols + PARAMS ((bfd *, struct lst_header *, carsym **syms)); +static bfd_boolean som_slurp_armap + PARAMS ((bfd *)); +static bfd_boolean som_write_armap + PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int)); +static void som_bfd_derive_misc_symbol_info + PARAMS ((bfd *, asymbol *, struct som_misc_symbol_info *)); +static bfd_boolean som_bfd_prep_for_ar_write + PARAMS ((bfd *, unsigned int *, unsigned int *)); +static unsigned int som_bfd_ar_symbol_hash + PARAMS ((asymbol *)); +static bfd_boolean som_bfd_ar_write_symbol_stuff + PARAMS ((bfd *, unsigned int, unsigned int, struct lst_header, + unsigned int)); +static bfd_boolean som_is_space + PARAMS ((asection *)); +static bfd_boolean som_is_subspace + PARAMS ((asection *)); +static bfd_boolean som_is_container + PARAMS ((asection *, asection *)); +static bfd_boolean som_bfd_free_cached_info + PARAMS ((bfd *)); +static bfd_boolean som_bfd_link_split_section + PARAMS ((bfd *, asection *)); /* Map SOM section names to POSIX/BSD single-character symbol types. @@ -778,7 +805,7 @@ static const int comp3_opcodes[] = { #endif #define SOM_HOWTO(TYPE, NAME) \ - HOWTO(TYPE, 0, 0, 32, false, 0, 0, hppa_som_reloc, NAME, false, 0, 0, false) + HOWTO(TYPE, 0, 0, 32, FALSE, 0, 0, hppa_som_reloc, NAME, FALSE, 0, 0, FALSE) static reloc_howto_type som_hppa_howto_table[] = { SOM_HOWTO (R_NO_RELOCATION, "R_NO_RELOCATION"), @@ -1740,7 +1767,7 @@ som_object_setup (abfd, file_hdrp, aux_hdrp, current_offset) int found; /* som_mkobject will set bfd_error if som_mkobject fails. */ - if (som_mkobject (abfd) != true) + if (! som_mkobject (abfd)) return 0; /* Set BFD flags based on what information is available in the SOM. */ @@ -1814,6 +1841,8 @@ som_object_setup (abfd, file_hdrp, aux_hdrp, current_offset) obj_som_exec_data (abfd)->exec_flags = aux_hdrp->exec_flags; } + obj_som_exec_data (abfd)->version_id = file_hdrp->version_id; + bfd_default_set_arch_mach (abfd, bfd_arch_hppa, pa10); bfd_get_symcount (abfd) = file_hdrp->symbol_total; @@ -1840,7 +1869,7 @@ som_object_setup (abfd, file_hdrp, aux_hdrp, current_offset) BFD sections which correspond to spaces will overlap the sections for the associated subspaces. */ -static boolean +static bfd_boolean setup_sections (abfd, file_hdr, current_offset) bfd *abfd; struct header *file_hdr; @@ -1849,7 +1878,8 @@ setup_sections (abfd, file_hdr, current_offset) char *space_strings; unsigned int space_index, i; unsigned int total_subspaces = 0; - asection **subspace_sections, *section; + asection **subspace_sections = NULL; + asection *section; bfd_size_type amt; /* First, read in space names. */ @@ -1902,9 +1932,9 @@ setup_sections (abfd, file_hdr, current_offset) space_asect->flags |= SEC_DEBUGGING; /* Set up all the attributes for the space. */ - if (bfd_som_set_section_attributes (space_asect, space.is_defined, - space.is_private, space.sort_key, - space.space_number) == false) + if (! bfd_som_set_section_attributes (space_asect, space.is_defined, + space.is_private, space.sort_key, + space.space_number)) goto error_return; /* If the space has no subspaces, then we're done. */ @@ -1928,7 +1958,7 @@ setup_sections (abfd, file_hdr, current_offset) goto error_return; /* Setup the start address and file loc from the first subspace - record. */ + record. */ space_asect->vma = subspace.subspace_start; space_asect->filepos = subspace.file_loc_init_value + current_offset; space_asect->alignment_power = log2 (subspace.alignment); @@ -1965,10 +1995,10 @@ setup_sections (abfd, file_hdr, current_offset) goto error_return; /* Store private information about the section. */ - if (bfd_som_set_subsection_attributes (subspace_asect, space_asect, - subspace.access_control_bits, - subspace.sort_key, - subspace.quadrant) == false) + if (! bfd_som_set_subsection_attributes (subspace_asect, space_asect, + subspace.access_control_bits, + subspace.sort_key, + subspace.quadrant)) goto error_return; /* Keep an easy mapping between subspaces and sections. @@ -2063,7 +2093,7 @@ setup_sections (abfd, file_hdr, current_offset) } /* This can happen for a .o which defines symbols in otherwise - empty subspaces. */ + empty subspaces. */ if (!save_subspace.file_loc_init_value) { space_asect->_cooked_size = 0; @@ -2111,7 +2141,7 @@ setup_sections (abfd, file_hdr, current_offset) if (subspace_sections != NULL) free (subspace_sections); - return true; + return TRUE; error_return: if (space_strings != NULL) @@ -2119,7 +2149,7 @@ setup_sections (abfd, file_hdr, current_offset) if (subspace_sections != NULL) free (subspace_sections); - return false; + return FALSE; } /* Read in a SOM object and make it into a BFD. */ @@ -2266,7 +2296,7 @@ som_object_p (abfd) /* Create a SOM object. */ -static boolean +static bfd_boolean som_mkobject (abfd) bfd *abfd; { @@ -2274,15 +2304,15 @@ som_mkobject (abfd) abfd->tdata.som_data = (struct som_data_struct *) bfd_zalloc (abfd, (bfd_size_type) sizeof (struct som_data_struct)); if (abfd->tdata.som_data == NULL) - return false; - return true; + return FALSE; + return TRUE; } /* Initialize some information in the file header. This routine makes not attempt at doing the right thing for a full executable; it is only meant to handle relocatable objects. */ -static boolean +static bfd_boolean som_prep_headers (abfd) bfd *abfd; { @@ -2293,7 +2323,7 @@ som_prep_headers (abfd) /* Make and attach a file header to the BFD. */ file_hdr = (struct header *) bfd_zalloc (abfd, amt); if (file_hdr == NULL) - return false; + return FALSE; obj_som_file_hdr (abfd) = file_hdr; if (abfd->flags & (EXEC_P | DYNAMIC)) @@ -2304,7 +2334,7 @@ som_prep_headers (abfd) obj_som_exec_hdr (abfd) = (struct som_exec_auxhdr *) bfd_zalloc (abfd, amt); if (obj_som_exec_hdr (abfd) == NULL) - return false; + return FALSE; if (abfd->flags & D_PAGED) file_hdr->a_magic = DEMAND_MAGIC; @@ -2320,9 +2350,6 @@ som_prep_headers (abfd) else file_hdr->a_magic = RELOC_MAGIC; - /* Only new format SOM is supported. */ - file_hdr->version_id = NEW_VERSION_ID; - /* These fields are optional, and embedding timestamps is not always a wise thing to do, it makes comparing objects during a multi-stage bootstrap difficult. */ @@ -2351,7 +2378,7 @@ som_prep_headers (abfd) som_section_data (section)->space_dict = (struct space_dictionary_record *) bfd_zalloc (abfd, amt); if (som_section_data (section)->space_dict == NULL) - return false; + return FALSE; /* Set space attributes. Note most attributes of SOM spaces are set based on the subspaces it contains. */ som_section_data (section)->space_dict->loader_fix_index = -1; @@ -2374,7 +2401,7 @@ som_prep_headers (abfd) som_section_data (section)->subspace_dict = (struct subspace_dictionary_record *) bfd_zalloc (abfd, amt); if (som_section_data (section)->subspace_dict == NULL) - return false; + return FALSE; /* Set subspace attributes. Basic stuff is done here, additional attributes are filled in later as more information becomes @@ -2409,58 +2436,58 @@ som_prep_headers (abfd) som_section_data (section)->copy_data->quadrant; } } - return true; + return TRUE; } -/* Return true if the given section is a SOM space, false otherwise. */ +/* Return TRUE if the given section is a SOM space, FALSE otherwise. */ -static boolean +static bfd_boolean som_is_space (section) asection *section; { /* If no copy data is available, then it's neither a space nor a subspace. */ if (som_section_data (section)->copy_data == NULL) - return false; + return FALSE; /* If the containing space isn't the same as the given section, then this isn't a space. */ if (som_section_data (section)->copy_data->container != section && (som_section_data (section)->copy_data->container->output_section != section)) - return false; + return FALSE; /* OK. Must be a space. */ - return true; + return TRUE; } -/* Return true if the given section is a SOM subspace, false otherwise. */ +/* Return TRUE if the given section is a SOM subspace, FALSE otherwise. */ -static boolean +static bfd_boolean som_is_subspace (section) asection *section; { /* If no copy data is available, then it's neither a space nor a subspace. */ if (som_section_data (section)->copy_data == NULL) - return false; + return FALSE; /* If the containing space is the same as the given section, then this isn't a subspace. */ if (som_section_data (section)->copy_data->container == section || (som_section_data (section)->copy_data->container->output_section == section)) - return false; + return FALSE; /* OK. Must be a subspace. */ - return true; + return TRUE; } -/* Return true if the given space containins the given subspace. It +/* Return TRUE if the given space containins the given subspace. It is safe to assume space really is a space, and subspace really is a subspace. */ -static boolean +static bfd_boolean som_is_container (space, subspace) asection *space, *subspace; { @@ -2658,7 +2685,7 @@ som_prep_for_fixups (abfd, syms, num_syms) } } -static boolean +static bfd_boolean som_write_fixups (abfd, current_offset, total_reloc_sizep) bfd *abfd; unsigned long current_offset; @@ -2728,7 +2755,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep) for this subspace in preparation for writing out its fixup stream. */ if (bfd_seek (abfd, current_offset + total_reloc_size, SEEK_SET) != 0) - return false; + return FALSE; /* Buffer space has already been allocated. Just perform some initialization here. */ @@ -2767,7 +2794,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep) { amt = p - tmp_space; if (bfd_bwrite ((PTR) tmp_space, amt, abfd) != amt) - return false; + return FALSE; p = tmp_space; som_initialize_reloc_queue (reloc_queue); @@ -2961,7 +2988,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep) break; case R_END_TRY: - /* The end of a exception handling region. The reloc's + /* The end of an exception handling region. The reloc's addend contains the offset of the exception handling code. */ if (bfd_reloc->addend == 0) @@ -3028,14 +3055,14 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep) /* Last BFD relocation for a subspace has been processed. Map the rest of the subspace with R_NO_RELOCATION fixups. */ - p = som_reloc_skip (abfd, bfd_section_size (abfd, subsection) - - reloc_offset, + p = som_reloc_skip (abfd, (bfd_section_size (abfd, subsection) + - reloc_offset), p, &subspace_reloc_size, reloc_queue); /* Scribble out the relocations. */ amt = p - tmp_space; if (bfd_bwrite ((PTR) tmp_space, amt, abfd) != amt) - return false; + return FALSE; p = tmp_space; total_reloc_size += subspace_reloc_size; @@ -3045,12 +3072,12 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep) section = section->next; } *total_reloc_sizep = total_reloc_size; - return true; + return TRUE; } /* Write out the space/subspace string table. */ -static boolean +static bfd_boolean som_write_space_strings (abfd, current_offset, string_sizep) bfd *abfd; unsigned long current_offset; @@ -3068,7 +3095,7 @@ som_write_space_strings (abfd, current_offset, string_sizep) /* Seek to the start of the space strings in preparation for writing them out. */ if (bfd_seek (abfd, (file_ptr) current_offset, SEEK_SET) != 0) - return false; + return FALSE; /* Walk through all the spaces and subspaces (order is not important) building up and writing string table entries for their names. */ @@ -3085,27 +3112,27 @@ som_write_space_strings (abfd, current_offset, string_sizep) length = strlen (section->name); /* If there is not enough room for the next entry, then dump the - current buffer contents now and maybe allocate a larger - buffer. Each entry will take 4 bytes to hold the string - length + the string itself + null terminator. */ + current buffer contents now and maybe allocate a larger + buffer. Each entry will take 4 bytes to hold the string + length + the string itself + null terminator. */ if (p - tmp_space + 5 + length > tmp_space_size) { /* Flush buffer before refilling or reallocating. */ amt = p - tmp_space; if (bfd_bwrite ((PTR) &tmp_space[0], amt, abfd) != amt) - return false; + return FALSE; /* Reallocate if now empty buffer still too small. */ if (5 + length > tmp_space_size) { /* Ensure a minimum growth factor to avoid O(n**2) space - consumption for n strings. The optimal minimum - factor seems to be 2, as no other value can guarantee - wasting less then 50% space. (Note that we cannot - deallocate space allocated by `alloca' without - returning from this function.) The same technique is - used a few more times below when a buffer is - reallocated. */ + consumption for n strings. The optimal minimum + factor seems to be 2, as no other value can guarantee + wasting less than 50% space. (Note that we cannot + deallocate space allocated by `alloca' without + returning from this function.) The same technique is + used a few more times below when a buffer is + reallocated. */ tmp_space_size = MAX (2 * tmp_space_size, 5 + length); tmp_space = alloca (tmp_space_size); } @@ -3144,18 +3171,18 @@ som_write_space_strings (abfd, current_offset, string_sizep) contained in a partial block. */ amt = p - tmp_space; if (bfd_bwrite ((PTR) &tmp_space[0], amt, abfd) != amt) - return false; + return FALSE; *string_sizep = strings_size; - return true; + return TRUE; } /* Write out the symbol string table. */ -static boolean +static bfd_boolean som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep, compilation_unit) bfd *abfd; - file_ptr current_offset; + unsigned long current_offset; asymbol **syms; unsigned int num_syms; unsigned int *string_sizep; @@ -3189,8 +3216,8 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep, /* Seek to the start of the space strings in preparation for writing them out. */ - if (bfd_seek (abfd, current_offset, SEEK_SET) != 0) - return false; + if (bfd_seek (abfd, (file_ptr) current_offset, SEEK_SET) != 0) + return FALSE; if (compilation_unit) { @@ -3206,7 +3233,7 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep, /* Flush buffer before refilling or reallocating. */ amt = p - tmp_space; if (bfd_bwrite ((PTR) &tmp_space[0], amt, abfd) != amt) - return false; + return FALSE; /* Reallocate if now empty buffer still too small. */ if (5 + length > tmp_space_size) @@ -3217,7 +3244,7 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep, } /* Reset to beginning of the (possibly new) buffer - space. */ + space. */ p = tmp_space; } @@ -3275,7 +3302,7 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep, /* Flush buffer before refilling or reallocating. */ amt = p - tmp_space; if (bfd_bwrite ((PTR) &tmp_space[0], amt, abfd) != amt) - return false; + return FALSE; /* Reallocate if now empty buffer still too small. */ if (5 + length > tmp_space_size) @@ -3316,17 +3343,17 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep, /* Scribble out any partial block. */ amt = p - tmp_space; if (bfd_bwrite ((PTR) &tmp_space[0], amt, abfd) != amt) - return false; + return FALSE; *string_sizep = strings_size; - return true; + return TRUE; } /* Compute variable information to be placed in the SOM headers, space/subspace dictionaries, relocation streams, etc. Begin writing parts of the object file. */ -static boolean +static bfd_boolean som_begin_writing (abfd) bfd *abfd; { @@ -3372,14 +3399,14 @@ som_begin_writing (abfd) bfd_size_type len; if (bfd_seek (abfd, (file_ptr) current_offset, SEEK_SET) != 0) - return false; + return FALSE; /* Write the aux_id structure and the string length. */ len = sizeof (struct aux_id) + sizeof (unsigned int); obj_som_file_hdr (abfd)->aux_header_size += len; current_offset += len; if (bfd_bwrite ((PTR) obj_som_version_hdr (abfd), len, abfd) != len) - return false; + return FALSE; /* Write the version string. */ len = obj_som_version_hdr (abfd)->header_id.length - sizeof (int); @@ -3387,7 +3414,7 @@ som_begin_writing (abfd) current_offset += len; if (bfd_bwrite ((PTR) obj_som_version_hdr (abfd)->user_string, len, abfd) != len) - return false; + return FALSE; } if (obj_som_copyright_hdr (abfd) != NULL) @@ -3395,14 +3422,14 @@ som_begin_writing (abfd) bfd_size_type len; if (bfd_seek (abfd, (file_ptr) current_offset, SEEK_SET) != 0) - return false; + return FALSE; /* Write the aux_id structure and the string length. */ len = sizeof (struct aux_id) + sizeof (unsigned int); obj_som_file_hdr (abfd)->aux_header_size += len; current_offset += len; if (bfd_bwrite ((PTR) obj_som_copyright_hdr (abfd), len, abfd) != len) - return false; + return FALSE; /* Write the copyright string. */ len = obj_som_copyright_hdr (abfd)->header_id.length - sizeof (int); @@ -3410,7 +3437,7 @@ som_begin_writing (abfd) current_offset += len; if (bfd_bwrite ((PTR) obj_som_copyright_hdr (abfd)->copyright, len, abfd) != len) - return false; + return FALSE; } /* Next comes the initialization pointers; we have no initialization @@ -3457,8 +3484,8 @@ som_begin_writing (abfd) obj_som_file_hdr (abfd)->space_strings_location = current_offset; /* Scribble out the space strings. */ - if (som_write_space_strings (abfd, current_offset, &strings_size) == false) - return false; + if (! som_write_space_strings (abfd, current_offset, &strings_size)) + return FALSE; /* Record total string table size in the header and update the current offset. */ @@ -3655,9 +3682,9 @@ som_begin_writing (abfd) if (abfd->flags & (EXEC_P | DYNAMIC)) current_offset = SOM_ALIGN (current_offset, PA_PAGESIZE); if (bfd_seek (abfd, (file_ptr) current_offset - 1, SEEK_SET) != 0) - return false; + return FALSE; if (bfd_bwrite ((PTR) "", (bfd_size_type) 1, abfd) != 1) - return false; + return FALSE; obj_som_file_hdr (abfd)->unloadable_sp_size = current_offset - obj_som_file_hdr (abfd)->unloadable_sp_location; @@ -3669,12 +3696,12 @@ som_begin_writing (abfd) /* Done. Store the total size of the SOM so far. */ obj_som_file_hdr (abfd)->som_length = current_offset; - return true; + return TRUE; } /* Finally, scribble out the various headers to the disk. */ -static boolean +static bfd_boolean som_finish_writing (abfd) bfd *abfd; { @@ -3688,6 +3715,14 @@ som_finish_writing (abfd) unsigned int total_reloc_size; bfd_size_type amt; + /* We must set up the version identifier here as objcopy/strip copy + private BFD data too late for us to handle this in som_begin_writing. */ + if (obj_som_exec_data (abfd) + && obj_som_exec_data (abfd)->version_id) + obj_som_file_hdr (abfd)->version_id = obj_som_exec_data (abfd)->version_id; + else + obj_som_file_hdr (abfd)->version_id = NEW_VERSION_ID; + /* Next is the symbol table. These are fixed length records. Count the number of symbols to determine how much room is needed @@ -3719,11 +3754,10 @@ som_finish_writing (abfd) obj_som_file_hdr (abfd)->symbol_strings_location = current_offset; /* Scribble out the symbol strings. */ - if (som_write_symbol_strings (abfd, current_offset, syms, - num_syms, &strings_size, - obj_som_compilation_unit (abfd)) - == false) - return false; + if (! som_write_symbol_strings (abfd, current_offset, syms, + num_syms, &strings_size, + obj_som_compilation_unit (abfd))) + return FALSE; /* Record total string table size in header and update the current offset. */ @@ -3743,8 +3777,8 @@ som_finish_writing (abfd) /* Write the fixups and update fields in subspace headers which relate to the fixup stream. */ - if (som_write_fixups (abfd, current_offset, &total_reloc_size) == false) - return false; + if (! som_write_fixups (abfd, current_offset, &total_reloc_size)) + return FALSE; /* Record the total size of the fixup stream in the file header. */ obj_som_file_hdr (abfd)->fixup_request_total = total_reloc_size; @@ -3754,8 +3788,8 @@ som_finish_writing (abfd) /* Now that the symbol table information is complete, build and write the symbol table. */ - if (som_build_and_write_symbol_table (abfd) == false) - return false; + if (! som_build_and_write_symbol_table (abfd)) + return FALSE; /* Subspaces are written first so that we can set up information about them in their containing spaces as the subspace is written. */ @@ -3763,7 +3797,7 @@ som_finish_writing (abfd) /* Seek to the start of the subspace dictionary records. */ location = obj_som_file_hdr (abfd)->subspace_location; if (bfd_seek (abfd, location, SEEK_SET) != 0) - return false; + return FALSE; section = abfd->sections; /* Now for each loadable space write out records for its subspaces. */ @@ -3813,7 +3847,7 @@ som_finish_writing (abfd) amt = sizeof (struct subspace_dictionary_record); if (bfd_bwrite ((PTR) som_section_data (subsection)->subspace_dict, amt, abfd) != amt) - return false; + return FALSE; } /* Goto the next section. */ section = section->next; @@ -3869,7 +3903,7 @@ som_finish_writing (abfd) amt = sizeof (struct subspace_dictionary_record); if (bfd_bwrite ((PTR) som_section_data (subsection)->subspace_dict, amt, abfd) != amt) - return false; + return FALSE; } /* Goto the next section. */ section = section->next; @@ -3882,7 +3916,7 @@ som_finish_writing (abfd) dictionary records. */ location = obj_som_file_hdr (abfd)->space_location; if (bfd_seek (abfd, location, SEEK_SET) != 0) - return false; + return FALSE; section = abfd->sections; for (i = 0; i < num_spaces; i++) @@ -3895,7 +3929,7 @@ som_finish_writing (abfd) amt = sizeof (struct space_dictionary_record); if (bfd_bwrite ((PTR) som_section_data (section)->space_dict, amt, abfd) != amt) - return false; + return FALSE; /* Goto the next section. */ section = section->next; @@ -3906,11 +3940,11 @@ som_finish_writing (abfd) { location = obj_som_file_hdr (abfd)->compiler_location; if (bfd_seek (abfd, location, SEEK_SET) != 0) - return false; + return FALSE; amt = COMPUNITSZ; if (bfd_bwrite ((PTR) obj_som_compilation_unit (abfd), amt, abfd) != amt) - return false; + return FALSE; } /* Setting of the system_id has to happen very late now that copying of @@ -3931,10 +3965,10 @@ som_finish_writing (abfd) /* Only thing left to do is write out the file header. It is always at location zero. Seek there and write it. */ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) - return false; + return FALSE; amt = sizeof (struct header); if (bfd_bwrite ((PTR) obj_som_file_hdr (abfd), amt, abfd) != amt) - return false; + return FALSE; /* Now write the exec header. */ if (abfd->flags & (EXEC_P | DYNAMIC)) @@ -3963,18 +3997,18 @@ som_finish_writing (abfd) || exec_header->exec_dfile + exec_header->exec_dsize > som_length) { bfd_set_error (bfd_error_bad_value); - return false; + return FALSE; } if (bfd_seek (abfd, obj_som_file_hdr (abfd)->aux_header_location, SEEK_SET) != 0) - return false; + return FALSE; amt = AUX_HDR_SIZE; if (bfd_bwrite ((PTR) exec_header, amt, abfd) != amt) - return false; + return FALSE; } - return true; + return TRUE; } /* Compute and return the checksum for a SOM file header. */ @@ -4109,16 +4143,16 @@ som_bfd_derive_misc_symbol_info (abfd, sym, info) /* The secondary_def field is for weak symbols. */ if (sym->flags & BSF_WEAK) - info->secondary_def = true; + info->secondary_def = TRUE; else - info->secondary_def = false; + info->secondary_def = FALSE; } /* Build and write, in one big chunk, the entire symbol table for this BFD. */ -static boolean +static bfd_boolean som_build_and_write_symbol_table (abfd) bfd *abfd; { @@ -4133,10 +4167,9 @@ som_build_and_write_symbol_table (abfd) to hold the symbol table as we build it. */ symtab_size = num_syms; symtab_size *= sizeof (struct symbol_dictionary_record); - som_symtab = (struct symbol_dictionary_record *) bfd_malloc (symtab_size); + som_symtab = (struct symbol_dictionary_record *) bfd_zmalloc (symtab_size); if (som_symtab == NULL && symtab_size != 0) goto error_return; - memset (som_symtab, 0, (size_t) symtab_size); /* Walk over each symbol. */ for (i = 0; i < num_syms; i++) @@ -4164,32 +4197,32 @@ som_build_and_write_symbol_table (abfd) /* Everything is ready, seek to the right location and scribble out the symbol table. */ if (bfd_seek (abfd, symtab_location, SEEK_SET) != 0) - return false; + return FALSE; if (bfd_bwrite ((PTR) som_symtab, symtab_size, abfd) != symtab_size) goto error_return; if (som_symtab != NULL) free (som_symtab); - return true; + return TRUE; error_return: if (som_symtab != NULL) free (som_symtab); - return false; + return FALSE; } /* Write an object in SOM format. */ -static boolean +static bfd_boolean som_write_object_contents (abfd) bfd *abfd; { - if (abfd->output_has_begun == false) + if (! abfd->output_has_begun) { /* Set up fixed parts of the file, space, and subspace headers. Notify the world that output has begun. */ som_prep_headers (abfd); - abfd->output_has_begun = true; + abfd->output_has_begun = TRUE; /* Start writing the object file. This include all the string tables, fixup streams, and other portions of the object file. */ som_begin_writing (abfd); @@ -4200,7 +4233,7 @@ som_write_object_contents (abfd) /* Read and save the string table associated with the given BFD. */ -static boolean +static bfd_boolean som_slurp_string_table (abfd) bfd *abfd; { @@ -4209,7 +4242,7 @@ som_slurp_string_table (abfd) /* Use the saved version if its available. */ if (obj_som_stringtab (abfd) != NULL) - return true; + return TRUE; /* I don't think this can currently happen, and I'm not sure it should really be an error, but it's better than getting unpredictable results @@ -4217,25 +4250,24 @@ som_slurp_string_table (abfd) if (obj_som_stringtab_size (abfd) == 0) { bfd_set_error (bfd_error_no_symbols); - return false; + return FALSE; } /* Allocate and read in the string table. */ amt = obj_som_stringtab_size (abfd); - stringtab = bfd_malloc (amt); + stringtab = bfd_zmalloc (amt); if (stringtab == NULL) - return false; - memset (stringtab, 0, obj_som_stringtab_size (abfd)); + return FALSE; if (bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET) != 0) - return false; + return FALSE; if (bfd_bread (stringtab, amt, abfd) != amt) - return false; + return FALSE; /* Save our results and return success. */ obj_som_stringtab (abfd) = stringtab; - return true; + return TRUE; } /* Return the amount of data (in bytes) required to hold the symbol @@ -4328,10 +4360,9 @@ som_slurp_symbol_table (abfd) amt = symbol_count; amt *= sizeof (som_symbol_type); - symbase = (som_symbol_type *) bfd_malloc (amt); + symbase = (som_symbol_type *) bfd_zmalloc (amt); if (symbase == NULL) goto error_return; - memset (symbase, 0, symbol_count * sizeof (som_symbol_type)); /* Read in the external SOM representation. */ amt = symbol_count; @@ -4467,7 +4498,7 @@ som_slurp_symbol_table (abfd) sym->symbol.flags |= BSF_DEBUGGING; /* Note increment at bottom of loop, since we skip some symbols - we can not include it as part of the for statement. */ + we can not include it as part of the for statement. */ sym++; } @@ -4480,12 +4511,12 @@ som_slurp_symbol_table (abfd) successful_return: if (buf != NULL) free (buf); - return (true); + return (TRUE); error_return: if (buf != NULL) free (buf); - return false; + return FALSE; } /* Canonicalize a SOM symbol table. Return the number of entries @@ -4559,7 +4590,7 @@ som_print_symbol (abfd, afile, symbol, how) } } -static boolean +static bfd_boolean som_bfd_is_local_label_name (abfd, name) bfd *abfd ATTRIBUTE_UNUSED; const char *name; @@ -4587,7 +4618,7 @@ som_set_reloc_info (fixup, end, internal_relocs, section, symbols, just_count) arelent *internal_relocs; asection *section; asymbol **symbols; - boolean just_count; + bfd_boolean just_count; { unsigned int op, varname, deallocate_contents = 0; unsigned char *end_fixups = &fixup[end]; @@ -4672,13 +4703,13 @@ som_set_reloc_info (fixup, end, internal_relocs, section, symbols, just_count) c = *cp++; /* If this is a variable, push it on the stack. */ - if (isupper (c)) + if (ISUPPER (c)) push (var (c)); /* If this is a lower case letter, then it represents additional data from the fixup stream to be pushed onto the stack. */ - else if (islower (c)) + else if (ISLOWER (c)) { int bits = (c - 'a') * 8; for (v = 0; c > 'a'; --c) @@ -4689,10 +4720,10 @@ som_set_reloc_info (fixup, end, internal_relocs, section, symbols, just_count) } /* A decimal constant. Push it on the stack. */ - else if (isdigit (c)) + else if (ISDIGIT (c)) { v = c - '0'; - while (isdigit (*cp)) + while (ISDIGIT (*cp)) v = (v * 10) + (*cp++ - '0'); push (v); } @@ -4877,7 +4908,7 @@ som_set_reloc_info (fixup, end, internal_relocs, section, symbols, just_count) if (rptr->addend == 0 && !section->contents) { /* Got to read the damn contents first. We don't - bother saving the contents (yet). Add it one + bother saving the contents (yet). Add it one day if the need arises. */ section->contents = bfd_malloc (section->_raw_size); if (section->contents == NULL) @@ -4921,15 +4952,15 @@ som_set_reloc_info (fixup, end, internal_relocs, section, symbols, just_count) /* Read in the relocs (aka fixups in SOM terms) for a section. som_get_reloc_upper_bound calls this routine with JUST_COUNT - set to true to indicate it only needs a count of the number + set to TRUE to indicate it only needs a count of the number of actual relocations. */ -static boolean +static bfd_boolean som_slurp_reloc_table (abfd, section, symbols, just_count) bfd *abfd; asection *section; asymbol **symbols; - boolean just_count; + bfd_boolean just_count; { char *external_relocs; unsigned int fixup_stream_size; @@ -4940,7 +4971,7 @@ som_slurp_reloc_table (abfd, section, symbols, just_count) fixup_stream_size = som_section_data (section)->reloc_size; /* If there were no relocations, then there is nothing to do. */ if (section->reloc_count == 0) - return true; + return TRUE; /* If reloc_count is -1, then the relocation stream has not been parsed. We must do so now to know how many relocations exist. */ @@ -4949,45 +4980,45 @@ som_slurp_reloc_table (abfd, section, symbols, just_count) amt = fixup_stream_size; external_relocs = (char *) bfd_malloc (amt); if (external_relocs == (char *) NULL) - return false; + return FALSE; /* Read in the external forms. */ if (bfd_seek (abfd, obj_som_reloc_filepos (abfd) + section->rel_filepos, SEEK_SET) != 0) - return false; + return FALSE; if (bfd_bread (external_relocs, amt, abfd) != amt) - return false; + return FALSE; /* Let callers know how many relocations found. also save the relocation stream as we will need it again. */ section->reloc_count = som_set_reloc_info (external_relocs, fixup_stream_size, - NULL, NULL, NULL, true); + NULL, NULL, NULL, TRUE); som_section_data (section)->reloc_stream = external_relocs; } /* If the caller only wanted a count, then return now. */ if (just_count) - return true; + return TRUE; num_relocs = section->reloc_count; external_relocs = som_section_data (section)->reloc_stream; /* Return saved information about the relocations if it is available. */ if (section->relocation != (arelent *) NULL) - return true; + return TRUE; amt = num_relocs; amt *= sizeof (arelent); internal_relocs = (arelent *) bfd_zalloc (abfd, (amt)); if (internal_relocs == (arelent *) NULL) - return false; + return FALSE; /* Process and internalize the relocations. */ som_set_reloc_info (external_relocs, fixup_stream_size, - internal_relocs, section, symbols, false); + internal_relocs, section, symbols, FALSE); /* We're done with the external relocations. Free them. */ free (external_relocs); @@ -4995,7 +5026,7 @@ som_slurp_reloc_table (abfd, section, symbols, just_count) /* Save our results and return success. */ section->relocation = internal_relocs; - return (true); + return TRUE; } /* Return the number of bytes required to store the relocation @@ -5010,7 +5041,7 @@ som_get_reloc_upper_bound (abfd, asect) and parse it to determine how many relocations exist. */ if (asect->flags & SEC_RELOC) { - if (! som_slurp_reloc_table (abfd, asect, NULL, true)) + if (! som_slurp_reloc_table (abfd, asect, NULL, TRUE)) return -1; return (asect->reloc_count + 1) * sizeof (arelent *); } @@ -5031,7 +5062,7 @@ som_canonicalize_reloc (abfd, section, relptr, symbols) arelent *tblptr; int count; - if (som_slurp_reloc_table (abfd, section, symbols, false) == false) + if (! som_slurp_reloc_table (abfd, section, symbols, FALSE)) return -1; count = section->reloc_count; @@ -5048,7 +5079,7 @@ extern const bfd_target som_vec; /* A hook to set up object file dependent section information. */ -static boolean +static bfd_boolean som_new_section_hook (abfd, newsect) bfd *abfd; asection *newsect; @@ -5056,17 +5087,17 @@ som_new_section_hook (abfd, newsect) bfd_size_type amt = sizeof (struct som_section_data_struct); newsect->used_by_bfd = (PTR) bfd_zalloc (abfd, amt); if (!newsect->used_by_bfd) - return false; + return FALSE; newsect->alignment_power = 3; /* We allow more than three sections internally. */ - return true; + return TRUE; } /* Copy any private info we understand from the input symbol to the output symbol. */ -static boolean +static bfd_boolean som_bfd_copy_private_symbol_data (ibfd, isymbol, obfd, osymbol) bfd *ibfd; asymbol *isymbol; @@ -5079,20 +5110,20 @@ som_bfd_copy_private_symbol_data (ibfd, isymbol, obfd, osymbol) /* One day we may try to grok other private data. */ if (ibfd->xvec->flavour != bfd_target_som_flavour || obfd->xvec->flavour != bfd_target_som_flavour) - return false; + return FALSE; /* The only private information we need to copy is the argument relocation bits. */ output_symbol->tc_data.ap.hppa_arg_reloc = input_symbol->tc_data.ap.hppa_arg_reloc; - return true; + return TRUE; } /* Copy any private info we understand from the input section to the output section. */ -static boolean +static bfd_boolean som_bfd_copy_private_section_data (ibfd, isection, obfd, osection) bfd *ibfd; asection *isection; @@ -5105,13 +5136,13 @@ som_bfd_copy_private_section_data (ibfd, isection, obfd, osection) if (ibfd->xvec->flavour != bfd_target_som_flavour || obfd->xvec->flavour != bfd_target_som_flavour || (!som_is_space (isection) && !som_is_subspace (isection))) - return true; + return TRUE; amt = sizeof (struct som_copyable_section_data_struct); som_section_data (osection)->copy_data = (struct som_copyable_section_data_struct *) bfd_zalloc (obfd, amt); if (som_section_data (osection)->copy_data == NULL) - return false; + return FALSE; memcpy (som_section_data (osection)->copy_data, som_section_data (isection)->copy_data, @@ -5122,38 +5153,38 @@ som_bfd_copy_private_section_data (ibfd, isection, obfd, osection) som_section_data (osection)->copy_data->container = som_section_data (osection)->copy_data->container->output_section; - return true; + return TRUE; } /* Copy any private info we understand from the input bfd to the output bfd. */ -static boolean +static bfd_boolean som_bfd_copy_private_bfd_data (ibfd, obfd) bfd *ibfd, *obfd; { /* One day we may try to grok other private data. */ if (ibfd->xvec->flavour != bfd_target_som_flavour || obfd->xvec->flavour != bfd_target_som_flavour) - return true; + return TRUE; /* Allocate some memory to hold the data we need. */ obj_som_exec_data (obfd) = (struct som_exec_data *) bfd_zalloc (obfd, (bfd_size_type) sizeof (struct som_exec_data)); if (obj_som_exec_data (obfd) == NULL) - return false; + return FALSE; /* Now copy the data. */ memcpy (obj_som_exec_data (obfd), obj_som_exec_data (ibfd), sizeof (struct som_exec_data)); - return true; + return TRUE; } /* Set backend info for sections which can not be described in the BFD data structures. */ -boolean +bfd_boolean bfd_som_set_section_attributes (section, defined, private, sort_key, spnum) asection *section; int defined; @@ -5169,20 +5200,20 @@ bfd_som_set_section_attributes (section, defined, private, sort_key, spnum) (struct som_copyable_section_data_struct *) bfd_zalloc (section->owner, amt); if (som_section_data (section)->copy_data == NULL) - return false; + return FALSE; } som_section_data (section)->copy_data->sort_key = sort_key; som_section_data (section)->copy_data->is_defined = defined; som_section_data (section)->copy_data->is_private = private; som_section_data (section)->copy_data->container = section; som_section_data (section)->copy_data->space_number = spnum; - return true; + return TRUE; } /* Set backend info for subsections which can not be described in the BFD data structures. */ -boolean +bfd_boolean bfd_som_set_subsection_attributes (section, container, access, sort_key, quadrant) asection *section; @@ -5199,13 +5230,13 @@ bfd_som_set_subsection_attributes (section, container, access, (struct som_copyable_section_data_struct *) bfd_zalloc (section->owner, amt); if (som_section_data (section)->copy_data == NULL) - return false; + return FALSE; } som_section_data (section)->copy_data->sort_key = sort_key; som_section_data (section)->copy_data->access_control_bits = access; som_section_data (section)->copy_data->quadrant = quadrant; som_section_data (section)->copy_data->container = container; - return true; + return TRUE; } /* Set the full SOM symbol type. SOM needs far more symbol information @@ -5225,7 +5256,7 @@ bfd_som_set_symbol_type (symbol, type) /* Attach an auxiliary header to the BFD backend so that it may be written into the object file. */ -boolean +bfd_boolean bfd_som_attach_aux_hdr (abfd, type, string) bfd *abfd; int type; @@ -5244,7 +5275,7 @@ bfd_som_attach_aux_hdr (abfd, type, string) obj_som_version_hdr (abfd) = (struct user_string_aux_hdr *) bfd_zalloc (abfd, amt); if (!obj_som_version_hdr (abfd)) - return false; + return FALSE; obj_som_version_hdr (abfd)->header_id.type = VERSION_AUX_ID; obj_som_version_hdr (abfd)->header_id.length = len + pad; obj_som_version_hdr (abfd)->header_id.length += sizeof (int); @@ -5262,20 +5293,20 @@ bfd_som_attach_aux_hdr (abfd, type, string) obj_som_copyright_hdr (abfd) = (struct copyright_aux_hdr *) bfd_zalloc (abfd, amt); if (!obj_som_copyright_hdr (abfd)) - return false; + return FALSE; obj_som_copyright_hdr (abfd)->header_id.type = COPYRIGHT_AUX_ID; obj_som_copyright_hdr (abfd)->header_id.length = len + pad; obj_som_copyright_hdr (abfd)->header_id.length += sizeof (int); obj_som_copyright_hdr (abfd)->string_length = len; strcpy (obj_som_copyright_hdr (abfd)->copyright, string); } - return true; + return TRUE; } /* Attach an compilation unit header to the BFD backend so that it may be written into the object file. */ -boolean +bfd_boolean bfd_som_attach_compilation_unit (abfd, name, language_name, product_id, version_id) bfd *abfd; @@ -5286,14 +5317,14 @@ bfd_som_attach_compilation_unit (abfd, name, language_name, product_id, { COMPUNIT *n = (COMPUNIT *) bfd_zalloc (abfd, (bfd_size_type) COMPUNITSZ); if (n == NULL) - return false; + return FALSE; #define STRDUP(f) \ if (f != NULL) \ { \ n->f.n_name = bfd_alloc (abfd, (bfd_size_type) strlen (f) + 1); \ if (n->f.n_name == NULL) \ - return false; \ + return FALSE; \ strcpy (n->f.n_name, f); \ } @@ -5306,10 +5337,10 @@ bfd_som_attach_compilation_unit (abfd, name, language_name, product_id, obj_som_compilation_unit (abfd) = n; - return true; + return TRUE; } -static boolean +static bfd_boolean som_get_section_contents (abfd, section, location, offset, count) bfd *abfd; sec_ptr section; @@ -5318,15 +5349,15 @@ som_get_section_contents (abfd, section, location, offset, count) bfd_size_type count; { if (count == 0 || ((section->flags & SEC_HAS_CONTENTS) == 0)) - return true; + return TRUE; if ((bfd_size_type) (offset+count) > section->_raw_size || bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0 || bfd_bread (location, count, abfd) != count) - return (false); /* on error */ - return (true); + return FALSE; /* on error */ + return TRUE; } -static boolean +static bfd_boolean som_set_section_contents (abfd, section, location, offset, count) bfd *abfd; sec_ptr section; @@ -5334,12 +5365,12 @@ som_set_section_contents (abfd, section, location, offset, count) file_ptr offset; bfd_size_type count; { - if (abfd->output_has_begun == false) + if (! abfd->output_has_begun) { /* Set up fixed parts of the file, space, and subspace headers. Notify the world that output has begun. */ som_prep_headers (abfd); - abfd->output_has_begun = true; + abfd->output_has_begun = TRUE; /* Start writing the object file. This include all the string tables, fixup streams, and other portions of the object file. */ som_begin_writing (abfd); @@ -5349,20 +5380,20 @@ som_set_section_contents (abfd, section, location, offset, count) are not generated at run time by the OS). */ if (!som_is_subspace (section) || ((section->flags & SEC_HAS_CONTENTS) == 0)) - return true; + return TRUE; /* Seek to the proper offset within the object file and write the data. */ offset += som_section_data (section)->subspace_dict->file_loc_init_value; if (bfd_seek (abfd, offset, SEEK_SET) != 0) - return false; + return FALSE; if (bfd_bwrite ((PTR) location, count, abfd) != count) - return false; - return true; + return FALSE; + return TRUE; } -static boolean +static bfd_boolean som_set_arch_mach (abfd, arch, machine) bfd *abfd; enum bfd_architecture arch; @@ -5372,7 +5403,7 @@ som_set_arch_mach (abfd, arch, machine) return bfd_default_set_arch_mach (abfd, arch, machine); } -static boolean +static bfd_boolean som_find_nearest_line (abfd, section, symbols, offset, filename_ptr, functionname_ptr, line_ptr) bfd *abfd ATTRIBUTE_UNUSED; @@ -5383,18 +5414,18 @@ som_find_nearest_line (abfd, section, symbols, offset, filename_ptr, const char **functionname_ptr ATTRIBUTE_UNUSED; unsigned int *line_ptr ATTRIBUTE_UNUSED; { - return (false); + return FALSE; } static int som_sizeof_headers (abfd, reloc) bfd *abfd ATTRIBUTE_UNUSED; - boolean reloc ATTRIBUTE_UNUSED; + bfd_boolean reloc ATTRIBUTE_UNUSED; { (*_bfd_error_handler) (_("som_sizeof_headers unimplemented")); fflush (stderr); abort (); - return (0); + return 0; } /* Return the single-character symbol type corresponding to @@ -5438,7 +5469,7 @@ som_decode_symclass (symbol) else return '?'; if (symbol->flags & BSF_GLOBAL) - c = toupper (c); + c = TOUPPER (c); return c; } @@ -5461,7 +5492,7 @@ som_get_symbol_info (ignore_abfd, symbol, ret) /* Count the number of symbols in the archive symbol table. Necessary so that we can allocate space for all the carsyms at once. */ -static boolean +static bfd_boolean som_bfd_count_ar_symbols (abfd, lst_header, count) bfd *abfd; struct lst_header *lst_header; @@ -5526,18 +5557,18 @@ som_bfd_count_ar_symbols (abfd, lst_header, count) } if (hash_table != NULL) free (hash_table); - return true; + return TRUE; error_return: if (hash_table != NULL) free (hash_table); - return false; + return FALSE; } /* Fill in the canonical archive symbols (SYMS) from the archive described by ABFD and LST_HEADER. */ -static boolean +static bfd_boolean som_bfd_fill_in_ar_symbols (abfd, lst_header, syms) bfd *abfd; struct lst_header *lst_header; @@ -5667,19 +5698,19 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms) free (hash_table); if (som_dict != NULL) free (som_dict); - return true; + return TRUE; error_return: if (hash_table != NULL) free (hash_table); if (som_dict != NULL) free (som_dict); - return false; + return FALSE; } /* Read in the LST from the archive. */ -static boolean +static bfd_boolean som_slurp_armap (abfd) bfd *abfd; { @@ -5693,29 +5724,29 @@ som_slurp_armap (abfd) /* Special cases. */ if (i == 0) - return true; + return TRUE; if (i != 16) - return false; + return FALSE; if (bfd_seek (abfd, (file_ptr) -16, SEEK_CUR) != 0) - return false; + return FALSE; /* For archives without .o files there is no symbol table. */ if (strncmp (nextname, "/ ", 16)) { - bfd_has_map (abfd) = false; - return true; + bfd_has_map (abfd) = FALSE; + return TRUE; } /* Read in and sanity check the archive header. */ amt = sizeof (struct ar_hdr); if (bfd_bread ((PTR) &ar_header, amt, abfd) != amt) - return false; + return FALSE; if (strncmp (ar_header.ar_fmag, ARFMAG, 2)) { bfd_set_error (bfd_error_malformed_archive); - return false; + return FALSE; } /* How big is the archive symbol table entry? */ @@ -5724,7 +5755,7 @@ som_slurp_armap (abfd) if (errno != 0) { bfd_set_error (bfd_error_malformed_archive); - return false; + return FALSE; } /* Save off the file offset of the first real user data. */ @@ -5734,24 +5765,23 @@ som_slurp_armap (abfd) in just a minute. */ amt = sizeof (struct lst_header); if (bfd_bread ((PTR) &lst_header, amt, abfd) != amt) - return false; + return FALSE; /* Sanity check. */ if (lst_header.a_magic != LIBMAGIC) { bfd_set_error (bfd_error_malformed_archive); - return false; + return FALSE; } /* Count the number of symbols in the library symbol table. */ - if (som_bfd_count_ar_symbols (abfd, &lst_header, &ardata->symdef_count) - == false) - return false; + if (! som_bfd_count_ar_symbols (abfd, &lst_header, &ardata->symdef_count)) + return FALSE; /* Get back to the start of the library symbol table. */ if (bfd_seek (abfd, (ardata->first_file_filepos - parsed_size + sizeof (struct lst_header)), SEEK_SET) != 0) - return false; + return FALSE; /* Initializae the cache and allocate space for the library symbols. */ ardata->cache = 0; @@ -5759,21 +5789,20 @@ som_slurp_armap (abfd) amt *= sizeof (carsym); ardata->symdefs = (carsym *) bfd_alloc (abfd, amt); if (!ardata->symdefs) - return false; + return FALSE; /* Now fill in the canonical archive symbols. */ - if (som_bfd_fill_in_ar_symbols (abfd, &lst_header, &ardata->symdefs) - == false) - return false; + if (! som_bfd_fill_in_ar_symbols (abfd, &lst_header, &ardata->symdefs)) + return FALSE; /* Seek back to the "first" file in the archive. Note the "first" file may be the extended name table. */ if (bfd_seek (abfd, ardata->first_file_filepos, SEEK_SET) != 0) - return false; + return FALSE; /* Notify the generic archive code that we have a symbol map. */ - bfd_has_map (abfd) = true; - return true; + bfd_has_map (abfd) = TRUE; + return TRUE; } /* Begin preparing to write a SOM library symbol table. @@ -5781,7 +5810,7 @@ som_slurp_armap (abfd) As part of the prep work we need to determine the number of symbols and the size of the associated string section. */ -static boolean +static bfd_boolean som_bfd_prep_for_ar_write (abfd, num_syms, stringsize) bfd *abfd; unsigned int *num_syms, *stringsize; @@ -5809,8 +5838,8 @@ som_bfd_prep_for_ar_write (abfd, num_syms, stringsize) /* Make sure the symbol table has been read, then snag a pointer to it. It's a little slimey to grab the symbols via obj_som_symtab, but doing so avoids allocating lots of extra memory. */ - if (som_slurp_symbol_table (curr_bfd) == false) - return false; + if (! som_slurp_symbol_table (curr_bfd)) + return FALSE; sym = obj_som_symtab (curr_bfd); curr_count = bfd_get_symcount (curr_bfd); @@ -5849,7 +5878,7 @@ som_bfd_prep_for_ar_write (abfd, num_syms, stringsize) curr_bfd = curr_bfd->next; } - return true; + return TRUE; } /* Hash a symbol name based on the hashing algorithm presented in the @@ -5872,7 +5901,7 @@ som_bfd_ar_symbol_hash (symbol) /* Do the bulk of the work required to write the SOM library symbol table. */ -static boolean +static bfd_boolean som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst, elength) bfd *abfd; unsigned int nsyms, string_size; @@ -5891,19 +5920,19 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst, elength) amt = lst.hash_size; amt *= sizeof (unsigned int); - hash_table = (unsigned int *) bfd_malloc (amt); + hash_table = (unsigned int *) bfd_zmalloc (amt); if (hash_table == NULL && lst.hash_size != 0) goto error_return; amt = lst.module_count; amt *= sizeof (struct som_entry); - som_dict = (struct som_entry *) bfd_malloc (amt); + som_dict = (struct som_entry *) bfd_zmalloc (amt); if (som_dict == NULL && lst.module_count != 0) goto error_return; amt = lst.hash_size; amt *= sizeof (struct lst_symbol_record *); - last_hash_entry = ((struct lst_symbol_record **) bfd_malloc (amt)); + last_hash_entry = ((struct lst_symbol_record **) bfd_zmalloc (amt)); if (last_hash_entry == NULL && lst.hash_size != 0) goto error_return; @@ -5911,12 +5940,6 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst, elength) of the lst record. So save its location. */ lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header); - /* Some initialization. */ - memset (hash_table, 0, 4 * lst.hash_size); - memset (som_dict, 0, lst.module_count * sizeof (struct som_entry)); - memset (last_hash_entry, 0, - lst.hash_size * sizeof (struct lst_symbol_record *)); - /* Symbols have som_index fields, so we have to keep track of the index of each SOM in the archive. @@ -5970,7 +5993,7 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst, elength) /* Make sure the symbol table has been read, then snag a pointer to it. It's a little slimey to grab the symbols via obj_som_symtab, but doing so avoids allocating lots of extra memory. */ - if (som_slurp_symbol_table (curr_bfd) == false) + if (! som_slurp_symbol_table (curr_bfd)) goto error_return; sym = obj_som_symtab (curr_bfd); @@ -6115,7 +6138,7 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst, elength) free (lst_syms); if (strings != NULL) free (strings); - return true; + return TRUE; error_return: if (hash_table != NULL) @@ -6129,14 +6152,14 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst, elength) if (strings != NULL) free (strings); - return false; + return FALSE; } /* Write out the LST for the archive. You'll never believe this is really how armaps are handled in SOM... */ -static boolean +static bfd_boolean som_write_armap (abfd, elength, map, orl_count, stridx) bfd *abfd; unsigned int elength; @@ -6156,7 +6179,7 @@ som_write_armap (abfd, elength, map, orl_count, stridx) if (stat (abfd->filename, &statbuf) != 0) { bfd_set_error (bfd_error_system_call); - return false; + return FALSE; } /* Fudge factor. */ bfd_ardata (abfd)->armap_timestamp = statbuf.st_mtime + 60; @@ -6206,8 +6229,8 @@ som_write_armap (abfd, elength, map, orl_count, stridx) /* Count how many symbols we will have on the hash chains and the size of the associated string table. */ - if (som_bfd_prep_for_ar_write (abfd, &nsyms, &stringsize) == false) - return false; + if (! som_bfd_prep_for_ar_write (abfd, &nsyms, &stringsize)) + return FALSE; lst_size += sizeof (struct lst_symbol_record) * nsyms; @@ -6245,32 +6268,32 @@ som_write_armap (abfd, elength, map, orl_count, stridx) /* Scribble out the ar header. */ amt = sizeof (struct ar_hdr); if (bfd_bwrite ((PTR) &hdr, amt, abfd) != amt) - return false; + return FALSE; /* Now scribble out the lst header. */ amt = sizeof (struct lst_header); if (bfd_bwrite ((PTR) &lst, amt, abfd) != amt) - return false; + return FALSE; /* Build and write the armap. */ if (!som_bfd_ar_write_symbol_stuff (abfd, nsyms, stringsize, lst, elength)) - return false; + return FALSE; /* Done. */ - return true; + return TRUE; } /* Free all information we have cached for this BFD. We can always read it again later if we need it. */ -static boolean +static bfd_boolean som_bfd_free_cached_info (abfd) bfd *abfd; { asection *o; if (bfd_get_format (abfd) != bfd_object) - return true; + return TRUE; #define FREE(x) if (x != NULL) { free (x); x = NULL; } /* Free the native string and symbol tables. */ @@ -6286,14 +6309,14 @@ som_bfd_free_cached_info (abfd) } #undef FREE - return true; + return TRUE; } /* End of miscellaneous support functions. */ /* Linker support functions. */ -static boolean +static bfd_boolean som_bfd_link_split_section (abfd, sec) bfd *abfd ATTRIBUTE_UNUSED; asection *sec; @@ -6314,7 +6337,7 @@ som_bfd_link_split_section (abfd, sec) #define som_update_armap_timestamp bfd_true #define som_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data -#define som_get_lineno _bfd_nosymbols_get_lineno +#define som_get_lineno _bfd_nosymbols_get_lineno #define som_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol #define som_read_minisymbols _bfd_generic_read_minisymbols #define som_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol @@ -6325,11 +6348,14 @@ som_bfd_link_split_section (abfd, sec) bfd_generic_get_relocated_section_contents #define som_bfd_relax_section bfd_generic_relax_section #define som_bfd_link_hash_table_create _bfd_generic_link_hash_table_create +#define som_bfd_link_hash_table_free _bfd_generic_link_hash_table_free #define som_bfd_link_add_symbols _bfd_generic_link_add_symbols +#define som_bfd_link_just_syms _bfd_generic_link_just_syms #define som_bfd_final_link _bfd_generic_final_link #define som_bfd_gc_sections bfd_generic_gc_sections #define som_bfd_merge_sections bfd_generic_merge_sections +#define som_bfd_discard_group bfd_generic_discard_group const bfd_target som_vec = { "som", /* name */