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);
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;
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. */
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;
}
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);
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);
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;
}
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;
}
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;
sunos4_get_section_contents (abfd, section, location, offset, count)
bfd *abfd;
sec_ptr section;
- void *location;
+ PTR location;
file_ptr offset;
int count;
{
}
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);
(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;
}
obj_aout_symbols (abfd) = cached;
bfd_get_symcount (abfd) = symbol_count;
- free ((void *)syms);
+ free ((PTR)syms);
return true;
}
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);
}
*/
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++)
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 */
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;
}
\f
return ++oidx >= bfd_get_symcount (abfd) ? BFD_NO_MORE_SYMBOLS : oidx;
}
-char *
+CONST char *
sunos4_symbol_name (abfd, idx)
bfd *abfd;
symindex idx;
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;
{
unsigned int count;
size_t reloc_size;
- void *relocs;
+ PTR relocs;
arelent *reloc_cache;
size_t each_size;
count = reloc_size / each_size;
- relocs = malloc (reloc_size);
+ relocs = (PTR) malloc (reloc_size);
if (!relocs) {
bfd_error = no_memory;
return false;
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;
}
}
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;
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;
}
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,
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 */
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;
}
-bfd_target aoutvec =
+bfd_target aout_big_vec =
{
"a.out-generic-big", /* name */
bfd_target_aout_flavour_enum,
*/
/* $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
- *
*/
#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;
_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;
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;
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))
{
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)));
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);
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);
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;
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:
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);
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);
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 +=
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;
}
\f
/** A couple of functions for creating ar_hdrs */
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
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.
}
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 */
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) {
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++)
\f
+
/** Error handling
o - Most functions return nonzero on success (check doc for
precise semantics); 0 or NULL on 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)
}
#endif /* not ANSI_LIBRARIES */
+
+
char *
bfd_errmsg (error_tag)
bfd_ec 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;
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"))
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
}
}
/* 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;
/* 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;
bfd_map_over_sections (abfd, operation, user_storage)
bfd *abfd;
void (*operation)();
- void *user_storage;
+ PTR user_storage;
{
asection *sect;
int i = 0;
bfd_set_section_contents (abfd, section, location, offset, count)
bfd *abfd;
sec_ptr section;
-void *location;
+ PTR location;
file_ptr offset;
int count;
{
bfd_get_section_contents (abfd, section, location, offset, count)
bfd *abfd;
sec_ptr section;
- void *location;
+ PTR location;
file_ptr offset;
int count;
{
void
bfd_print_symbol_vandf(file, symbol)
-void *file;
+PTR file;
asymbol *symbol;
{
flagword type = symbol->flags;
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;
symbol = (asymbol*)NULL;
}
- if (howto->special_function) {
+ if (howto->special_function){
bfd_reloc_status_enum_type cont;
cont = howto->special_function(abfd,
reloc_entry,
}
/*
- 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){
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;
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) {
/*
- 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;
}
void (*bfd_error_trap)();
+
/*SUPPRESS558*/
/*SUPPRESS529*/
#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 */
}
}
-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;
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;
struct exec *ptr;
{return n_symoff(ptr) + ptr->a_syms;}
+static
unsigned int n_badmag(ptr)
struct exec *ptr;
{
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);
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;
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. */
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);
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;
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 */
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);
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);
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;
}
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;
}
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;
sunos4_get_section_contents (abfd, section, location, offset, count)
bfd *abfd;
sec_ptr section;
- void *location;
+ PTR location;
file_ptr offset;
int count;
{
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 */
}
boolean
-sunos4_slurp_symbol_table (abfd)
- bfd *abfd;
+DEFUN(sunos4_slurp_symbol_table, (abfd),
+ bfd *abfd)
{
unsigned int symbol_count;
size_t symbol_size;
}
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);
(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;
}
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 =
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++)
obj_aout_symbols (abfd) = cached;
bfd_get_symcount (abfd) = symbol_count;
- free ((void *)syms);
+ free ((PTR)syms);
return true;
}
-\f
+
void
-sunos4_write_syms (abfd)
- bfd *abfd;
+DEFUN(sunos4_write_syms,(abfd),
+ bfd *abfd)
{
unsigned int count ;
asymbol **generic = bfd_get_outsymbols (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);
}
*/
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++)
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 */
}
}
-\f
+
void
-sunos4_reclaim_symbol_table (abfd)
- bfd *abfd;
+DEFUN(sunos4_reclaim_symbol_table,(abfd),
+ bfd *abfd)
{
asection *section;
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;
}
\f
return ++oidx >= bfd_get_symcount (abfd) ? BFD_NO_MORE_SYMBOLS : oidx;
}
-char *
+CONST char *
sunos4_symbol_name (abfd, idx)
bfd *abfd;
symindex idx;
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;
{
unsigned int count;
size_t reloc_size;
- void *relocs;
+ PTR relocs;
arelent *reloc_cache;
size_t each_size;
count = reloc_size / each_size;
- relocs = malloc (reloc_size);
+ relocs = (PTR) malloc (reloc_size);
if (!relocs) {
bfd_error = no_memory;
return false;
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;
}
}
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;
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;
}
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,
*/
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;
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;
}
-bfd_target aoutvec =
+bfd_target aout_big_vec =
{
"a.out-generic-big", /* name */
bfd_target_aout_flavour_enum,
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 */
+ };
+