X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Foasys.c;h=d1e86ca363fb516240a554ef3879d0c366fd97a3;hb=6cee3f79e46e3b0fa9046bd66b5b88de22b0b49c;hp=17fc735d77975e83dfad35608380408a437da784;hpb=e61463e1e61219fa605d31d2297cb7a88d6da1db;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/oasys.c b/bfd/oasys.c index 17fc735d77..d1e86ca363 100644 --- a/bfd/oasys.c +++ b/bfd/oasys.c @@ -1,6 +1,6 @@ /* BFD back-end for oasys objects. - Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2001, 2002 - Free Software Foundation, Inc. + Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2001, + 2002, 2003 Free Software Foundation, Inc. Written by Steve Chamberlain of Cygnus Support, . This file is part of BFD, the Binary File Descriptor library. @@ -27,62 +27,85 @@ #include "oasys.h" #include "liboasys.h" -static boolean oasys_slurp_section_data PARAMS ((bfd * const)); -static boolean oasys_read_record PARAMS ((bfd *, oasys_record_union_type *)); -static boolean oasys_write_sections PARAMS ((bfd *)); -static boolean oasys_write_record +static bfd_boolean oasys_slurp_section_data + PARAMS ((bfd * const)); +static bfd_boolean oasys_read_record + PARAMS ((bfd *, oasys_record_union_type *)); +static bfd_boolean oasys_write_sections + PARAMS ((bfd *)); +static bfd_boolean oasys_write_record PARAMS ((bfd *, oasys_record_enum_type, oasys_record_union_type *, size_t)); -static boolean oasys_write_syms PARAMS ((bfd *)); -static boolean oasys_write_header PARAMS ((bfd *)); -static boolean oasys_write_end PARAMS ((bfd *)); -static boolean oasys_write_data PARAMS ((bfd *)); -static size_t oasys_string_length PARAMS ((oasys_record_union_type *)); -static boolean oasys_slurp_symbol_table PARAMS ((bfd *const)); -static long int oasys_get_symtab_upper_bound PARAMS ((bfd *const)); -static const bfd_target *oasys_archive_p PARAMS ((bfd *)); -static boolean oasys_mkobject PARAMS ((bfd *)); -static const bfd_target *oasys_object_p PARAMS ((bfd *)); -static void oasys_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *)); +static bfd_boolean oasys_write_syms + PARAMS ((bfd *)); +static bfd_boolean oasys_write_header + PARAMS ((bfd *)); +static bfd_boolean oasys_write_end + PARAMS ((bfd *)); +static bfd_boolean oasys_write_data + PARAMS ((bfd *)); +static size_t oasys_string_length + PARAMS ((oasys_record_union_type *)); +static bfd_boolean oasys_slurp_symbol_table + PARAMS ((bfd *const)); +static long int oasys_get_symtab_upper_bound + PARAMS ((bfd *const)); +static const bfd_target *oasys_archive_p + PARAMS ((bfd *)); +static bfd_boolean oasys_mkobject + PARAMS ((bfd *)); +static const bfd_target *oasys_object_p + PARAMS ((bfd *)); +static void oasys_get_symbol_info + PARAMS ((bfd *, asymbol *, symbol_info *)); static void oasys_print_symbol PARAMS ((bfd *, void *, asymbol *, bfd_print_symbol_type)); -static boolean oasys_new_section_hook PARAMS ((bfd *, asection *)); -static long int oasys_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); -static boolean oasys_get_section_contents +static bfd_boolean oasys_new_section_hook + PARAMS ((bfd *, asection *)); +static long int oasys_get_reloc_upper_bound + PARAMS ((bfd *, sec_ptr)); +static bfd_boolean oasys_get_section_contents PARAMS ((bfd *, sec_ptr, void *, file_ptr, bfd_size_type)); -static int comp PARAMS ((const void *, const void *)); -static boolean oasys_write_object_contents PARAMS ((bfd *)); -static boolean oasys_set_section_contents +static int comp + PARAMS ((const void *, const void *)); +static bfd_boolean oasys_write_object_contents + PARAMS ((bfd *)); +static bfd_boolean oasys_set_section_contents PARAMS ((bfd *, sec_ptr, void *, file_ptr, bfd_size_type)); -static asymbol *oasys_make_empty_symbol PARAMS ((bfd *)); -static bfd *oasys_openr_next_archived_file PARAMS ((bfd *, bfd *)); -static boolean oasys_find_nearest_line +static asymbol *oasys_make_empty_symbol + PARAMS ((bfd *)); +static bfd *oasys_openr_next_archived_file + PARAMS ((bfd *, bfd *)); +static bfd_boolean oasys_find_nearest_line PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **, const char **, unsigned int *)); -static int oasys_generic_stat_arch_elt PARAMS ((bfd *, struct stat *)); -static int oasys_sizeof_headers PARAMS ((bfd *, boolean)); +static int oasys_generic_stat_arch_elt + PARAMS ((bfd *, struct stat *)); +static int oasys_sizeof_headers + PARAMS ((bfd *, bfd_boolean)); -long oasys_get_symtab PARAMS ((bfd *, asymbol **)); +long oasys_canonicalize_symtab + PARAMS ((bfd *, asymbol **)); long oasys_canonicalize_reloc PARAMS ((bfd *, sec_ptr, arelent **, asymbol **)); /* Read in all the section data and relocation stuff too. */ -static boolean +static bfd_boolean oasys_read_record (abfd, record) bfd *abfd; oasys_record_union_type *record; { bfd_size_type amt = sizeof (record->header); if (bfd_bread ((PTR) record, amt, abfd) != amt) - return false; + return FALSE; amt = record->header.length - sizeof (record->header); if ((long) amt <= 0) - return true; + return TRUE; if (bfd_bread ((PTR) ((char *) record + sizeof (record->header)), amt, abfd) != amt) - return false; - return true; + return FALSE; + return TRUE; } static size_t @@ -109,13 +132,13 @@ moving in, and the defined symbols at the end of the table moving back. */ -static boolean +static bfd_boolean oasys_slurp_symbol_table (abfd) bfd *const abfd; { oasys_record_union_type record; oasys_data_type *data = OASYS_DATA (abfd); - boolean loop = true; + bfd_boolean loop = TRUE; asymbol *dest_defined; asymbol *dest; char *string_ptr; @@ -123,7 +146,7 @@ oasys_slurp_symbol_table (abfd) if (data->symbols != (asymbol *) NULL) { - return true; + return TRUE; } /* Buy enough memory for all the symbols and all the names */ amt = abfd->symcount; @@ -138,18 +161,18 @@ oasys_slurp_symbol_table (abfd) data->strings = bfd_alloc (abfd, amt); if (!data->symbols || !data->strings) - return false; + return FALSE; dest_defined = data->symbols + abfd->symcount - 1; string_ptr = data->strings; if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) - return false; + return FALSE; while (loop) { if (! oasys_read_record (abfd, &record)) - return false; + return FALSE; switch (record.header.type) { case oasys_record_is_header_enum: @@ -229,10 +252,10 @@ oasys_slurp_symbol_table (abfd) } break; default: - loop = false; + loop = FALSE; } } - return true; + return TRUE; } static long @@ -248,13 +271,13 @@ oasys_get_symtab_upper_bound (abfd) extern const bfd_target oasys_vec; long -oasys_get_symtab (abfd, location) +oasys_canonicalize_symtab (abfd, location) bfd *abfd; asymbol **location; { asymbol *symbase; unsigned int counter; - if (oasys_slurp_symbol_table (abfd) == false) + if (! oasys_slurp_symbol_table (abfd)) { return -1; } @@ -405,13 +428,13 @@ oasys_archive_p (abfd) return abfd->xvec; } -static boolean +static bfd_boolean oasys_mkobject (abfd) bfd *abfd; { bfd_size_type amt = sizeof (oasys_data_type); abfd->tdata.oasys_obj_data = (oasys_data_type *) bfd_alloc (abfd, amt); - return abfd->tdata.oasys_obj_data ? true : false; + return abfd->tdata.oasys_obj_data != NULL; } #define MAX_SECS 16 @@ -421,8 +444,8 @@ oasys_object_p (abfd) { oasys_data_type *oasys; oasys_data_type *save = OASYS_DATA (abfd); - boolean loop = true; - boolean had_usefull = false; + bfd_boolean loop = TRUE; + bfd_boolean had_usefull = FALSE; abfd->tdata.oasys_obj_data = 0; oasys_mkobject (abfd); @@ -449,14 +472,14 @@ oasys_object_p (abfd) switch ((oasys_record_enum_type) (record.header.type)) { case oasys_record_is_header_enum: - had_usefull = true; + had_usefull = TRUE; break; case oasys_record_is_symbol_enum: case oasys_record_is_local_enum: /* Count symbols and remember their size for a future malloc */ abfd->symcount++; oasys->symbol_string_length += 1 + oasys_string_length (&record); - had_usefull = true; + had_usefull = TRUE; break; case oasys_record_is_section_enum: { @@ -487,7 +510,7 @@ oasys_object_p (abfd) s->_raw_size = H_GET_32 (abfd, record.section.value); s->vma = H_GET_32 (abfd, record.section.vma); s->flags = 0; - had_usefull = true; + had_usefull = TRUE; } break; case oasys_record_is_data_enum: @@ -496,9 +519,9 @@ oasys_object_p (abfd) case oasys_record_is_module_enum: case oasys_record_is_named_section_enum: case oasys_record_is_end_enum: - if (had_usefull == false) + if (! had_usefull) goto fail; - loop = false; + loop = FALSE; break; default: goto fail; @@ -578,20 +601,20 @@ oasys_print_symbol (abfd, afile, symbol, how) static reloc_howto_type howto_table[] = { - HOWTO (0, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "abs16", true, 0x0000ffff, 0x0000ffff, false), - HOWTO (0, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "abs32", true, 0xffffffff, 0xffffffff, false), - HOWTO (0, 0, 1, 16, true, 0, complain_overflow_signed, 0, "pcrel16", true, 0x0000ffff, 0x0000ffff, false), - HOWTO (0, 0, 2, 32, true, 0, complain_overflow_signed, 0, "pcrel32", true, 0xffffffff, 0xffffffff, false) + HOWTO (0, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, 0, "abs16", TRUE, 0x0000ffff, 0x0000ffff, FALSE), + HOWTO (0, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, 0, "abs32", TRUE, 0xffffffff, 0xffffffff, FALSE), + HOWTO (0, 0, 1, 16, TRUE, 0, complain_overflow_signed, 0, "pcrel16", TRUE, 0x0000ffff, 0x0000ffff, FALSE), + HOWTO (0, 0, 2, 32, TRUE, 0, complain_overflow_signed, 0, "pcrel32", TRUE, 0xffffffff, 0xffffffff, FALSE) }; /* Read in all the section data and relocation stuff too */ -static boolean +static bfd_boolean oasys_slurp_section_data (abfd) bfd *const abfd; { oasys_record_union_type record; oasys_data_type *data = OASYS_DATA (abfd); - boolean loop = true; + bfd_boolean loop = TRUE; oasys_per_section_type *per; asection *s; bfd_size_type amt; @@ -600,19 +623,19 @@ oasys_slurp_section_data (abfd) for (s = abfd->sections; s != (asection *) NULL; s = s->next) { per = oasys_per_section (s); - if (per->initialized == true) - return true; + if (per->initialized) + return TRUE; } if (data->first_data_record == 0) - return true; + return TRUE; if (bfd_seek (abfd, data->first_data_record, SEEK_SET) != 0) - return false; + return FALSE; while (loop) { if (! oasys_read_record (abfd, &record)) - return false; + return FALSE; switch (record.header.type) { case oasys_record_is_header_enum: @@ -632,25 +655,25 @@ oasys_slurp_section_data (abfd) per = oasys_per_section (section); - if (per->initialized == false) + if (! per->initialized) { per->data = (bfd_byte *) bfd_zalloc (abfd, section->_raw_size); if (!per->data) - return false; + return FALSE; per->reloc_tail_ptr = (oasys_reloc_type **) §ion->relocation; - per->had_vma = false; - per->initialized = true; + per->had_vma = FALSE; + per->initialized = TRUE; section->reloc_count = 0; section->flags = SEC_ALLOC; } dst_offset = H_GET_32 (abfd, record.data.addr); - if (per->had_vma == false) + if (! per->had_vma) { /* Take the first vma we see as the base */ section->vma = dst_offset; - per->had_vma = true; + per->had_vma = TRUE; } dst_offset -= section->vma; @@ -705,7 +728,7 @@ oasys_slurp_section_data (abfd) r = (oasys_reloc_type *) bfd_alloc (abfd, amt); if (!r) - return false; + return FALSE; *(per->reloc_tail_ptr) = r; per->reloc_tail_ptr = &r->next; r->next = (oasys_reloc_type *) NULL; @@ -728,16 +751,13 @@ oasys_slurp_section_data (abfd) r->relent.sym_ptr_ptr = (asymbol **) NULL; section->reloc_count++; - /* Fake up the data to look like it's got the -ve pc in it, this makes - it much easier to convert into other formats. This is done by - hitting the addend. - */ - if (r->relent.howto->pc_relative == true) - { - r->relent.addend -= dst_ptr - dst_base_ptr; - } - - + /* Fake up the data to look like + it's got the -ve pc in it, this + makes it much easier to convert + into other formats. This is done + by hitting the addend. */ + if (r->relent.howto->pc_relative) + r->relent.addend -= dst_ptr - dst_base_ptr; } break; @@ -750,7 +770,7 @@ oasys_slurp_section_data (abfd) r = (oasys_reloc_type *) bfd_alloc (abfd, amt); if (!r) - return false; + return FALSE; *(per->reloc_tail_ptr) = r; per->reloc_tail_ptr = &r->next; r->next = (oasys_reloc_type *) NULL; @@ -772,17 +792,13 @@ oasys_slurp_section_data (abfd) section->reloc_count++; src += 2; - /* Fake up the data to look like it's got the -ve pc in it, this makes - it much easier to convert into other formats. This is done by - hitting the addend. - */ - if (r->relent.howto->pc_relative == true) - { - r->relent.addend -= dst_ptr - dst_base_ptr; - } - - - + /* Fake up the data to look like + it's got the -ve pc in it, this + makes it much easier to convert + into other formats. This is done + by hitting the addend. */ + if (r->relent.howto->pc_relative) + r->relent.addend -= dst_ptr - dst_base_ptr; } break; case RELOCATION_TYPE_COM: @@ -800,15 +816,15 @@ oasys_slurp_section_data (abfd) case oasys_record_is_section_enum: break; default: - loop = false; + loop = FALSE; } } - return true; + return TRUE; } -static boolean +static bfd_boolean oasys_new_section_hook (abfd, newsect) bfd *abfd; asection *newsect; @@ -816,17 +832,17 @@ oasys_new_section_hook (abfd, newsect) newsect->used_by_bfd = (PTR) bfd_alloc (abfd, (bfd_size_type) sizeof (oasys_per_section_type)); if (!newsect->used_by_bfd) - return false; + return FALSE; oasys_per_section (newsect)->data = (bfd_byte *) NULL; oasys_per_section (newsect)->section = newsect; oasys_per_section (newsect)->offset = 0; - oasys_per_section (newsect)->initialized = false; + oasys_per_section (newsect)->initialized = FALSE; newsect->alignment_power = 1; /* Turn the section string into an index */ sscanf (newsect->name, "%u", &newsect->target_index); - return true; + return TRUE; } @@ -840,7 +856,7 @@ oasys_get_reloc_upper_bound (abfd, asect) return (asect->reloc_count + 1) * sizeof (arelent *); } -static boolean +static bfd_boolean oasys_get_section_contents (abfd, section, location, offset, count) bfd *abfd; sec_ptr section; @@ -848,9 +864,9 @@ oasys_get_section_contents (abfd, section, location, offset, count) file_ptr offset; bfd_size_type count; { - oasys_per_section_type *p = (oasys_per_section_type *) section->used_by_bfd; + oasys_per_section_type *p = oasys_per_section (section); oasys_slurp_section_data (abfd); - if (p->initialized == false) + if (! p->initialized) { (void) memset (location, 0, (size_t) count); } @@ -858,7 +874,7 @@ oasys_get_section_contents (abfd, section, location, offset, count) { (void) memcpy (location, (PTR) (p->data + offset), (size_t) count); } - return true; + return TRUE; } @@ -897,7 +913,7 @@ oasys_canonicalize_reloc (ignore_abfd, section, relptr, symbols) /* Calculate the checksum and write one record */ -static boolean +static bfd_boolean oasys_write_record (abfd, type, record, size) bfd *abfd; oasys_record_enum_type type; @@ -920,13 +936,13 @@ oasys_write_record (abfd, type, record, size) } record->header.check_sum = 0xff & (-checksum); if (bfd_bwrite ((PTR) record, (bfd_size_type) size, abfd) != size) - return false; - return true; + return FALSE; + return TRUE; } /* Write out all the symbols */ -static boolean +static bfd_boolean oasys_write_syms (abfd) bfd *abfd; { @@ -1002,7 +1018,7 @@ oasys_write_syms (abfd) (oasys_record_union_type *) & symbol, offsetof (oasys_symbol_record_type, name[0]) + l)) - return false; + return FALSE; } else { @@ -1011,17 +1027,17 @@ oasys_write_syms (abfd) (oasys_record_union_type *) & symbol, offsetof (oasys_symbol_record_type, name[0]) + l)) - return false; + return FALSE; } g->value = index - 1; } - return true; + return TRUE; } /* Write a section header for each section */ -static boolean +static bfd_boolean oasys_write_sections (abfd) bfd *abfd; { @@ -1036,7 +1052,7 @@ oasys_write_sections (abfd) (_("%s: can not represent section `%s' in oasys"), bfd_get_filename (abfd), s->name); bfd_set_error (bfd_error_nonrepresentable_section); - return false; + return FALSE; } out.relb = RELOCATION_TYPE_REL | s->target_index; H_PUT_32 (abfd, s->_cooked_size, out.value); @@ -1046,12 +1062,12 @@ oasys_write_sections (abfd) oasys_record_is_section_enum, (oasys_record_union_type *) & out, sizeof (out))) - return false; + return FALSE; } - return true; + return TRUE; } -static boolean +static bfd_boolean oasys_write_header (abfd) bfd *abfd; { @@ -1077,12 +1093,12 @@ oasys_write_header (abfd) (oasys_record_union_type *) & r, offsetof (oasys_header_record_type, description[0]))) - return false; + return FALSE; - return true; + return TRUE; } -static boolean +static bfd_boolean oasys_write_end (abfd) bfd *abfd; { @@ -1096,10 +1112,10 @@ oasys_write_end (abfd) oasys_record_is_end_enum, (oasys_record_union_type *) & end, sizeof (end))) - return false; + return FALSE; if (bfd_bwrite ((PTR) &null, (bfd_size_type) 1, abfd) != 1) - return false; - return true; + return FALSE; + return TRUE; } static int @@ -1116,7 +1132,7 @@ comp (ap, bp) Writing data.. */ -static boolean +static bfd_boolean oasys_write_data (abfd) bfd *abfd; { @@ -1293,29 +1309,29 @@ oasys_write_data (abfd) (abfd, oasys_record_is_data_enum, ((oasys_record_union_type *) &processed_data), (size_t) (dst - (bfd_byte *) &processed_data)))) - return false; + return FALSE; } } } - return true; + return TRUE; } -static boolean +static bfd_boolean oasys_write_object_contents (abfd) bfd *abfd; { if (! oasys_write_header (abfd)) - return false; + return FALSE; if (! oasys_write_syms (abfd)) - return false; + return FALSE; if (! oasys_write_sections (abfd)) - return false; + return FALSE; if (! oasys_write_data (abfd)) - return false; + return FALSE; if (! oasys_write_end (abfd)) - return false; - return true; + return FALSE; + return TRUE; } @@ -1326,7 +1342,7 @@ oasys_write_object_contents (abfd) /* set section contents is complicated with OASYS since the format is * not a byte image, but a record stream. */ -static boolean +static bfd_boolean oasys_set_section_contents (abfd, section, location, offset, count) bfd *abfd; sec_ptr section; @@ -1341,13 +1357,13 @@ oasys_set_section_contents (abfd, section, location, offset, count) oasys_per_section (section)->data = (bfd_byte *) (bfd_alloc (abfd, section->_cooked_size)); if (!oasys_per_section (section)->data) - return false; + return FALSE; } (void) memcpy ((PTR) (oasys_per_section (section)->data + offset), location, (size_t) count); } - return true; + return TRUE; } @@ -1413,7 +1429,7 @@ oasys_openr_next_archived_file (arch, prev) } } -static boolean +static bfd_boolean oasys_find_nearest_line (abfd, section, symbols, offset, filename_ptr, functionname_ptr, line_ptr) bfd *abfd ATTRIBUTE_UNUSED; @@ -1424,7 +1440,7 @@ oasys_find_nearest_line (abfd, section, symbols, offset, const char **functionname_ptr ATTRIBUTE_UNUSED; unsigned int *line_ptr ATTRIBUTE_UNUSED; { - return false; + return FALSE; } @@ -1450,7 +1466,7 @@ oasys_generic_stat_arch_elt (abfd, buf) static int oasys_sizeof_headers (abfd, exec) bfd *abfd ATTRIBUTE_UNUSED; - boolean exec ATTRIBUTE_UNUSED; + bfd_boolean exec ATTRIBUTE_UNUSED; { return 0; } @@ -1461,11 +1477,11 @@ oasys_sizeof_headers (abfd, exec) #define oasys_slurp_armap bfd_true #define oasys_slurp_extended_name_table bfd_true #define oasys_construct_extended_name_table \ - ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \ + ((bfd_boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \ bfd_true) #define oasys_truncate_arname bfd_dont_truncate_arname #define oasys_write_armap \ - ((boolean (*) \ + ((bfd_boolean (*) \ PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \ bfd_true) #define oasys_read_ar_hdr bfd_nullvoidptr