diff options
author | Steve Chamberlain <steve@cygnus> | 1991-04-15 15:25:16 +0000 |
---|---|---|
committer | Steve Chamberlain <steve@cygnus> | 1991-04-15 15:25:16 +0000 |
commit | 9846338e68f0951443690e50cb678082a86be57e (patch) | |
tree | 83da5e493e728f6aa8cf5153cac383b338009a72 | |
parent | 14825ce9fa772c7024798c83291c822ee86797ea (diff) | |
download | ppe42-binutils-9846338e68f0951443690e50cb678082a86be57e.tar.gz ppe42-binutils-9846338e68f0951443690e50cb678082a86be57e.zip |
Merged in some changes from Intel,
Added some more prototypes.
-rwxr-xr-x | bfd/aout.c | 100 | ||||
-rw-r--r-- | bfd/archive.c | 192 | ||||
-rw-r--r-- | bfd/bfd.c | 250 | ||||
-rwxr-xr-x | bfd/coff-code.h | 80 | ||||
-rw-r--r-- | bfd/libaout.h | 4 | ||||
-rw-r--r-- | bfd/libbfd.c | 14 | ||||
-rw-r--r-- | bfd/libbfd.h | 12 | ||||
-rw-r--r-- | bfd/opncls.c | 30 | ||||
-rw-r--r-- | bfd/sunos.c | 303 | ||||
-rw-r--r-- | bfd/targets.c | 38 |
10 files changed, 569 insertions, 454 deletions
diff --git a/bfd/aout.c b/bfd/aout.c index dc931ee81f..a88d39137f 100755 --- a/bfd/aout.c +++ b/bfd/aout.c @@ -204,11 +204,11 @@ sunos4_object_p (abfd) unsigned long magic; /* Swapped magic number */ unsigned char exec_bytes[EXEC_BYTES_SIZE]; /* Raw bytes of exec hdr */ struct exec *execp; - void *rawptr; + PTR rawptr; bfd_error = system_call_error; - if (bfd_read ((void *)magicbuf, 1, sizeof (magicbuf), abfd) != + if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) != sizeof (magicbuf)) return 0; magic = bfd_h_getlong (abfd, magicbuf); @@ -219,14 +219,14 @@ sunos4_object_p (abfd) if (bfd_seek (abfd, 0L, false) < 0) return 0; - if (bfd_read ((void *) exec_bytes, 1, EXEC_BYTES_SIZE, abfd) + if (bfd_read ((PTR) exec_bytes, 1, EXEC_BYTES_SIZE, abfd) != EXEC_BYTES_SIZE) { bfd_error = wrong_format; return 0; } /* Use an intermediate variable for clarity */ - rawptr = (void *) zalloc (sizeof (struct sunexdata) + sizeof (struct exec)); + rawptr = (PTR) zalloc (sizeof (struct sunexdata) + sizeof (struct exec)); if (rawptr == NULL) { bfd_error = no_memory; @@ -347,7 +347,7 @@ sunos4_mkobject (abfd) return false; } - abfd->tdata = (void *)((struct sunexdata *) rawptr); + abfd->tdata = (PTR)((struct sunexdata *) rawptr); exec_hdr (abfd) = (struct exec *) (rawptr + sizeof (struct sunexdata)); /* For simplicity's sake we just make all the sections right here. */ @@ -496,24 +496,24 @@ sunos4_write_object_contents (abfd) bfd_aout_swap_exec_header_out (abfd, execp, exec_bytes); bfd_seek (abfd, 0L, false); - bfd_write ((void *) exec_bytes, 1, EXEC_BYTES_SIZE, abfd); + bfd_write ((PTR) exec_bytes, 1, EXEC_BYTES_SIZE, abfd); /* Now write out reloc info, followed by syms and strings */ if (bfd_get_symcount (abfd) != 0) - { - bfd_seek (abfd, - (long)(N_SYMOFF(*execp)), false); + { + bfd_seek (abfd, + (long)(N_SYMOFF(*execp)), false); - sunos4_write_syms (abfd); + sunos4_write_syms (abfd); - bfd_seek (abfd, (long)(N_TROFF(*execp)), false); + bfd_seek (abfd, (long)(N_TROFF(*execp)), false); - if (!sunos4_squirt_out_relocs (abfd, obj_textsec (abfd))) return false; - bfd_seek (abfd, (long)(N_DROFF(*execp)), false); + if (!sunos4_squirt_out_relocs (abfd, obj_textsec (abfd))) return false; + bfd_seek (abfd, (long)(N_DROFF(*execp)), false); - if (!sunos4_squirt_out_relocs (abfd, obj_datasec (abfd))) return false; - } + if (!sunos4_squirt_out_relocs (abfd, obj_datasec (abfd))) return false; + } return true; } @@ -613,7 +613,7 @@ sunos4_core_file_p (abfd) bfd_error = system_call_error; - if (bfd_read ((void *)longbuf, 1, sizeof (longbuf), abfd) != + if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) != sizeof (longbuf)) return 0; core_mag = bfd_h_getlong (abfd, longbuf); @@ -621,7 +621,7 @@ sunos4_core_file_p (abfd) if (core_mag != CORE_MAGIC) return 0; /* SunOS core headers can vary in length; second word is size; */ - if (bfd_read ((void *)longbuf, 1, sizeof (longbuf), abfd) != + if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) != sizeof (longbuf)) return 0; core_size = bfd_h_getlong (abfd, longbuf); @@ -639,9 +639,9 @@ sunos4_core_file_p (abfd) core = (struct core *) (rawptr + sizeof (struct suncordata)); - if ((bfd_read ((void *) core, 1, core_size, abfd)) != core_size) { + if ((bfd_read ((PTR) core, 1, core_size, abfd)) != core_size) { bfd_error = system_call_error; - free ((void *)rawptr); + free ((PTR)rawptr); return 0; } @@ -655,24 +655,24 @@ sunos4_core_file_p (abfd) if (core_stacksec (abfd) == NULL) { loser: bfd_error = no_memory; - free ((void *)rawptr); + free ((PTR)rawptr); return 0; } core_datasec (abfd) = (asection *) zalloc (sizeof (asection)); if (core_datasec (abfd) == NULL) { loser1: - free ((void *)core_stacksec (abfd)); + free ((PTR)core_stacksec (abfd)); goto loser; } core_regsec (abfd) = (asection *) zalloc (sizeof (asection)); if (core_regsec (abfd) == NULL) { loser2: - free ((void *)core_datasec (abfd)); + free ((PTR)core_datasec (abfd)); goto loser1; } core_reg2sec (abfd) = (asection *) zalloc (sizeof (asection)); if (core_reg2sec (abfd) == NULL) { - free ((void *)core_regsec (abfd)); + free ((PTR)core_regsec (abfd)); goto loser2; } @@ -841,7 +841,7 @@ sunos4_set_section_contents (abfd, section, location, offset, count) bfd_seek (abfd, section->filepos + offset, SEEK_SET); if (count) { - return (bfd_write ((void *)location, 1, count, abfd) == count) ? + return (bfd_write ((PTR)location, 1, count, abfd) == count) ? true : false; } return false; @@ -850,7 +850,7 @@ boolean sunos4_get_section_contents (abfd, section, location, offset, count) bfd *abfd; sec_ptr section; - void *location; + PTR location; file_ptr offset; int count; { @@ -1129,7 +1129,7 @@ DEFUN(sunos4_slurp_symbol_table, (abfd), } bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET); - if (bfd_read ((void *)&string_size, 4, 1, abfd) != 4) + if (bfd_read ((PTR)&string_size, 4, 1, abfd) != 4) return false; string_size = bfd_h_getlong (abfd, (unsigned char *)&string_size); @@ -1148,22 +1148,22 @@ DEFUN(sunos4_slurp_symbol_table, (abfd), (symbol_count * sizeof (aout_symbol_type)))); if (cached == NULL) { bfd_error = no_memory; - free ((void *)syms); + free ((PTR)syms); return false; } strings = ((char *) cached) + (symbol_count * sizeof (aout_symbol_type)); bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET); - if (bfd_read ((void *)syms, 1, symbol_size, abfd) != symbol_size) { + if (bfd_read ((PTR)syms, 1, symbol_size, abfd) != symbol_size) { bailout: - free ((void *)cached); - free ((void*)syms); + free ((PTR)cached); + free ((PTR)syms); return false; } bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET); - if (bfd_read ((void *)strings, 1, string_size, abfd) != string_size) { + if (bfd_read ((PTR)strings, 1, string_size, abfd) != string_size) { goto bailout; } @@ -1209,7 +1209,7 @@ DEFUN(sunos4_slurp_symbol_table, (abfd), obj_aout_symbols (abfd) = cached; bfd_get_symcount (abfd) = symbol_count; - free ((void *)syms); + free ((PTR)syms); return true; } @@ -1257,7 +1257,7 @@ DEFUN(sunos4_write_syms,(abfd), bfd_h_putshort (abfd, nsp.n_desc, (unsigned char *)&nsp.n_desc); bfd_h_putlong (abfd, nsp.n_value, (unsigned char *)&nsp.n_value); - bfd_write((void *)&nsp,1, sizeof(nsp), abfd); + bfd_write((PTR)&nsp,1, sizeof(nsp), abfd); } @@ -1266,7 +1266,7 @@ DEFUN(sunos4_write_syms,(abfd), */ bfd_h_putlong (abfd, stindex, (unsigned char *)&stindex); - bfd_write((void *)&stindex, 1, sizeof(stindex), abfd); + bfd_write((PTR)&stindex, 1, sizeof(stindex), abfd); generic = bfd_get_outsymbols(abfd); for (count = 0; count < bfd_get_symcount(abfd); count++) @@ -1276,7 +1276,7 @@ DEFUN(sunos4_write_syms,(abfd), if (g->name != (char *)NULL) { size_t length = strlen(g->name)+1; - bfd_write((void *)g->name, 1, length, abfd); + bfd_write((PTR)g->name, 1, length, abfd); } if ((g->flags & BSF_FAKE)==0) { g->name = itos(count); /* smash the generic symbol */ @@ -1297,13 +1297,13 @@ DEFUN(sunos4_reclaim_symbol_table,(abfd), section != (asection *) NULL; section = section->next) if (section->relocation) { - free ((void *)section->relocation); + free ((PTR)section->relocation); section->relocation = NULL; section->reloc_count = 0; } bfd_get_symcount (abfd) = 0; - free ((void *)obj_aout_symbols (abfd)); + free ((PTR)obj_aout_symbols (abfd)); obj_aout_symbols (abfd) = (aout_symbol_type *)NULL; } @@ -1364,7 +1364,7 @@ sunos4_get_next_symbol (abfd, oidx) return ++oidx >= bfd_get_symcount (abfd) ? BFD_NO_MORE_SYMBOLS : oidx; } -char * +CONST char * sunos4_symbol_name (abfd, idx) bfd *abfd; symindex idx; @@ -1438,7 +1438,7 @@ swap_std_reloc_out (abfd, p, natptr, count) bfd_h_putlong (abfd, g->address, natptr->r_address); r_length = g->howto->size; /* Size as a power of two */ - r_pcrel = g->howto->pc_relative; /* Relative to PC? */ + r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */ /* r_baserel, r_jmptable, r_relative??? FIXME-soon */ r_baserel = 0; r_jmptable = 0; @@ -1718,7 +1718,7 @@ sunos4_slurp_reloc_table (abfd, asect, symbols) { unsigned int count; size_t reloc_size; - void *relocs; + PTR relocs; arelent *reloc_cache; size_t each_size; @@ -1745,7 +1745,7 @@ sunos4_slurp_reloc_table (abfd, asect, symbols) count = reloc_size / each_size; - relocs = malloc (reloc_size); + relocs = (PTR) malloc (reloc_size); if (!relocs) { bfd_error = no_memory; return false; @@ -1766,7 +1766,7 @@ sunos4_slurp_reloc_table (abfd, asect, symbols) if (each_size == RELOC_EXT_SIZE) { - register struct reloc_ext_bytes *rptr = relocs; + register struct reloc_ext_bytes *rptr = (struct reloc_ext_bytes *) relocs; unsigned int counter = 0; arelent *cache_ptr = reloc_cache; @@ -1775,7 +1775,7 @@ sunos4_slurp_reloc_table (abfd, asect, symbols) } } else { - register struct reloc_std_bytes *rptr = relocs; + register struct reloc_std_bytes *rptr = (struct reloc_std_bytes *) relocs; unsigned int counter = 0; arelent *cache_ptr = reloc_cache; @@ -1830,7 +1830,7 @@ sunos4_squirt_out_relocs (abfd, section) swap_std_reloc_out(abfd, generic, native, count); } - if ( bfd_write ((void *) native, 1, natsize, abfd) != natsize) { + if ( bfd_write ((PTR) native, 1, natsize, abfd) != natsize) { free(native); return false; } @@ -1941,10 +1941,10 @@ bfd_print_symbol_enum_type how; break; case bfd_print_symbol_all_enum: { - char *section_name = symbol->section == (asection *)NULL ? + CONST char *section_name = symbol->section == (asection *)NULL ? "*abs" : symbol->section->name; - bfd_print_symbol_vandf((void *)file,symbol); + bfd_print_symbol_vandf((PTR)file,symbol); fprintf(file," %-5s %04x %02x %02x %s", section_name, @@ -2000,8 +2000,8 @@ DEFUN(sunos4_find_nearest_line,(abfd, asection *section AND asymbol **symbols AND bfd_vma offset AND - char **filename_ptr AND - char **functionname_ptr AND + CONST char **filename_ptr AND + CONST char **functionname_ptr AND unsigned int *line_ptr) { /* Run down the file looking for the filename, function and linenumber */ @@ -2043,7 +2043,7 @@ DEFUN(sunos4_find_nearest_line,(abfd, func = (asymbol *)q; } if (*line_ptr && func) { - char *function = func->name; + CONST char *function = func->name; char *p; strncpy(buffer, function, sizeof(buffer)-1); buffer[sizeof(buffer)-1] = 0; @@ -2064,7 +2064,7 @@ DEFUN(sunos4_find_nearest_line,(abfd, } -bfd_target aoutvec = +bfd_target aout_big_vec = { "a.out-generic-big", /* name */ bfd_target_aout_flavour_enum, diff --git a/bfd/archive.c b/bfd/archive.c index 477b6b18ea..bd28af2b8b 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -27,39 +27,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ */ /* $Id$ - * $Log$ - * Revision 1.4 1991/04/04 17:55:47 steve - * *** empty log message *** - * - * Revision 1.3 1991/04/04 14:56:42 gumby - * Minor format fixes. - * - * Revision 1.2 1991/04/03 22:09:43 steve - * Various noise - * - * Revision 1.1.1.1 1991/03/21 21:10:42 gumby - * Back from Intel with Steve - * - * Revision 1.1 1991/03/21 21:10:42 gumby - * Initial revision - * - * Revision 1.3 1991/03/16 05:55:25 rich - * pop - * - * Revision 1.2 1991/03/15 18:15:50 rich - * *** empty log message *** - * - * Revision 1.7 1991/03/08 04:18:02 rich - * *** empty log message *** - * - * Revision 1.6 1991/03/07 21:55:31 sac - * Added primitive file caching, a file open only for input and - * less than BFD_INCORE_FILE_SIZE will be malloced and read in - * only once. - * - * Revision 1.5 1991/03/05 16:31:12 sac - * lint - * */ @@ -69,6 +36,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ar.h" #include "ranlib.h" +#ifdef GNU960 +#define BFD_GNU960_ARMAG(abfd) (BFD_COFF_FILE_P((abfd)) ? ARMAG : ARMAGB) +#endif + /* We keep a cache of archive filepointers to archive elements to speed up searching the archive by filepos. We only add an entry to the cache when we actually read one. We also don't sort the cache; @@ -94,7 +65,7 @@ boolean _bfd_generic_mkarchive (abfd) bfd *abfd; { - abfd->tdata =(void *) zalloc (sizeof (struct artdata)); + abfd->tdata =(PTR) zalloc (sizeof (struct artdata)); if (abfd->tdata == NULL) { bfd_error = no_memory; @@ -239,7 +210,7 @@ snarf_ar_hdr (abfd) unsigned int allocsize = sizeof (struct areltdata) + sizeof (struct ar_hdr); char *allocptr; - if (bfd_read ((void *)hdrp, 1, sizeof (struct ar_hdr), abfd) + if (bfd_read ((PTR)hdrp, 1, sizeof (struct ar_hdr), abfd) != sizeof (struct ar_hdr)) { bfd_error = no_more_archived_files; return NULL; @@ -329,7 +300,7 @@ get_elt_at_filepos (archive, filepos) return NULL; } n_nfd->origin = bfd_tell (archive); - n_nfd->arelt_data = (void *) new_areldata; + n_nfd->arelt_data = (PTR) new_areldata; n_nfd->filename = new_areldata->filename; if (add_bfd_to_cache (archive, filepos, n_nfd)) @@ -397,12 +368,16 @@ bfd_generic_archive_p (abfd) { char armag[SARMAG+1]; - if (bfd_read ((void *)armag, 1, SARMAG, abfd) != SARMAG) { + if (bfd_read ((PTR)armag, 1, SARMAG, abfd) != SARMAG) { bfd_error = wrong_format; return 0; } +#ifdef GNU960 + if (strncmp (armag, BFD_GNU960_ARMAG(abfd), SARMAG)) return 0; +#else if (strncmp (armag, ARMAG, SARMAG)) return 0; +#endif bfd_set_ardata(abfd, (struct artdata *) zalloc (sizeof (struct artdata))); @@ -441,7 +416,7 @@ bfd_slurp_bsd_armap (abfd) struct artdata *ardata = bfd_ardata (abfd); char *stringbase; - if (bfd_read ((void *)nextname, 1, 16, abfd) == 16) { + if (bfd_read ((PTR)nextname, 1, 16, abfd) == 16) { /* The archive has at least 16 bytes in it */ bfd_seek (abfd, -16L, SEEK_CUR); @@ -461,7 +436,7 @@ bfd_slurp_bsd_armap (abfd) return false; } - if (bfd_read ((void *)raw_armap, 1, mapdata->parsed_size, abfd) != + if (bfd_read ((PTR)raw_armap, 1, mapdata->parsed_size, abfd) != mapdata->parsed_size) { bfd_error = malformed_archive; free (raw_armap); @@ -501,7 +476,7 @@ bfd_slurp_coff_armap (abfd) unsigned int stringsize; carsym *carsyms; - if (bfd_read ((void *)&nextname, 1, 1, abfd) != 1) { + if (bfd_read ((PTR)&nextname, 1, 1, abfd) != 1) { bfd_seek (abfd, -1L, SEEK_CUR); bfd_has_map(abfd) = false; return true; @@ -525,7 +500,7 @@ bfd_slurp_coff_armap (abfd) return false; } - if (bfd_read ((void *)raw_armap, 1, mapdata->parsed_size, abfd) != + if (bfd_read ((PTR)raw_armap, 1, mapdata->parsed_size, abfd) != mapdata->parsed_size) { bfd_error = malformed_archive; oops: @@ -592,7 +567,7 @@ _bfd_slurp_extended_name_table (abfd) char nextname[17]; struct areltdata *namedata; - if (bfd_read ((void *)nextname, 1, 16, abfd) == 16) { + if (bfd_read ((PTR)nextname, 1, 16, abfd) == 16) { bfd_seek (abfd, -16L, SEEK_CUR); @@ -613,7 +588,7 @@ _bfd_slurp_extended_name_table (abfd) return false; } - if (bfd_read ((void*)bfd_ardata (abfd)->extended_names, 1, + if (bfd_read ((PTR)bfd_ardata (abfd)->extended_names, 1, namedata->parsed_size, abfd) != namedata->parsed_size) { bfd_error = malformed_archive; free (bfd_ardata (abfd)->extended_names); @@ -621,6 +596,14 @@ _bfd_slurp_extended_name_table (abfd) goto byebye; } + /* It appears that the extended names are newline-padded, not null padded. + */ + { + char *temp = bfd_ardata (abfd)->extended_names; + for (; *temp != '\0'; ++temp) + if (*temp == '\n') *temp = '\0'; + } + /* Pad to an even boundary if you have to */ bfd_ardata (abfd)->first_file_filepos = bfd_tell (abfd); bfd_ardata (abfd)->first_file_filepos += @@ -658,49 +641,56 @@ bfd_construct_extended_name_table (abfd, tabloc, tablen) char **tabloc; unsigned int *tablen; { - unsigned int maxname = abfd->xvec->ar_max_namelen; - unsigned int total_namelen = 0; - bfd *current; - char *strptr; + unsigned int maxname = abfd->xvec->ar_max_namelen; + unsigned int total_namelen = 0; + bfd *current; + char *strptr; - *tablen = 0; + *tablen = 0; - /* Figure out how long the table should be */ - for (current = abfd->archive_head; current != NULL; current = current->next){ - unsigned int thislen = strlen (normalize(current->filename)); - if (thislen > maxname) total_namelen += thislen + 1; /* leave room for \0 */ - } + /* Figure out how long the table should be */ + for (current = abfd->archive_head; current != NULL; current = current->next){ + unsigned int thislen = strlen (normalize(current->filename)); + if (thislen > maxname) total_namelen += thislen + 1; /* leave room for \n */ + } - if (total_namelen == 0) return true; + if (total_namelen == 0) return true; - *tabloc = zalloc (total_namelen); - if (*tabloc == NULL) { - bfd_error = no_memory; - return false; - } + *tabloc = zalloc (total_namelen); + if (*tabloc == NULL) { + bfd_error = no_memory; + return false; + } - *tablen = total_namelen; - strptr = *tabloc; - - for (current = abfd->archive_head; current != NULL; current = - current->next) { - char *normal =normalize( current->filename); - unsigned int thislen = strlen (normal); - if (thislen > maxname) { - /* Works for now; may need to be re-engineered if we encounter an oddball - archive format and want to generalise this hack. */ - struct ar_hdr *hdr = arch_hdr(current); - strcpy (strptr, normal); - hdr->ar_name[0] = ' '; - /* We know there will always be enough room (one of the few cases - where you may safely use sprintf). */ - sprintf ((hdr->ar_name) + 1, "%-o", (unsigned) (strptr - *tabloc)); - - strptr += thislen + 1; + *tablen = total_namelen; + strptr = *tabloc; + + for (current = abfd->archive_head; current != NULL; current = + current->next) { + char *normal =normalize( current->filename); + unsigned int thislen = strlen (normal); + if (thislen > maxname) { + /* Works for now; may need to be re-engineered if we encounter an oddball + archive format and want to generalise this hack. */ + struct ar_hdr *hdr = arch_hdr(current); + strcpy (strptr, normal); + strptr[thislen] = '\n'; + hdr->ar_name[0] = ' '; + /* We know there will always be enough room (one of the few cases + where you may safely use sprintf). */ + sprintf ((hdr->ar_name) + 1, "%-o", (unsigned) (strptr - *tabloc)); + /* Kinda Kludgy. We should just use the returned value of sprintf + but not all implementations get this right */ + { + char *temp = hdr->ar_name +2; + for (; temp < hdr->ar_name + maxname; temp++) + if (*temp == '\0') *temp = ' '; } + strptr += thislen + 1; } + } - return true; + return true; } /** A couple of functions for creating ar_hdrs */ @@ -798,21 +788,35 @@ bfd_generic_stat_arch_elt (abfd, buf) return 0; } -/* Don't do anything -- it'll be taken care of later */ void -bfd_dont_truncate_arname (ignore_abfd, ignore_filename, ignore_arhdr) - bfd *ignore_abfd; - char *ignore_filename; - char *ignore_arhdr; +bfd_dont_truncate_arname (abfd, pathname, arhdr) + bfd *abfd; + char *pathname; + char *arhdr; { - /* FIXME -- Actually this is incorrect. If the name is short we - should insert into the header; only if it is long should we do - nothing. + /* This interacts unpleasantly with ar's quick-append option. + Fortunately ic960 users will never use that option. Fixing this + is very hard; fortunately I know how to do it and will do so once + intel's release is out the door. */ + + struct ar_hdr *hdr = (struct ar_hdr *) arhdr; + int length; + char *filename = strrchr (pathname, '/'); + int maxlen = ar_maxnamelen (abfd); - Anyway, this interacts unpleasantly with ar's quick-append option, - for now just be compatible with the old system */ + if (filename == NULL) + filename = pathname; + else + ++filename; + + length = strlen (filename); + if (length <= maxlen) + memcpy (hdr->ar_name, filename, length); + + if (length < maxlen) (hdr->ar_name)[length] = ar_padchar (abfd); return; + } void @@ -842,7 +846,7 @@ bfd_bsd_truncate_arname (abfd, pathname, arhdr) length = maxlen; } - if (length < 16) (hdr->ar_name)[length] = ar_padchar (abfd); + if (length < maxlen) (hdr->ar_name)[length] = ar_padchar (abfd); } /* Store name into ar header. Truncates the name to fit. @@ -912,7 +916,7 @@ _bfd_write_archive_contents (arch) } if (!current->arelt_data) { current->arelt_data = - (void *) bfd_ar_hdr_from_filesystem (current->filename); + (PTR) bfd_ar_hdr_from_filesystem (current->filename); if (!current->arelt_data) return false; /* Put in the file name */ @@ -938,7 +942,11 @@ _bfd_write_archive_contents (arch) return false; bfd_seek (arch, 0, SEEK_SET); +#ifdef GNU960 + bfd_write (BFD_GNU960_ARMAG(arch), 1, SARMAG, arch); +#else bfd_write (ARMAG, 1, SARMAG, arch); +#endif if (makemap && hasobjects) { @@ -1189,11 +1197,11 @@ coff_write_armap (arch, elength, map, orl_count, stridx) memset ((char *)(&hdr), 0, sizeof (struct ar_hdr)); hdr.ar_name[0] = '/'; sprintf (hdr.ar_size, "%-10d", (int) mapsize); - sprintf (hdr.ar_date, "%ld", time (NULL)); + sprintf (hdr.ar_date, "%ld", (long)time (NULL)); /* This, at least, is what Intel coff sets the values to.: */ sprintf ((hdr.ar_uid), "%d", 0); sprintf ((hdr.ar_gid), "%d", 0); - sprintf ((hdr.ar_mode), "%-7o", 0); + sprintf ((hdr.ar_mode), "%-7o",(unsigned ) 0); hdr.ar_fmag[0] = '`'; hdr.ar_fmag[1] = '\n'; for (i = 0; i < sizeof (struct ar_hdr); i++) @@ -38,6 +38,7 @@ short _bfd_host_big_endian = 0x0100; + /** Error handling o - Most functions return nonzero on success (check doc for precise semantics); 0 or NULL on error. @@ -62,9 +63,25 @@ char *bfd_errmsgs[] = {"No error", "File format not recognized", "File format is ambiguous", "Section has no contents", + "Nonrepresentable section on output", "#<Invalid error code>" }; + +static +void +DEFUN(bfd_nonrepresentable_section,(abfd, name), + CONST bfd * CONST abfd AND + CONST char * CONST name) +{ + printf("bfd error writing file %s, can't represent section name %s\n", abfd->filename, name); + exit(1); +} +bfd_error_vector_type bfd_error_vector = + { + bfd_nonrepresentable_section + }; + #if !defined(ANSI_LIBRARIES) char * strerror (code) @@ -78,6 +95,8 @@ strerror (code) } #endif /* not ANSI_LIBRARIES */ + + char * bfd_errmsg (error_tag) bfd_ec error_tag; @@ -94,6 +113,15 @@ bfd_errmsg (error_tag) return bfd_errmsgs [(int)error_tag]; } + +void bfd_default_error_trap(error_tag) +bfd_ec error_tag; +{ + printf("bfd assert fail (%s)\n", bfd_errmsg(error_tag)); +} + +void (*bfd_error_trap)() = bfd_default_error_trap; +void (*bfd_error_nonrepresentabltrap)() = bfd_default_error_trap; void bfd_perror (message) char *message; @@ -135,12 +163,12 @@ extern bfd_target *target_vector[]; will cause the first entry in the target list to be returned. */ bfd_target * -bfd_find_target (target_name) - char *target_name; +DEFUN(bfd_find_target,(target_name), + CONST char *target_name) { bfd_target **target; extern char *getenv (); - char *targname = (target_name ? target_name : getenv ("GNUTARGET")); + CONST char *targname = (target_name ? target_name : getenv ("GNUTARGET")); /* This is safe; the vector cannot be null */ if (targname == NULL || !strcmp (targname, "default")) @@ -247,6 +275,15 @@ bfd_check_format (abfd, format) if (temp) { /* This format checks out as ok! */ right_targ = temp; match_count++; +#ifdef GNU960 + /* Big- and little-endian b.out archives look the same, but it doesn't + * matter: there is no difference in their headers, and member file byte + * orders will (I hope) be handled appropriately by bfd. Ditto for big + * and little coff archives. And the 4 coff/b.out object formats are + * unambiguous. So accept the first match we find. + */ + break; +#endif } } @@ -298,9 +335,9 @@ bfd_set_format (abfd, format) /* Hack object and core file sections */ sec_ptr -bfd_get_section_by_name (abfd, name) - bfd *abfd; - char *name; +DEFUN(bfd_get_section_by_name,(abfd, name), + bfd *abfd AND + CONST char *name) { asection *sect; @@ -312,9 +349,9 @@ bfd_get_section_by_name (abfd, name) /* If you try to create a section with a name which is already in use, returns the old section by that name instead. */ sec_ptr -bfd_make_section (abfd, name) - bfd *abfd; - char *name; +DEFUN(bfd_make_section,(abfd, name), + bfd *abfd AND + CONST char *name) { asection *newsect; asection ** prev = &abfd->sections; @@ -367,7 +404,7 @@ void bfd_map_over_sections (abfd, operation, user_storage) bfd *abfd; void (*operation)(); - void *user_storage; + PTR user_storage; { asection *sect; int i = 0; @@ -418,7 +455,7 @@ boolean bfd_set_section_contents (abfd, section, location, offset, count) bfd *abfd; sec_ptr section; -void *location; + PTR location; file_ptr offset; int count; { @@ -441,7 +478,7 @@ boolean bfd_get_section_contents (abfd, section, location, offset, count) bfd *abfd; sec_ptr section; - void *location; + PTR location; file_ptr offset; int count; { @@ -544,7 +581,7 @@ bfd_canonicalize_reloc (abfd, asect, location, symbols) void bfd_print_symbol_vandf(file, symbol) -void *file; +PTR file; asymbol *symbol; { flagword type = symbol->flags; @@ -625,18 +662,16 @@ bfd_perform_relocation(abfd, output_bfd) bfd *abfd; arelent *reloc_entry; -void *data; +PTR data; asection *input_section; bfd *output_bfd; { bfd_vma relocation; bfd_reloc_status_enum_type flag = bfd_reloc_ok; bfd_vma relocation_before; - bfd_vma mask; - bfd_vma target_mask; bfd_vma addr = reloc_entry->address ; bfd_vma output_base = 0; - struct rint_struct *howto = reloc_entry->howto; + CONST struct rint_struct *howto = reloc_entry->howto; asection *reloc_target_output_section; asection *reloc_target_input_section; asymbol *symbol; @@ -651,7 +686,7 @@ bfd *output_bfd; symbol = (asymbol*)NULL; } - if (howto->special_function) { + if (howto->special_function){ bfd_reloc_status_enum_type cont; cont = howto->special_function(abfd, reloc_entry, @@ -662,9 +697,9 @@ bfd *output_bfd; } /* - Work out which section the relocation is targetted at and the - initial relocation command value. - */ + Work out which section the relocation is targetted at and the + initial relocation command value. + */ if (symbol != (asymbol *)NULL){ @@ -675,18 +710,18 @@ bfd *output_bfd; relocation = symbol->value; } if (symbol->section != (asection *)NULL) - { - reloc_target_input_section = symbol->section; - } + { + reloc_target_input_section = symbol->section; + } else { reloc_target_input_section = (asection *)NULL; } } else if (reloc_entry->section != (asection *)NULL) - { - relocation = 0; - reloc_target_input_section = reloc_entry->section; - } + { + relocation = 0; + reloc_target_input_section = reloc_entry->section; + } else { relocation = 0; reloc_target_input_section = (asection *)NULL; @@ -713,29 +748,29 @@ bfd *output_bfd; if(reloc_entry->address > (bfd_vma)(input_section->size)) - { - return bfd_reloc_outofrange; - } + { + return bfd_reloc_outofrange; + } if (howto->pc_relative == true) - { - /* - Anything which started out as pc relative should end up that - way too - */ + { + /* + Anything which started out as pc relative should end up that + way too + */ - relocation -= - output_base + input_section->output_offset; + relocation -= + output_base + input_section->output_offset; - } + } if (output_bfd!= (bfd *)NULL && howto->partial_inplace == false) { /* - This is a partial relocation, and we want to apply the relocation - to the reloc entry rather than the raw data. Modify the reloc - inplace to reflect what we now know. - */ + This is a partial relocation, and we want to apply the relocation + to the reloc entry rather than the raw data. Modify the reloc + inplace to reflect what we now know. + */ reloc_entry->addend = relocation ; reloc_entry->section = reloc_target_input_section; if (reloc_target_input_section != (asection *)NULL) { @@ -750,82 +785,89 @@ bfd *output_bfd; /* - Either we are relocating all the way, or we don't want to apply - the relocation to the reloc entry (probably because there isn't - any room in the output format to describe addends to relocs) - */ + Either we are relocating all the way, or we don't want to apply + the relocation to the reloc entry (probably because there isn't + any room in the output format to describe addends to relocs) + */ relocation >>= howto->rightshift; - if (howto->bitsize == 32) { - mask = ~0; - } - else { - mask = (1L << howto->bitsize) - 1 ; - mask |= mask - 1; /* FIXME, what is this? */ - } - - relocation &= mask; /* Shift everything up to where it's going to be used */ relocation <<= howto->bitpos; - mask <<= howto->bitpos; - target_mask = ~mask; - /* Wait for the day when all have the mask in them */ - BFD_ASSERT(howto->mask == mask); + /* Wait for the day when all have the mask in them */ relocation_before = relocation; - switch (howto->size) - { - case 0: - { - char x = bfd_getchar(abfd, (char *)data + addr); - relocation += x & mask; - bfd_putchar(abfd, - ( x & target_mask) | ( relocation & mask), - (unsigned char *) data + addr); - } - break; - - case 1: - { - short x = bfd_getshort(abfd, (bfd_byte *)data + addr); - relocation += x & mask; - bfd_putshort(abfd, ( x & target_mask) | (relocation & mask), - (unsigned char *)data + addr); - } - break; - case 2: - { - long x = bfd_getlong(abfd, (bfd_byte *) data + addr); - relocation += x & mask; - bfd_putlong(abfd, ( x & target_mask) | (relocation & mask), - (bfd_byte *)data + addr); - } - break; - case 3: - /* Do nothing */ - break; - default: - return bfd_reloc_other; - } + /* What we do: + i instruction to be left alone + o offset within instruction + r relocation offset to apply + S src mask + D dst mask + N ~dst mask + A part 1 + B part 2 + R result + + Do this: + i i i i i o o o o o from bfd_get<size> + and S S S S S to get the size offset we want + + r r r r r r r r r r to get the final value to place + and D D D D D to chop to right size + ----------------------- + A A A A A + And this: + i i i i i o o o o o from bfd_get<size> + and N N N N N get instruction + ----------------------- + B B B B B + + And then: + B B B B B + or A A A A A + ----------------------- + R R R R R R R R R R put into bfd_put<size> + */ - /* See if important parts of the relocation were chopped to make - it fit into the relocation field. (ie are there any significant - bits left over after the masking ? */ - if ((relocation_before & target_mask) != 0 && - howto->complain_on_overflow == true) - { - /* Its ok if the bit which fell off is */ - return bfd_reloc_overflow; - } +#define DOIT(x) \ + x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask)) + + switch (howto->size) + { + case 0: + { + char x = bfd_getchar(abfd, (char *)data + addr); + DOIT(x); + bfd_putchar(abfd,x, (unsigned char *) data + addr); + } + break; + + case 1: + { + short x = bfd_getshort(abfd, (bfd_byte *)data + addr); + DOIT(x); + bfd_putshort(abfd, x, (unsigned char *)data + addr); + } + break; + case 2: + { + long x = bfd_getlong(abfd, (bfd_byte *) data + addr); +DOIT(x); + bfd_putlong(abfd,x, (bfd_byte *)data + addr); + } + break; + case 3: + /* Do nothing */ + break; + default: + return bfd_reloc_other; + } } - return flag; } diff --git a/bfd/coff-code.h b/bfd/coff-code.h index ba9832c90e..fd12c47e5b 100755 --- a/bfd/coff-code.h +++ b/bfd/coff-code.h @@ -138,7 +138,7 @@ bfd_coff_swap_sym(abfd, se) bfd_h_put_x(abfd, se->n_numaux, &se->n_numaux); } -static void +void bfd_coff_swap_aux(abfd, au, type, class) bfd *abfd; AUXENT *au; @@ -184,7 +184,7 @@ bfd_coff_swap_aux(abfd, au, type, class) } } -static void +void bfd_coff_swap_lineno(abfd, lineno) bfd *abfd; LINENO *lineno; @@ -206,7 +206,7 @@ get_index(symbol) return (int) symbol->value; } -static void +static void set_index(symbol, idx) asymbol *symbol; unsigned int idx; @@ -235,7 +235,7 @@ make_a_section_from_file(abfd, hdr) { asection *return_section; { - char *name = malloc(9); + char *name = (PTR) malloc(9); if (name == NULL) { bfd_error = no_memory; return (BFD_FAILURE); @@ -311,7 +311,7 @@ coff_real_object_p(abfd, nscns, opthdr) + opthdr + (nscns * sizeof(struct scnhdr)); - file_info = malloc(readsize); + file_info = (PTR) malloc(readsize); if (file_info == NULL) { bfd_error = no_memory; return 0; @@ -1054,7 +1054,7 @@ coff_print_symbol(ignore_abfd, file, symbol, how) break; case bfd_print_symbol_all_enum: { - char *section_name = symbol->section == (asection *) NULL ? + CONST char *section_name = symbol->section == (asection *) NULL ? "*abs" : symbol->section->name; bfd_print_symbol_vandf((PTR) file, symbol); @@ -1455,7 +1455,7 @@ static boolean coff_set_section_contents(abfd, section, location, offset, count) bfd *abfd; sec_ptr section; - PTR location; + PTR location; file_ptr offset; size_t count; { @@ -1473,7 +1473,7 @@ static boolean coff_get_section_contents(abfd, section, location, offset, count) bfd *abfd; sec_ptr section; - PTR location; + PTR location; file_ptr offset; int count; { @@ -1528,18 +1528,18 @@ buy_and_read(abfd, where, seek_direction, size) int seek_direction; size_t size; { - PTR area = (PTR) malloc(size); - if (!area) { - bfd_error = no_memory; - return (NULL); - } - bfd_seek(abfd, where, seek_direction); - if (bfd_read(area, 1, size, abfd) != size) { - bfd_error = system_call_error; - free(area); - return (NULL); - } /* on error */ - return (area); + PTR area = (PTR) malloc(size); + if (!area) { + bfd_error = no_memory; + return (NULL); + } + bfd_seek(abfd, where, seek_direction); + if (bfd_read(area, 1, size, abfd) != size) { + bfd_error = system_call_error; + free(area); + return (NULL); + } /* on error */ + return (area); } /* buy_and_read() */ static void @@ -1685,7 +1685,7 @@ get_normalized_symtab(abfd) } else { unsigned long namelength = 0; - char *filename; + CONST char *filename; obj_symbol_slew(abfd) = 2; if ((retval = (SYMENT *) malloc(size @@ -1764,12 +1764,12 @@ get_normalized_symtab(abfd) } /* if end of string */ } /* possible lengths of this string. */ - if ((newstring = malloc(++i)) == NULL) { + if ((newstring = (PTR) malloc(++i)) == NULL) { bfd_error = no_memory; return (NULL); } /* on error */ bzero(newstring, i); - strncpy(newstring, s->n_name, i -1 ); + strncpy(newstring, s->n_name, i-1); s->n_offset = (int) newstring; s->n_zeroes = 0; @@ -1791,7 +1791,7 @@ get_normalized_symtab(abfd) } /* on error */ sp(string_table_size); - if ((string_table = malloc(string_table_size -= 4)) == NULL) { + if ((string_table = (PTR) malloc(string_table_size -= 4)) == NULL) { bfd_error = no_memory; return (NULL); } /* on mallocation error */ @@ -1867,7 +1867,7 @@ coff_get_next_symbol(abfd, oidx) return ++oidx >= bfd_get_symcount(abfd) ? BFD_NO_MORE_SYMBOLS : oidx; } -static char * +static CONST char * coff_symbol_name(abfd, idx) bfd *abfd; symindex idx; @@ -2004,7 +2004,7 @@ find_next_file_symbol(current, end) Note that C_FILE symbols can, and some do, have more than 1 aux entry. */ -static void +static void force_indices_file_symbol_relative(abfd, symtab) bfd *abfd; SYMENT *symtab; @@ -2386,20 +2386,20 @@ coff_canonicalize_reloc(abfd, section, relptr, symbols) */ static boolean -coff_find_nearest_line(abfd, - section, - symbols, - offset, - filename_ptr, - functionname_ptr, - line_ptr) - bfd *abfd; - asection *section; - asymbol **symbols; - bfd_vma offset; - char **filename_ptr; - char **functionname_ptr; - unsigned int *line_ptr; +DEFUN(coff_find_nearest_line,(abfd, + section, + symbols, + offset, + filename_ptr, + functionname_ptr, + line_ptr), + bfd *abfd AND + asection *section AND + asymbol **symbols AND + bfd_vma offset AND + CONST char **filename_ptr AND + CONST char **functionname_ptr AND + unsigned int *line_ptr) { static bfd *cache_abfd; static asection *cache_section; diff --git a/bfd/libaout.h b/bfd/libaout.h index febe2f4788..43195f5bc6 100644 --- a/bfd/libaout.h +++ b/bfd/libaout.h @@ -61,7 +61,7 @@ struct sunexdata { }; -#define obj_outsymbols(bfd) ((void *)(((struct sunexdata *) ((bfd)->tdata))->outsymbols)) +#define obj_outsymbols(bfd) ((PTR)(((struct sunexdata *) ((bfd)->tdata))->outsymbols)) @@ -75,6 +75,6 @@ struct sunexdata { #define obj_arch_flags(bfd) ((((struct sunexdata *) (bfd)->tdata))->arch_flags) #define get_tdata(x) ((struct sunexdata *)((x)->tdata)) -#define set_tdata(x,y) ((x)->tdata = (void *) (y)) +#define set_tdata(x,y) ((x)->tdata = (PTR) (y)) diff --git a/bfd/libbfd.c b/bfd/libbfd.c index 9998690f04..4a6219b13c 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -115,7 +115,7 @@ char * zalloc (size) size_t size; { - char *ptr = malloc (size); + char *ptr = (char *) malloc (size); if ((ptr != NULL) && (size != 0)) bzero (ptr, size); @@ -136,7 +136,7 @@ zalloc (size) size_t bfd_read (ptr, size, nitems, abfd) - void *ptr; + PTR ptr; size_t size; size_t nitems; bfd *abfd; @@ -146,19 +146,19 @@ bfd_read (ptr, size, nitems, abfd) size_t bfd_write (ptr, size, nitems, abfd) - void *ptr; + PTR ptr; size_t size; size_t nitems; bfd *abfd; { - return fwrite (ptr, 1, size*nitems, bfd_cache_lookup(abfd)); + return fwrite (ptr, 1, size*nitems, bfd_cache_lookup(abfd)); } int bfd_seek (abfd, position, direction) -bfd *abfd; -file_ptr position; -int direction; +bfd * CONST abfd; +CONST file_ptr position; +CONST int direction; { /* For the time being, a bfd may not seek to it's end. The problem is that we don't easily have a way to recognize diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 790d957c30..2ff951f039 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -44,7 +44,7 @@ struct artdata { }; #define bfd_ardata(bfd) ((struct artdata *) ((bfd)->tdata)) -#define bfd_set_ardata(bfd, v) ((bfd)->tdata = (void *) (v)) +#define bfd_set_ardata(bfd, v) ((bfd)->tdata = (PTR) (v)) /* Goes in bfd's arelt_data slot */ struct areltdata { @@ -60,16 +60,16 @@ struct areltdata { it before it becomes a problem -- Gumby */ PROTO (char *, zalloc, (size_t size)); -PROTO (char *, realloc, (char * ptr, size_t size)); -PROTO (bfd_target *, bfd_find_target, (char *target_name)); -PROTO (size_t, bfd_read, (void *ptr, size_t size, size_t nitems, bfd *abfd)); -PROTO (size_t, bfd_write, (void *ptr, size_t size, size_t nitems, bfd *abfd)); + +PROTO (bfd_target *, bfd_find_target, (CONST char *target_name)); +PROTO (size_t, bfd_read, (PTR ptr, size_t size, size_t nitems, bfd *abfd)); +PROTO (size_t, bfd_write, (PTR ptr, size_t size, size_t nitems, bfd *abfd)); PROTO (FILE *, bfd_cache_lookup, (bfd *)); PROTO (void, bfd_cache_close, (bfd *)); -PROTO (int, bfd_seek,(bfd*, file_ptr, int direction)); +PROTO (int, bfd_seek,(bfd* abfd, file_ptr fp , int direction)); PROTO (long, bfd_tell, (bfd *abfd)); PROTO (bfd *, _bfd_create_empty_archive_element_shell, (bfd *obfd)); PROTO (bfd *, look_for_bfd_in_cache, (bfd *arch_bfd, file_ptr index)); diff --git a/bfd/opncls.c b/bfd/opncls.c index 63e9c51dae..585acea507 100644 --- a/bfd/opncls.c +++ b/bfd/opncls.c @@ -67,7 +67,7 @@ bfd *new_bfd() nbfd->opened_once = false; nbfd->output_has_begun = false; nbfd->section_count = 0; - nbfd->usrdata = (void *)NULL; + nbfd->usrdata = (PTR)NULL; nbfd->sections = (asection *)NULL; nbfd->cacheable = false; nbfd->flags = NO_FLAGS; @@ -76,7 +76,7 @@ bfd *new_bfd() bfd *new_bfd_contained_in(obfd) bfd *obfd; { - bfd *nbfd = new_bfd(obfd); + bfd *nbfd = new_bfd(); nbfd->xvec = obfd->xvec; nbfd->my_archive = obfd; nbfd->direction = read_direction; @@ -87,9 +87,9 @@ bfd *obfd; Returns a pointer to a freshly-allocated bfd on success, or NULL. */ bfd * -bfd_openr (filename, target) - char *filename; - char *target; +DEFUN(bfd_openr, (filename, target), + CONST char *filename AND + CONST char *target) { bfd *nbfd; bfd_target *target_vec; @@ -130,10 +130,10 @@ bfd_openr (filename, target) */ bfd * -bfd_fdopenr (filename, target, fd) - char *filename; - char *target; - int fd; +DEFUN(bfd_fdopenr,(filename, target, fd), + CONST char *filename AND + CONST char *target AND + int fd) { bfd *nbfd; bfd_target *target_vec; @@ -204,9 +204,9 @@ bfd_fdopenr (filename, target, fd) See comment by bfd_fdopenr before you try to modify this function. */ bfd * -bfd_openw (filename, target) - char *filename; - char *target; +DEFUN(bfd_openw,(filename, target), + CONST char *filename AND + CONST char *target) { bfd *nbfd; bfd_target *target_vec; @@ -262,9 +262,9 @@ bfd_close (abfd) called to create a bfd with no ascociated file or target */ bfd * -bfd_create(filename, template) -char *filename; -bfd *template; +DEFUN(bfd_create,(filename, template), + CONST char *filename AND + CONST bfd *template) { bfd *nbfd = new_bfd(); if (nbfd == (bfd *)NULL) { diff --git a/bfd/sunos.c b/bfd/sunos.c index 9b554b65ff..a88d39137f 100644 --- a/bfd/sunos.c +++ b/bfd/sunos.c @@ -31,6 +31,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ void (*bfd_error_trap)(); + /*SUPPRESS558*/ /*SUPPRESS529*/ @@ -50,52 +51,54 @@ typedef void generic_symbol_type; #include "a.out.sun4.h" #define CTOR_TABLE_RELOC_IDX 2 -static CONST reloc_howto_type howto_table_ext[] = +static reloc_howto_type howto_table_ext[] = { /* type rs size bsz pcrel bitpos abs ovrf sf name partial inplace mask*/ -{ (unsigned int) RELOC_8, 0, 0, 8, false, 0, true, true,0,"8", false, 0x000000ff}, -{ (unsigned int) RELOC_16, 0, 1, 16, false, 0, true, true,0,"16", false, 0x0000ffff}, -{ (unsigned int) RELOC_32, 0, 2, 32, false, 0, true, true,0,"32", false, 0xffffffff}, -{ (unsigned int) RELOC_DISP8, 0, 0, 8, true, 0, false, true,0,"DISP8", false, 0x000000ff}, -{ (unsigned int) RELOC_DISP16, 0, 1, 16, true, 0, false, true,0,"DISP16", false, 0x0000ffff}, -{ (unsigned int) RELOC_DISP32, 0, 2, 32, true, 0, false, true,0,"DISP32", false, 0xffffffff}, -{ (unsigned int) RELOC_WDISP30,2, 2, 30, true, 0, false, true,0,"WDISP30", false, 0x3fffffff}, -{ (unsigned int) RELOC_WDISP22,2, 2, 22, true, 0, false, true,0,"WDISP22", false, 0x003fffff}, -{ (unsigned int) RELOC_HI22, 10, 2, 22, false, 0, false, true,0,"HI22", false, 0x003fffff}, -{ (unsigned int) RELOC_22, 0, 2, 22, false, 0, false, true,0,"22", false, 0x003fffff}, -{ (unsigned int) RELOC_13, 0, 2, 13, false, 0, false, true,0,"13", false, 0x00001fff}, -{ (unsigned int) RELOC_LO10, 0, 2, 10, false, 0, false, true,0,"LO10", false, 0x000003ff}, -{ (unsigned int) RELOC_SFA_BASE,0, 2, 32, false, 0, false, true,0,"SFA_BASE", false, 0xffffffff}, -{ (unsigned int) RELOC_SFA_OFF13,0,2, 32, false, 0, false, true,0,"SFA_OFF13",false, 0xffffffff}, -{ (unsigned int) RELOC_BASE10, 0, 2, 16, false, 0, false, true,0,"BASE10", false, 0x0000ffff}, -{ (unsigned int) RELOC_BASE13, 0, 2, 13, false, 0, false, true,0,"BASE13", false, 0x00001fff}, -{ (unsigned int) RELOC_BASE22, 0, 2, 0, false, 0, false, true,0,"BASE22", false, 0x00000000}, -{ (unsigned int) RELOC_PC10, 0, 2, 10, false, 0, false, true,0,"PC10", false, 0x000003ff}, -{ (unsigned int) RELOC_PC22, 0, 2, 22, false, 0, false, true,0,"PC22", false, 0x003fffff}, -{ (unsigned int) RELOC_JMP_TBL,0, 2, 32, false, 0, false, true,0,"JMP_TBL", false, 0xffffffff}, -{ (unsigned int) RELOC_SEGOFF16,0, 2, 0, false, 0, false, true,0,"SEGOFF16", false, 0x00000000}, -{ (unsigned int) RELOC_GLOB_DAT,0, 2, 0, false, 0, false, true,0,"GLOB_DAT", false, 0x00000000}, -{ (unsigned int) RELOC_JMP_SLOT,0, 2, 0, false, 0, false, true,0,"JMP_SLOT", false, 0x00000000}, -{ (unsigned int) RELOC_RELATIVE,0, 2, 0, false, 0, false, true,0,"RELATIVE", false, 0x00000000}, -{ (unsigned int) RELOC_JUMPTARG,2, 13, 16, true, 0, false, true,0,"JUMPTARG", false, 0x0000ffff}, -{ (unsigned int) RELOC_CONST, 0, 13, 16, false, 0, false, true,0,"CONST", false, 0x0000ffff}, -{ (unsigned int) RELOC_CONSTH, 16, 13, 16, false, 0, false, true,0,"CONSTH", false, 0x0000ffff}, +{ (unsigned int) RELOC_8, 0, 0, 8, false, 0, true, true,0,"8", false, 0,0x000000ff}, +{ (unsigned int) RELOC_16, 0, 1, 16, false, 0, true, true,0,"16", false, 0,0x0000ffff}, +{ (unsigned int) RELOC_32, 0, 2, 32, false, 0, true, true,0,"32", false, 0,0xffffffff}, +{ (unsigned int) RELOC_DISP8, 0, 0, 8, true, 0, false, true,0,"DISP8", false, 0,0x000000ff}, +{ (unsigned int) RELOC_DISP16, 0, 1, 16, true, 0, false, true,0,"DISP16", false, 0,0x0000ffff}, +{ (unsigned int) RELOC_DISP32, 0, 2, 32, true, 0, false, true,0,"DISP32", false, 0,0xffffffff}, +{ (unsigned int) RELOC_WDISP30,2, 2, 30, true, 0, false, true,0,"WDISP30", false, 0,0x3fffffff}, +{ (unsigned int) RELOC_WDISP22,2, 2, 22, true, 0, false, true,0,"WDISP22", false, 0,0x003fffff}, +{ (unsigned int) RELOC_HI22, 10, 2, 22, false, 0, false, true,0,"HI22", false, 0,0x003fffff}, +{ (unsigned int) RELOC_22, 0, 2, 22, false, 0, false, true,0,"22", false, 0,0x003fffff}, +{ (unsigned int) RELOC_13, 0, 2, 13, false, 0, false, true,0,"13", false, 0,0x00001fff}, +{ (unsigned int) RELOC_LO10, 0, 2, 10, false, 0, false, true,0,"LO10", false, 0,0x000003ff}, +{ (unsigned int) RELOC_SFA_BASE,0, 2, 32, false, 0, false, true,0,"SFA_BASE", false, 0,0xffffffff}, +{ (unsigned int) RELOC_SFA_OFF13,0,2, 32, false, 0, false, true,0,"SFA_OFF13",false, 0,0xffffffff}, +{ (unsigned int) RELOC_BASE10, 0, 2, 16, false, 0, false, true,0,"BASE10", false, 0,0x0000ffff}, +{ (unsigned int) RELOC_BASE13, 0, 2, 13, false, 0, false, true,0,"BASE13", false, 0,0x00001fff}, +{ (unsigned int) RELOC_BASE22, 0, 2, 0, false, 0, false, true,0,"BASE22", false, 0,0x00000000}, +{ (unsigned int) RELOC_PC10, 0, 2, 10, false, 0, false, true,0,"PC10", false, 0,0x000003ff}, +{ (unsigned int) RELOC_PC22, 0, 2, 22, false, 0, false, true,0,"PC22", false, 0,0x003fffff}, +{ (unsigned int) RELOC_JMP_TBL,0, 2, 32, false, 0, false, true,0,"JMP_TBL", false, 0,0xffffffff}, +{ (unsigned int) RELOC_SEGOFF16,0, 2, 0, false, 0, false, true,0,"SEGOFF16", false, 0,0x00000000}, +{ (unsigned int) RELOC_GLOB_DAT,0, 2, 0, false, 0, false, true,0,"GLOB_DAT", false, 0,0x00000000}, +{ (unsigned int) RELOC_JMP_SLOT,0, 2, 0, false, 0, false, true,0,"JMP_SLOT", false, 0,0x00000000}, +{ (unsigned int) RELOC_RELATIVE,0, 2, 0, false, 0, false, true,0,"RELATIVE", false, 0,0x00000000}, +{ (unsigned int) RELOC_JUMPTARG,2, 13, 16, true, 0, false, true,0,"JUMPTARG", false, 0,0x0000ffff}, +{ (unsigned int) RELOC_CONST, 0, 13, 16, false, 0, false, true,0,"CONST", false, 0,0x0000ffff}, +{ (unsigned int) RELOC_CONSTH, 16, 13, 16, false, 0, false, true,0,"CONSTH", false, 0,0x0000ffff}, }; /* Convert standard reloc records to "arelent" format (incl byte swap). */ -static CONST reloc_howto_type howto_table_std[] = { +static reloc_howto_type howto_table_std[] = { /* type rs size bsz pcrel bitpos abs ovrf sf name*/ -{ (unsigned int) 0, 0, 0, 8, false, 0, true, true,0,"8", true, 0x000000ff}, -{ (unsigned int) 1, 0, 1, 16, false, 0, true, true,0,"16", true, 0x0000ffff}, -{ (unsigned int) 2, 0, 2, 32, false, 0, true, true,0,"32", true, 0xffffffff}, -{ (unsigned int) 3, 0, 3, 64, false, 0, true, true,0,"64", true, 0xdeaddead}, -{ (unsigned int) 4, 0, 0, 8, true, 0, false, true,0,"DISP8", true, 0x000000ff}, -{ (unsigned int) 5, 0, 1, 16, true, 0, false, true,0,"DISP16", true, 0x0000ffff}, -{ (unsigned int) 6, 0, 2, 32, true, 0, false, true,0,"DISP32", true, 0xffffffff}, -{ (unsigned int) 7, 0, 3, 64, true, 0, false, true,0,"DISP64", true, 0xfeedface}, +{ (unsigned int) 0, 0, 0, 8, false, 0, true, true,0,"8", true, 0x000000ff,0x000000ff}, +{ (unsigned int) 1, 0, 1, 16, false, 0, true, true,0,"16", true, 0x0000ffff,0x0000ffff}, +{ (unsigned int) 2, 0, 2, 32, false, 0, true, true,0,"32", true, 0xffffffff,0xffffffff}, +{ (unsigned int) 3, 0, 3, 64, false, 0, true, true,0,"64", true, 0xdeaddead,0xdeaddead}, +{ (unsigned int) 4, 0, 0, 8, true, 0, false, true,0,"DISP8", true, 0x000000ff,0x000000ff}, +{ (unsigned int) 5, 0, 1, 16, true, 0, false, true,0,"DISP16", true, 0x0000ffff,0x0000ffff}, +{ (unsigned int) 6, 0, 2, 32, true, 0, false, true,0,"DISP32", true, 0xffffffff,0xffffffff}, +{ (unsigned int) 7, 0, 3, 64, true, 0, false, true,0,"DISP64", true, 0xfeedface,0xfeedface}, }; + +bfd_error_vector_type bfd_error_vector; /** a.out files */ @@ -116,11 +119,11 @@ bfd *abfd; } } -void -bfd_aout_swap_exec_header_in (abfd, raw_bytes, execp) - bfd *abfd; - unsigned char *raw_bytes; - struct exec *execp; +static void +DEFUN(bfd_aout_swap_exec_header_in,(abfd, raw_bytes, execp), + bfd *abfd AND + unsigned char *raw_bytes AND + struct exec *execp) { struct exec_bytes *bytes = (struct exec_bytes *)raw_bytes; @@ -135,11 +138,11 @@ bfd_aout_swap_exec_header_in (abfd, raw_bytes, execp) execp->a_drsize = bfd_h_getlong (abfd, bytes->a_drsize); } -void -bfd_aout_swap_exec_header_out (abfd, execp, raw_bytes) - bfd *abfd; - struct exec *execp; - unsigned char *raw_bytes; +static void +DEFUN(bfd_aout_swap_exec_header_out,(abfd, execp, raw_bytes), + bfd *abfd AND + struct exec *execp AND + unsigned char *raw_bytes) { struct exec_bytes *bytes = (struct exec_bytes *)raw_bytes; @@ -183,6 +186,7 @@ static unsigned int n_stroff(ptr) struct exec *ptr; {return n_symoff(ptr) + ptr->a_syms;} +static unsigned int n_badmag(ptr) struct exec *ptr; { @@ -200,11 +204,11 @@ sunos4_object_p (abfd) unsigned long magic; /* Swapped magic number */ unsigned char exec_bytes[EXEC_BYTES_SIZE]; /* Raw bytes of exec hdr */ struct exec *execp; - void *rawptr; + PTR rawptr; bfd_error = system_call_error; - if (bfd_read ((void *)magicbuf, 1, sizeof (magicbuf), abfd) != + if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) != sizeof (magicbuf)) return 0; magic = bfd_h_getlong (abfd, magicbuf); @@ -215,14 +219,14 @@ sunos4_object_p (abfd) if (bfd_seek (abfd, 0L, false) < 0) return 0; - if (bfd_read ((void *) exec_bytes, 1, EXEC_BYTES_SIZE, abfd) + if (bfd_read ((PTR) exec_bytes, 1, EXEC_BYTES_SIZE, abfd) != EXEC_BYTES_SIZE) { bfd_error = wrong_format; return 0; } /* Use an intermediate variable for clarity */ - rawptr = (void *) zalloc (sizeof (struct sunexdata) + sizeof (struct exec)); + rawptr = (PTR) zalloc (sizeof (struct sunexdata) + sizeof (struct exec)); if (rawptr == NULL) { bfd_error = no_memory; @@ -343,7 +347,7 @@ sunos4_mkobject (abfd) return false; } - abfd->tdata = (void *)((struct sunexdata *) rawptr); + abfd->tdata = (PTR)((struct sunexdata *) rawptr); exec_hdr (abfd) = (struct exec *) (rawptr + sizeof (struct sunexdata)); /* For simplicity's sake we just make all the sections right here. */ @@ -422,7 +426,7 @@ boolean sunos4_write_object_contents (abfd) bfd *abfd; { - unsigned int data_pad = 0; + size_t data_pad = 0; unsigned char exec_bytes[EXEC_BYTES_SIZE]; struct exec *execp = exec_hdr (abfd); @@ -464,17 +468,17 @@ sunos4_write_object_contents (abfd) N_SET_FLAGS (*execp, 0x1); /* copied from ld.c; who the hell knows? */ if (abfd->flags & D_PAGED) - { - data_pad = ((obj_datasec(abfd)->size + PAGE_SIZE -1) - & (- PAGE_SIZE)) - obj_datasec(abfd)->size; + { + data_pad = ((obj_datasec(abfd)->size + PAGE_SIZE -1) + & (- PAGE_SIZE)) - obj_datasec(abfd)->size; - if (data_pad > obj_bsssec(abfd)->size) - execp->a_bss = 0; - else - execp->a_bss = obj_bsssec(abfd)->size - data_pad; - execp->a_data = obj_datasec(abfd)->size + data_pad; + if (data_pad > obj_bsssec(abfd)->size) + execp->a_bss = 0; + else + execp->a_bss = obj_bsssec(abfd)->size - data_pad; + execp->a_data = obj_datasec(abfd)->size + data_pad; - } + } else { execp->a_data = obj_datasec (abfd)->size; execp->a_bss = obj_bsssec (abfd)->size; @@ -492,7 +496,7 @@ sunos4_write_object_contents (abfd) bfd_aout_swap_exec_header_out (abfd, execp, exec_bytes); bfd_seek (abfd, 0L, false); - bfd_write ((void *) exec_bytes, 1, EXEC_BYTES_SIZE, abfd); + bfd_write ((PTR) exec_bytes, 1, EXEC_BYTES_SIZE, abfd); /* Now write out reloc info, followed by syms and strings */ @@ -609,7 +613,7 @@ sunos4_core_file_p (abfd) bfd_error = system_call_error; - if (bfd_read ((void *)longbuf, 1, sizeof (longbuf), abfd) != + if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) != sizeof (longbuf)) return 0; core_mag = bfd_h_getlong (abfd, longbuf); @@ -617,7 +621,7 @@ sunos4_core_file_p (abfd) if (core_mag != CORE_MAGIC) return 0; /* SunOS core headers can vary in length; second word is size; */ - if (bfd_read ((void *)longbuf, 1, sizeof (longbuf), abfd) != + if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) != sizeof (longbuf)) return 0; core_size = bfd_h_getlong (abfd, longbuf); @@ -635,9 +639,9 @@ sunos4_core_file_p (abfd) core = (struct core *) (rawptr + sizeof (struct suncordata)); - if ((bfd_read ((void *) core, 1, core_size, abfd)) != core_size) { + if ((bfd_read ((PTR) core, 1, core_size, abfd)) != core_size) { bfd_error = system_call_error; - free ((void *)rawptr); + free ((PTR)rawptr); return 0; } @@ -651,24 +655,24 @@ sunos4_core_file_p (abfd) if (core_stacksec (abfd) == NULL) { loser: bfd_error = no_memory; - free ((void *)rawptr); + free ((PTR)rawptr); return 0; } core_datasec (abfd) = (asection *) zalloc (sizeof (asection)); if (core_datasec (abfd) == NULL) { loser1: - free ((void *)core_stacksec (abfd)); + free ((PTR)core_stacksec (abfd)); goto loser; } core_regsec (abfd) = (asection *) zalloc (sizeof (asection)); if (core_regsec (abfd) == NULL) { loser2: - free ((void *)core_datasec (abfd)); + free ((PTR)core_datasec (abfd)); goto loser1; } core_reg2sec (abfd) = (asection *) zalloc (sizeof (asection)); if (core_reg2sec (abfd) == NULL) { - free ((void *)core_regsec (abfd)); + free ((PTR)core_regsec (abfd)); goto loser2; } @@ -837,7 +841,7 @@ sunos4_set_section_contents (abfd, section, location, offset, count) bfd_seek (abfd, section->filepos + offset, SEEK_SET); if (count) { - return (bfd_write ((void *)location, 1, count, abfd) == count) ? + return (bfd_write ((PTR)location, 1, count, abfd) == count) ? true : false; } return false; @@ -846,7 +850,7 @@ boolean sunos4_get_section_contents (abfd, section, location, offset, count) bfd *abfd; sec_ptr section; - void *location; + PTR location; file_ptr offset; int count; { @@ -1057,8 +1061,8 @@ translate_to_native_sym_flags (sym_pointer, cache_ptr_g, abfd) sym_pointer->n_type |= N_TEXT; } else { - bfd_error_trap(bfd_error_nonrepresentable_section, - bfd_get_output_section(cache_ptr)->name); + + bfd_error_vector.nonrepresentable_section(abfd, bfd_get_output_section(cache_ptr)->name); } /* Turn the symbol from section relative to absolute again */ @@ -1106,8 +1110,8 @@ bfd *abfd; } boolean -sunos4_slurp_symbol_table (abfd) - bfd *abfd; +DEFUN(sunos4_slurp_symbol_table, (abfd), + bfd *abfd) { unsigned int symbol_count; size_t symbol_size; @@ -1125,7 +1129,7 @@ sunos4_slurp_symbol_table (abfd) } bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET); - if (bfd_read ((void *)&string_size, 4, 1, abfd) != 4) + if (bfd_read ((PTR)&string_size, 4, 1, abfd) != 4) return false; string_size = bfd_h_getlong (abfd, (unsigned char *)&string_size); @@ -1144,22 +1148,22 @@ sunos4_slurp_symbol_table (abfd) (symbol_count * sizeof (aout_symbol_type)))); if (cached == NULL) { bfd_error = no_memory; - free ((void *)syms); + free ((PTR)syms); return false; } strings = ((char *) cached) + (symbol_count * sizeof (aout_symbol_type)); bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET); - if (bfd_read ((void *)syms, 1, symbol_size, abfd) != symbol_size) { + if (bfd_read ((PTR)syms, 1, symbol_size, abfd) != symbol_size) { bailout: - free ((void *)cached); - free ((void*)syms); + free ((PTR)cached); + free ((PTR)syms); return false; } bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET); - if (bfd_read ((void *)strings, 1, string_size, abfd) != string_size) { + if (bfd_read ((PTR)strings, 1, string_size, abfd) != string_size) { goto bailout; } @@ -1169,7 +1173,6 @@ sunos4_slurp_symbol_table (abfd) register struct nlist *sym_end = syms + symbol_count; register aout_symbol_type *cache_ptr = cached; - if (bfd_header_twiddle_required (abfd) == true) { /* run through the table and byte swap if needed */ for (sym_pointer = syms; sym_pointer < sym_end; sym_pointer++) { sym_pointer->n_un.n_strx = @@ -1184,7 +1187,7 @@ sunos4_slurp_symbol_table (abfd) bfd_h_get_x(abfd, &sym_pointer->n_type); } - } + /* Run through table and copy values */ for (sym_pointer = syms, cache_ptr = cached; sym_pointer < sym_end; sym_pointer++, cache_ptr++) @@ -1206,15 +1209,15 @@ sunos4_slurp_symbol_table (abfd) obj_aout_symbols (abfd) = cached; bfd_get_symcount (abfd) = symbol_count; - free ((void *)syms); + free ((PTR)syms); return true; } - + void -sunos4_write_syms (abfd) - bfd *abfd; +DEFUN(sunos4_write_syms,(abfd), + bfd *abfd) { unsigned int count ; asymbol **generic = bfd_get_outsymbols (abfd); @@ -1254,7 +1257,7 @@ sunos4_write_syms (abfd) bfd_h_putshort (abfd, nsp.n_desc, (unsigned char *)&nsp.n_desc); bfd_h_putlong (abfd, nsp.n_value, (unsigned char *)&nsp.n_value); - bfd_write((void *)&nsp,1, sizeof(nsp), abfd); + bfd_write((PTR)&nsp,1, sizeof(nsp), abfd); } @@ -1263,7 +1266,7 @@ sunos4_write_syms (abfd) */ bfd_h_putlong (abfd, stindex, (unsigned char *)&stindex); - bfd_write((void *)&stindex, 1, sizeof(stindex), abfd); + bfd_write((PTR)&stindex, 1, sizeof(stindex), abfd); generic = bfd_get_outsymbols(abfd); for (count = 0; count < bfd_get_symcount(abfd); count++) @@ -1273,7 +1276,7 @@ sunos4_write_syms (abfd) if (g->name != (char *)NULL) { size_t length = strlen(g->name)+1; - bfd_write((void *)g->name, 1, length, abfd); + bfd_write((PTR)g->name, 1, length, abfd); } if ((g->flags & BSF_FAKE)==0) { g->name = itos(count); /* smash the generic symbol */ @@ -1281,10 +1284,10 @@ sunos4_write_syms (abfd) } } - + void -sunos4_reclaim_symbol_table (abfd) - bfd *abfd; +DEFUN(sunos4_reclaim_symbol_table,(abfd), + bfd *abfd) { asection *section; @@ -1294,13 +1297,13 @@ sunos4_reclaim_symbol_table (abfd) section != (asection *) NULL; section = section->next) if (section->relocation) { - free ((void *)section->relocation); + free ((PTR)section->relocation); section->relocation = NULL; section->reloc_count = 0; } bfd_get_symcount (abfd) = 0; - free ((void *)obj_aout_symbols (abfd)); + free ((PTR)obj_aout_symbols (abfd)); obj_aout_symbols (abfd) = (aout_symbol_type *)NULL; } @@ -1361,7 +1364,7 @@ sunos4_get_next_symbol (abfd, oidx) return ++oidx >= bfd_get_symcount (abfd) ? BFD_NO_MORE_SYMBOLS : oidx; } -char * +CONST char * sunos4_symbol_name (abfd, idx) bfd *abfd; symindex idx; @@ -1435,7 +1438,7 @@ swap_std_reloc_out (abfd, p, natptr, count) bfd_h_putlong (abfd, g->address, natptr->r_address); r_length = g->howto->size; /* Size as a power of two */ - r_pcrel = g->howto->pc_relative; /* Relative to PC? */ + r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */ /* r_baserel, r_jmptable, r_relative??? FIXME-soon */ r_baserel = 0; r_jmptable = 0; @@ -1715,7 +1718,7 @@ sunos4_slurp_reloc_table (abfd, asect, symbols) { unsigned int count; size_t reloc_size; - void *relocs; + PTR relocs; arelent *reloc_cache; size_t each_size; @@ -1742,7 +1745,7 @@ sunos4_slurp_reloc_table (abfd, asect, symbols) count = reloc_size / each_size; - relocs = malloc (reloc_size); + relocs = (PTR) malloc (reloc_size); if (!relocs) { bfd_error = no_memory; return false; @@ -1763,7 +1766,7 @@ sunos4_slurp_reloc_table (abfd, asect, symbols) if (each_size == RELOC_EXT_SIZE) { - register struct reloc_ext_bytes *rptr = relocs; + register struct reloc_ext_bytes *rptr = (struct reloc_ext_bytes *) relocs; unsigned int counter = 0; arelent *cache_ptr = reloc_cache; @@ -1772,7 +1775,7 @@ sunos4_slurp_reloc_table (abfd, asect, symbols) } } else { - register struct reloc_std_bytes *rptr = relocs; + register struct reloc_std_bytes *rptr = (struct reloc_std_bytes *) relocs; unsigned int counter = 0; arelent *cache_ptr = reloc_cache; @@ -1827,7 +1830,7 @@ sunos4_squirt_out_relocs (abfd, section) swap_std_reloc_out(abfd, generic, native, count); } - if ( bfd_write ((void *) native, 1, natsize, abfd) != natsize) { + if ( bfd_write ((PTR) native, 1, natsize, abfd) != natsize) { free(native); return false; } @@ -1938,10 +1941,10 @@ bfd_print_symbol_enum_type how; break; case bfd_print_symbol_all_enum: { - char *section_name = symbol->section == (asection *)NULL ? + CONST char *section_name = symbol->section == (asection *)NULL ? "*abs" : symbol->section->name; - bfd_print_symbol_vandf((void *)file,symbol); + bfd_print_symbol_vandf((PTR)file,symbol); fprintf(file," %-5s %04x %02x %02x %s", section_name, @@ -1986,20 +1989,20 @@ sunos4_close_and_cleanup (abfd) */ boolean -sunos4_find_nearest_line(abfd, - section, - symbols, - offset, - filename_ptr, - functionname_ptr, - line_ptr) -bfd *abfd; -asection *section; -asymbol **symbols; -bfd_vma offset; -char **filename_ptr; -char **functionname_ptr; -unsigned int *line_ptr; +DEFUN(sunos4_find_nearest_line,(abfd, + section, + symbols, + offset, + filename_ptr, + functionname_ptr, + line_ptr), + bfd *abfd AND + asection *section AND + asymbol **symbols AND + bfd_vma offset AND + CONST char **filename_ptr AND + CONST char **functionname_ptr AND + unsigned int *line_ptr) { /* Run down the file looking for the filename, function and linenumber */ asymbol **p; @@ -2040,7 +2043,7 @@ unsigned int *line_ptr; func = (asymbol *)q; } if (*line_ptr && func) { - char *function = func->name; + CONST char *function = func->name; char *p; strncpy(buffer, function, sizeof(buffer)-1); buffer[sizeof(buffer)-1] = 0; @@ -2061,7 +2064,7 @@ unsigned int *line_ptr; } -bfd_target aoutvec = +bfd_target aout_big_vec = { "a.out-generic-big", /* name */ bfd_target_aout_flavour_enum, @@ -2117,3 +2120,59 @@ bfd_target aoutvec = bfd_generic_stat_arch_elt /* bfd_stat_arch_elt */ }; +bfd_target aout_little_vec = +{ + "a.out-generic-little", /* name */ + bfd_target_aout_flavour_enum, + true, /* target byte order */ + true, /* target headers byte order */ + (HAS_RELOC | EXEC_P | /* object flags */ + HAS_LINENO | HAS_DEBUG | + HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), + (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ + 0, /* valid reloc types */ + ' ', /* ar_pad_char */ + 16, /* ar_max_namelen */ + sunos4_close_and_cleanup, /* _close_and_cleanup */ + sunos4_set_section_contents, /* bfd_set_section_contents */ + sunos4_get_section_contents, /* bfd_get_section_contents */ + sunos4_new_section_hook, /* new_section_hook */ + sunos4_core_file_failing_command, /* _core_file_failing_command */ + sunos4_core_file_failing_signal, /* _core_file_failing_signal */ + sunos4_core_file_matches_executable_p, /* _core_file_matches_ex...p */ + + bfd_slurp_bsd_armap, /* bfd_slurp_armap */ + bfd_true, /* bfd_slurp_extended_name_table */ + bfd_bsd_truncate_arname, /* bfd_truncate_arname */ + + sunos4_get_symtab_upper_bound, /* get_symtab_upper_bound */ + sunos4_get_symtab, /* canonicalize_symtab */ + sunos4_reclaim_symbol_table, /* bfd_reclaim_symbol_table */ + sunos4_get_reloc_upper_bound, /* get_reloc_upper_bound */ + sunos4_canonicalize_reloc, /* bfd_canonicalize_reloc */ + sunos4_reclaim_reloc, /* bfd_reclaim_reloc */ + sunos4_get_symcount_upper_bound, /* bfd_get_symcount_upper_bound */ + sunos4_get_first_symbol, /* bfd_get_first_symbol */ + sunos4_get_next_symbol, /* bfd_get_next_symbol */ + sunos4_classify_symbol, /* bfd_classify_symbol */ + sunos4_symbol_hasclass, /* bfd_symbol_hasclass */ + sunos4_symbol_name, /* bfd_symbol_name */ + sunos4_symbol_value, /* bfd_symbol_value */ + + _do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* data */ + _do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* hdrs */ + + {_bfd_dummy_target, sunos4_object_p, /* bfd_check_format */ + bfd_generic_archive_p, sunos4_core_file_p}, + {bfd_false, sunos4_mkobject, /* bfd_zxset_format */ + _bfd_generic_mkarchive, bfd_false}, + sunos4_make_empty_symbol, + sunos4_print_symbol, + sunos4_get_lineno, + sunos4_set_arch_mach, + bsd_write_armap, + bfd_generic_openr_next_archived_file, + sunos4_find_nearest_line, /* bfd_find_nearest_line */ + bfd_generic_stat_arch_elt /* bfd_stat_arch_elt */ + }; + diff --git a/bfd/targets.c b/bfd/targets.c index 31741ec64d..c33f02d590 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -26,8 +26,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "bfd.h" #include "libbfd.h" -extern bfd_target aoutvec; + extern bfd_target aout_little_vec; +extern bfd_target aout_big_vec; extern bfd_target srec_vec; extern bfd_target b_out_vec_little_host; extern bfd_target b_out_vec_big_host; @@ -37,18 +38,23 @@ extern bfd_target ieee_vec; extern bfd_target oasys_vec; extern bfd_target m88k_bcs_vec; -vvvvvvvvvvvvvvvvvvvv -bfd_target *target_vector[] = { - &aout_little_vec, - &ieee_vec, - &oasys_vec, - &icoff_big_vec, - &aoutvec, - &icoff_little_vec, - &m88k_bcs_vec, - &b_out_vec_big_host, - &b_out_vec_little_host, - &srec_vec, - NULL, -}; -^^^^^^^^^^^^^^^^^^^^ + + +bfd_target *target_vector[] = + { +#ifndef GNU960 + &ieee_vec, + &oasys_vec, + &aout_little_vec, + &aout_big_vec, +/* &m88k_bcs_vec,*/ + &srec_vec, +#endif /* GNU960 */ + &icoff_little_vec, + &icoff_big_vec, + &b_out_vec_little_host, + &b_out_vec_big_host, + NULL + }; + + |