}
/* Use an intermediate variable for clarity */
- rawptr = (PTR) zalloc (sizeof (struct sunexdata) + sizeof (struct exec));
+ rawptr = (PTR) bfd_zalloc (abfd, sizeof (struct sunexdata) + sizeof (struct exec));
if (rawptr == NULL) {
bfd_error = no_memory;
bfd_error = system_call_error;
/* Use an intermediate variable for clarity */
- rawptr = zalloc (sizeof (struct sunexdata) + sizeof (struct exec));
+ rawptr = bfd_zalloc (abfd,sizeof (struct sunexdata) + sizeof (struct exec));
if (rawptr == NULL) {
bfd_error = no_memory;
switch (arch) {
case bfd_arch_sparc:
- if (machine == 0) arch_flags = M_SPARC;
- break;
+ if (machine == 0) arch_flags = M_SPARC;
+ break;
case bfd_arch_m68k:
- switch (machine) {
- case 0: arch_flags = M_UNKNOWN; break;
- case 68000: arch_flags = M_UNKNOWN; break;
- case 68010: arch_flags = M_68010; break;
- case 68020: arch_flags = M_68020; break;
- default: arch_flags = M_UNKNOWN; break;
- }
- break;
+ switch (machine) {
+ case 0: arch_flags = M_68010; break;
+ case 68000: arch_flags = M_UNKNOWN; break;
+ case 68010: arch_flags = M_68010; break;
+ case 68020: arch_flags = M_68020; break;
+ default: arch_flags = M_UNKNOWN; break;
+ }
+ break;
case bfd_arch_i386:
- if (machine == 0) arch_flags = M_386;
- break;
+ if (machine == 0) arch_flags = M_386;
+ break;
case bfd_arch_a29k:
- if (machine == 0) arch_flags = M_29K;
- break;
+ if (machine == 0) arch_flags = M_29K;
+ break;
default:
- arch_flags = M_UNKNOWN;
- break;
+ arch_flags = M_UNKNOWN;
+ break;
}
return arch_flags;
}
if (bfd_seek (abfd, 0L, false) < 0) return 0;
- rawptr = zalloc (core_size + sizeof (struct suncordata));
+ rawptr = bfd_zalloc (abfd, core_size + sizeof (struct suncordata));
if (rawptr == NULL) {
bfd_error = no_memory;
return 0;
/* create the sections. This is raunchy, but bfd_close wants to reclaim
them */
- core_stacksec (abfd) = (asection *) zalloc (sizeof (asection));
+ core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
if (core_stacksec (abfd) == NULL) {
loser:
bfd_error = no_memory;
free ((PTR)rawptr);
return 0;
}
- core_datasec (abfd) = (asection *) zalloc (sizeof (asection));
+ core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
if (core_datasec (abfd) == NULL) {
loser1:
free ((PTR)core_stacksec (abfd));
goto loser;
}
- core_regsec (abfd) = (asection *) zalloc (sizeof (asection));
+ core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
if (core_regsec (abfd) == NULL) {
loser2:
free ((PTR)core_datasec (abfd));
goto loser1;
}
- core_reg2sec (abfd) = (asection *) zalloc (sizeof (asection));
+ core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
if (core_reg2sec (abfd) == NULL) {
free ((PTR)core_regsec (abfd));
goto loser2;
{
asection *section = bfd_make_section(abfd,
cache_ptr->symbol.name);
- arelent_chain *reloc = (arelent_chain *)malloc(sizeof(arelent_chain));
+ arelent_chain *reloc = (arelent_chain *)bfd_alloc(abfd, sizeof(arelent_chain));
switch ( (cache_ptr->type & N_TYPE) ) {
case N_SETA:
bfd *abfd;
{
aout_symbol_type *new =
- (aout_symbol_type *)zalloc (sizeof (aout_symbol_type));
+ (aout_symbol_type *)bfd_zalloc (abfd, sizeof (aout_symbol_type));
new->symbol.the_bfd = abfd;
return &new->symbol;
symbol_count = symbol_size / sizeof (struct nlist);
- /* Malloc (should alloca) space for native symbols, and
- malloc space for string table and symbol cache. */
-
- syms = (struct nlist *) zalloc (symbol_size);
- if (syms == NULL) {
- bfd_error = no_memory;
- return false;
- }
-
- cached = (aout_symbol_type *) zalloc ((size_t)(string_size + 1 +
- (symbol_count * sizeof (aout_symbol_type))));
- if (cached == NULL) {
- bfd_error = no_memory;
- free ((PTR)syms);
- return false;
- }
-
- strings = ((char *) cached) + (symbol_count * sizeof (aout_symbol_type));
+ strings = bfd_alloc(abfd, string_size + 1);
+ cached = bfd_zalloc(abfd, symbol_count * sizeof(aout_symbol_type));
+ syms = bfd_alloc(abfd, symbol_size);
bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET);
if (bfd_read ((PTR)syms, 1, symbol_size, abfd) != symbol_size) {
bailout:
- free ((PTR)cached);
- free ((PTR)syms);
return false;
}
}
/* OK, now walk the new symtable, cacheing symbol properties */
- {
- register struct nlist *sym_pointer;
- register struct nlist *sym_end = syms + symbol_count;
- register aout_symbol_type *cache_ptr = cached;
+ {
+ register struct nlist *sym_pointer;
+ register struct nlist *sym_end = syms + symbol_count;
+ register aout_symbol_type *cache_ptr = cached;
/* run through the table and byte swap if needed */
for (sym_pointer = syms; sym_pointer < sym_end; sym_pointer++) {
}
- /* Run through table and copy values */
- for (sym_pointer = syms, cache_ptr = cached;
- sym_pointer < sym_end; sym_pointer++, cache_ptr++)
- {
- cache_ptr->symbol.the_bfd = abfd;
- if (sym_pointer->n_un.n_strx)
- cache_ptr->symbol.name = sym_pointer->n_un.n_strx + strings;
- else
- cache_ptr->symbol.name = (char *)NULL;
- cache_ptr->symbol.value = sym_pointer->n_value;
- cache_ptr->desc = sym_pointer->n_desc;
- cache_ptr->other = sym_pointer->n_other;
- cache_ptr->type = sym_pointer->n_type;
- cache_ptr->symbol.udata = 0;
- translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd);
+ /* Run through table and copy values */
+ for (sym_pointer = syms, cache_ptr = cached;
+ sym_pointer < sym_end; sym_pointer++, cache_ptr++)
+ {
+ cache_ptr->symbol.the_bfd = abfd;
+ if (sym_pointer->n_un.n_strx)
+ cache_ptr->symbol.name = sym_pointer->n_un.n_strx + strings;
+ else
+ cache_ptr->symbol.name = (char *)NULL;
+ cache_ptr->symbol.value = sym_pointer->n_value;
+ cache_ptr->desc = sym_pointer->n_desc;
+ cache_ptr->other = sym_pointer->n_other;
+ cache_ptr->type = sym_pointer->n_type;
+ cache_ptr->symbol.udata = 0;
+ translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd);
- }
- }
+ }
+ }
obj_aout_symbols (abfd) = cached;
bfd_get_symcount (abfd) = symbol_count;
- free ((PTR)syms);
+ bfd_release (abfd, (PTR)syms);
return true;
}
DEFUN(sunos4_reclaim_symbol_table,(abfd),
bfd *abfd)
{
- asection *section;
-
- if (!bfd_get_symcount (abfd)) return;
- for (section = abfd->sections;
- section != (asection *) NULL;
- section = section->next)
- if (section->relocation) {
- free ((PTR)section->relocation);
- section->relocation = NULL;
- section->reloc_count = 0;
- }
-
- bfd_get_symcount (abfd) = 0;
- free ((PTR)obj_aout_symbols (abfd));
- obj_aout_symbols (abfd) = (aout_symbol_type *)NULL;
}
\f
unsigned int
return bfd_get_symcount(abfd);
}
-\f
-/* Obsolete procedural interface; better to look at the cache directly */
-
-/* User should have checked the file flags; perhaps we should return
- BFD_NO_MORE_SYMBOLS if there are none? */
-
-int
-sunos4_get_symcount_upper_bound (abfd)
- bfd *abfd;
-{
- /* In case we're doing an output file or something...? */
- if (bfd_get_symcount (abfd)) return bfd_get_symcount (abfd);
-
- return (exec_hdr (abfd)->a_syms) / (sizeof (struct nlist));
-}
-
-symindex
-sunos4_get_first_symbol (ignore_abfd)
- bfd * ignore_abfd;
-{
- return 0;
-}
-
-symindex
-sunos4_get_next_symbol (abfd, oidx)
- bfd *abfd;
- symindex oidx;
-{
- if (oidx == BFD_NO_MORE_SYMBOLS) return BFD_NO_MORE_SYMBOLS;
- return ++oidx >= bfd_get_symcount (abfd) ? BFD_NO_MORE_SYMBOLS : oidx;
-}
-
-CONST char *
-sunos4_symbol_name (abfd, idx)
- bfd *abfd;
- symindex idx;
-{
- return (obj_aout_symbols (abfd) + idx)->symbol.name;
-}
-
-long
-sunos4_symbol_value (abfd, idx)
- bfd *abfd;
- symindex idx;
-{
- return (obj_aout_symbols (abfd) + idx)->symbol.value;
-}
-
-symclass
-sunos4_classify_symbol (abfd, idx)
- bfd *abfd;
- symindex idx;
-{
- aout_symbol_type *sym = obj_aout_symbols (abfd) + idx;
-
- if ((sym->symbol.flags & BSF_FORT_COMM) != 0) return bfd_symclass_fcommon;
- if ((sym->symbol.flags & BSF_GLOBAL) != 0) return bfd_symclass_global;
- if ((sym->symbol.flags & BSF_DEBUGGING) != 0) return bfd_symclass_debugger;
- if ((sym->symbol.flags & BSF_UNDEFINED) != 0) return bfd_symclass_undefined;
-
- return bfd_symclass_unknown;
-}
-
-boolean
-sunos4_symbol_hasclass (abfd, idx, class)
- bfd *abfd;
- symindex idx;
- symclass class;
-{
- aout_symbol_type *sym = obj_aout_symbols (abfd) + idx;
- switch (class) {
- case bfd_symclass_fcommon:
- return (sym->symbol.flags & BSF_FORT_COMM) ? true :false;
- case bfd_symclass_global:
- return (sym->symbol.flags & BSF_GLOBAL) ? true:false;
- case bfd_symclass_debugger:
- return (sym->symbol.flags & BSF_DEBUGGING) ? true:false;;
- case bfd_symclass_undefined:
- return (sym->symbol.flags & BSF_UNDEFINED) ? true:false;;
- default: return false;
- }
-}
\f
/* Standard reloc stuff */
/* Output standard relocation information to a file in target byte order. */
count = reloc_size / each_size;
- relocs = (PTR) malloc (reloc_size);
- if (!relocs) {
- bfd_error = no_memory;
- return false;
- }
- reloc_cache = (arelent *) zalloc ((size_t)(count * sizeof (arelent)));
- if (reloc_cache == (arelent *)NULL) {
- free (relocs);
- bfd_error = no_memory;
- return false;
- }
+
+ reloc_cache = (arelent *) bfd_zalloc (abfd, (size_t)(count * sizeof
+ (arelent)));
+ relocs = bfd_alloc (abfd, reloc_size);
if (bfd_read ( relocs, 1, reloc_size, abfd) != reloc_size) {
bfd_error = system_call_error;
- free (reloc_cache);
- free (relocs);
return false;
}
}
}
- free (relocs);
+bfd_release (abfd,relocs);
asect->relocation = reloc_cache;
asect->reloc_count = count;
return true;
each_size = reloc_size_func(abfd);
natsize = each_size * count;
- native = (unsigned char *) zalloc (natsize);
+ native = (unsigned char *) bfd_zalloc (abfd, natsize);
if (!native) {
bfd_error = no_memory;
return false;
}
if ( bfd_write ((PTR) native, 1, natsize, abfd) != natsize) {
- free(native);
+ bfd_release(abfd, native);
return false;
}
- free (native);
+ bfd_release (abfd, native);
return true;
}
bfd *ignore_abfd;
sec_ptr section;
{
- if (section->relocation) {
- free (section->relocation);
- section->relocation = NULL;
- section->reloc_count = 0;
- }
+
}
\f
default: bfd_error = invalid_operation; return false;
}
-#define cleaner(ptr) if (abfd->ptr) free (abfd->ptr)
- cleaner (tdata);
-
- if (abfd->my_archive)
- cleaner (filename);
-
-#undef cleaner
return true;
}
}
+#define sunos4_openr_next_archived_file bfd_generic_openr_next_archived_file
+#define sunos4_generic_stat_arch_elt bfd_generic_stat_arch_elt
+#define sunos4_slurp_armap bfd_slurp_bsd_armap
+#define sunos4_slurp_extended_name_table bfd_true
+#define sunos4_write_armap bsd_write_armap
+#define sunos4_truncate_arname bfd_bsd_truncate_arname
bfd_target aout_big_vec =
{
"a.out-generic-big", /* name */
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_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* data */
_do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* 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 */
+ {_bfd_dummy_target, sunos4_object_p,
+ bfd_generic_archive_p, sunos4_core_file_p},
+ {bfd_false, sunos4_mkobject,
+ _bfd_generic_mkarchive, bfd_false},
+
+ JUMP_TABLE(sunos4)
};
+
bfd_target aout_little_vec =
{
"a.out-generic-little", /* name */
bfd_target_aout_flavour_enum,
- true, /* target byte order */
- true, /* target headers byte order */
+ false, /* target byte order */
+ false, /* 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 */
+
+ {_bfd_dummy_target, sunos4_object_p,
+ bfd_generic_archive_p, sunos4_core_file_p},
+ {bfd_false, sunos4_mkobject,
+ _bfd_generic_mkarchive, bfd_false},
+
+ JUMP_TABLE(sunos4)
};
+
/*** archive.c -- an attempt at combining the machine-independent parts of
archives */
bfd *abfd;
bfd_format format;
{
- file_ptr filepos;
+
if (bfd_read_p (abfd) ||
((int)abfd->format < (int)bfd_unknown) ||
/* presume the answer is yes */
abfd->format = format;
- filepos = bfd_tell (abfd);
+/* filepos = bfd_tell (abfd);*/
if (!BFD_SEND_FMT (abfd, _bfd_set_format, (abfd))) {
abfd->format = bfd_unknown;
- bfd_seek (abfd, filepos, SEEK_SET);
+/* bfd_seek (abfd, filepos, SEEK_SET);*/
return false;
}
sect = sect->next;
}
- newsect = (asection *) zalloc (sizeof (asection));
+ newsect = (asection *) bfd_zalloc(abfd, sizeof (asection));
if (newsect == NULL) {
bfd_error = no_memory;
return NULL;
newsect->index = abfd->section_count++;
newsect->flags = SEC_NO_FLAGS;
-#if ignore /* the compiler doesn't know that zalloc clears the storage */
+
newsect->userdata = 0;
newsect->next = (asection *)NULL;
newsect->relocation = (arelent *)NULL;
newsect->reloc_count = 0;
newsect->line_filepos =0;
-#endif
+
if (BFD_SEND (abfd, _new_section_hook, (abfd, newsect)) != true) {
free (newsect);
return NULL;
\f
static void
-close_one()
+DEFUN_VOID(close_one)
{
bfd *kill = cache_sentinel;
if (kill == 0) /* Nothing in the cache */
}
/* Cuts the bfd abfd out of the chain in the cache */
static void
-snip (abfd)
- bfd *abfd;
+DEFUN(snip,(abfd),
+ bfd *abfd)
{
abfd->lru_prev->lru_next = abfd->lru_next;
abfd->lru_next->lru_prev = abfd->lru_prev;
}
static void
-bfd_cache_delete (abfd)
- bfd *abfd;
+DEFUN(bfd_cache_delete,(abfd),
+ bfd *abfd)
{
fclose ((FILE *)(abfd->iostream));
snip (abfd);
abfd->iostream = NULL;
open_files--;
+ bfd_last_cache = 0;
}
static bfd *
-insert(x,y)
-bfd *x;
-bfd *y;
+DEFUN(insert,(x,y),
+ bfd *x AND
+ bfd *y)
{
if (y) {
x->lru_next = y;
/* Initialize a BFD by putting it on the cache LRU. */
void
-bfd_cache_init(abfd)
-bfd *abfd;
+DEFUN(bfd_cache_init,(abfd),
+ bfd *abfd)
{
cache_sentinel = insert(abfd, cache_sentinel);
}
void
-bfd_cache_close(abfd)
-bfd *abfd;
+DEFUN(bfd_cache_close,(abfd),
+ bfd *abfd)
{
/* If this file is open then remove from the chain */
if (abfd->iostream)
BFD so that future accesses know the file is open. */
FILE *
-bfd_open_file (abfd)
- bfd *abfd;
+DEFUN(bfd_open_file, (abfd),
+ bfd *abfd)
{
abfd->cacheable = true; /* Allow it to be closed later. */
if(open_files >= BFD_CACHE_MAX_OPEN) {
one first, to avoid running out of file descriptors. */
FILE *
-bfd_cache_lookup_worker (abfd)
- bfd *abfd;
+DEFUN(bfd_cache_lookup_worker,(abfd),
+ bfd *abfd)
{
if (abfd->my_archive)
- {
- abfd = abfd->my_archive;
- }
+ {
+ abfd = abfd->my_archive;
+ }
/* Is this file already open .. if so then quick exit */
if (abfd->iostream)
- {
- if (abfd != cache_sentinel) {
- /* Place onto head of lru chain */
- snip (abfd);
- cache_sentinel = insert(abfd, cache_sentinel);
+ {
+ if (abfd != cache_sentinel) {
+ /* Place onto head of lru chain */
+ snip (abfd);
+ cache_sentinel = insert(abfd, cache_sentinel);
+ }
}
- }
/* This is a bfd without a stream -
so it must have been closed or never opened.
find an empty cache entry and use it. */
else
- {
+ {
- if (open_files >= BFD_CACHE_MAX_OPEN)
- {
- close_one();
- }
+ if (open_files >= BFD_CACHE_MAX_OPEN)
+ {
+ close_one();
+ }
- BFD_ASSERT(bfd_open_file (abfd) != (FILE *)NULL) ;
- fseek((FILE *)(abfd->iostream), abfd->where, false);
- }
-bfd_last_cache = abfd;
+ BFD_ASSERT(bfd_open_file (abfd) != (FILE *)NULL) ;
+ fseek((FILE *)(abfd->iostream), abfd->where, false);
+ }
+ bfd_last_cache = abfd;
return (FILE *)(abfd->iostream);
}
#include "archures.h" /* Machine architectures and types */
+
/* SUPPRESS 558 */
/* SUPPRESS 590 */
/* SUPPRESS 529 */
{
asection *return_section;
{
- char *name = (PTR) malloc(9);
+ char *name = bfd_alloc(abfd, 9);
if (name == NULL) {
bfd_error = no_memory;
return (BFD_FAILURE);
return true;
}
+static boolean
+DEFUN(coff_mkobject,(abfd),
+ bfd *abfd)
+{
+ coff_data_type *coff;
+ coff_data(abfd) =
+ (coff_data_type*)bfd_alloc(abfd,sizeof(coff_data_type));
+ coff = coff_data(abfd);
+ coff->relocbase = 0;
+ coff->hdr = (AOUTHDR*) bfd_alloc(abfd, sizeof(AOUTHDR));
+ return true;
+
+}
static
bfd_target *
unsigned nscns AND
unsigned opthdr)
{
- struct icofdata *tdata;
+ coff_data_type *coff;
char *file_info; /* buffer for all the headers */
size_t readsize; /* length of file_info */
struct filehdr *filehdr; /* points into file_info */
struct scnhdr *sections; /* points into file_info */
+
+ /* Build a play area */
+ (void) coff_mkobject(abfd);
+ coff = coff_data(abfd);
/*
- OK, now we know the format, read in the filehdr, soi-disant "optional
- header", and all the sections.
- */
+ OK, now we know the format, read in the filehdr, soi-disant "optional
+ header", and all the sections.
+ */
readsize = sizeof(struct filehdr)
+ opthdr
+ (nscns * sizeof(struct scnhdr));
- file_info = (PTR) malloc(readsize);
- if (file_info == NULL) {
- bfd_error = no_memory;
- return 0;
- }
+ file_info = (PTR) bfd_alloc(abfd, readsize);
if (bfd_seek(abfd, 0L, SEEK_SET) < 0)
- return 0;
+ goto fail;
+
if (bfd_read((PTR) file_info, 1, readsize, abfd) != readsize)
- return 0;
+ goto fail;
filehdr = (struct filehdr *) file_info;
sections = (struct scnhdr *) (file_info + sizeof(struct filehdr) + opthdr);
swap_filehdr(abfd, filehdr);
/* Now copy data as required; construct all asections etc */
- tdata = (struct icofdata *) malloc(sizeof(struct icofdata) +
- sizeof(AOUTHDR));
- if (tdata == NULL) {
- bfd_error = no_memory;
- return 0;
- }
- tdata->symbol_index_slew = 0;
- tdata->relocbase =0;
- tdata->raw_syment_count = 0;
- tdata->raw_linenos = 0;
- tdata->raw_syments = 0;
- tdata->sym_filepos =0;
- tdata->flags = filehdr->f_flags;
+ coff->symbol_index_slew = 0;
+ coff->relocbase =0;
+ coff->raw_syment_count = 0;
+ coff->raw_linenos = 0;
+ coff->raw_syments = 0;
+ coff->sym_filepos =0;
+ coff->flags = filehdr->f_flags;
if (nscns != 0) {
unsigned int i;
for (i = 0; i < nscns; i++) {
#ifdef MC88MAGIC
case MC88MAGIC:
case MC88DMAGIC:
+ case MC88OMAGIC:
abfd->obj_arch = bfd_arch_m88k;
abfd->obj_machine = 88100;
break;
case I960RWMAGIC:
abfd->obj_arch = bfd_arch_i960;
switch (F_I960TYPE & filehdr->f_flags)
- {
- default:
- case F_I960CORE:
- abfd->obj_machine = bfd_mach_i960_core;
- break;
- case F_I960KB:
- abfd->obj_machine = bfd_mach_i960_kb_sb;
- break;
- case F_I960MC:
- abfd->obj_machine = bfd_mach_i960_mc;
- break;
- case F_I960XA:
- abfd->obj_machine = bfd_mach_i960_xa;
- break;
- case F_I960CA:
- abfd->obj_machine = bfd_mach_i960_ca;
- break;
- case F_I960KA:
- abfd->obj_machine = bfd_mach_i960_ka_sa;
- break;
+ {
+ default:
+ case F_I960CORE:
+ abfd->obj_machine = bfd_mach_i960_core;
+ break;
+ case F_I960KB:
+ abfd->obj_machine = bfd_mach_i960_kb_sb;
+ break;
+ case F_I960MC:
+ abfd->obj_machine = bfd_mach_i960_mc;
+ break;
+ case F_I960XA:
+ abfd->obj_machine = bfd_mach_i960_xa;
+ break;
+ case F_I960CA:
+ abfd->obj_machine = bfd_mach_i960_ca;
+ break;
+ case F_I960KA:
+ abfd->obj_machine = bfd_mach_i960_ka_sa;
+ break;
- }
+ }
break;
#endif
if (!(filehdr->f_flags & F_LSYMS))
abfd->flags |= HAS_LOCALS;
- abfd->tdata = (PTR) tdata;
+
bfd_get_symcount(abfd) = filehdr->f_nsyms;
if (filehdr->f_nsyms)
abfd->flags |= HAS_SYMS;
- tdata->sym_filepos = filehdr->f_symptr;
- tdata->hdr = (struct aouthdr *) (file_info + sizeof(struct filehdr));
+ coff->sym_filepos = filehdr->f_symptr;
+ swap_aouthdr(abfd, coff->hdr);
- swap_aouthdr(abfd, tdata->hdr);
-
- tdata->symbols = (coff_symbol_type *) NULL;
+ coff->symbols = (coff_symbol_type *) NULL;
bfd_get_start_address(abfd) = opthdr ? exec_hdr(abfd)->entry : 0;
return abfd->xvec;
+ fail:
+ bfd_release(abfd, coff);
+ return (bfd_target *)NULL;
}
return coff_real_object_p(abfd, nscns, opthdr);
}
-static boolean
-DEFUN(coff_mkobject,(abfd),
- bfd *abfd)
-{
- char *rawptr;
-
- bfd_error = system_call_error;
-
- /* Use an intermediate variable for clarity */
- rawptr = zalloc(sizeof(struct icofdata) + sizeof(AOUTHDR));
- if (rawptr == NULL) {
- bfd_error = no_memory;
- return false;
- }
- abfd->tdata = (PTR) ((struct icofdata *) rawptr);
- exec_hdr(abfd) = (AOUTHDR *) (rawptr + sizeof(struct icofdata));
- obj_relocbase(abfd) =0;
- return true;
-}
bfd_coff_swap_sym(abfd, native);
bfd_write((PTR) native, 1, SYMESZ, abfd);
for (j = 0; j != native->n_numaux; j++) {
- bfd_coff_swap_aux(abfd, native + j + 1, type, class);
+ bfd_coff_swap_aux(abfd, (AUXENT *)(native + j + 1), type, class);
bfd_write((PTR) (native + j + 1), 1, AUXESZ, abfd);
}
arelent *q = p[i];
memset((PTR)&n, 0, sizeof(n));
n.r_vaddr = q->address + s->vma;
+ if (q->sym_ptr_ptr) {
n.r_symndx = get_index((*(q->sym_ptr_ptr)));
+ }
n.r_type = q->howto->type;
swap_reloc(abfd, &n);
bfd_write((PTR) &n, 1, RELSZ, abfd);
coff_make_empty_symbol(abfd)
bfd *abfd;
{
- coff_symbol_type *new = (coff_symbol_type *) malloc(sizeof(coff_symbol_type));
+ coff_symbol_type *new = (coff_symbol_type *) bfd_alloc(abfd, sizeof(coff_symbol_type));
if (new == NULL) {
bfd_error = no_memory;
return (NULL);
#endif
#ifdef MC88MAGIC
case bfd_arch_m88k:
- *magicp = MC88MAGIC;
+ *magicp = MC88OMAGIC;
return true;
break;
#endif
int seek_direction;
size_t size;
{
- PTR area = (PTR) malloc(size);
+ PTR area = (PTR) bfd_alloc(abfd, 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);
for (i = raw_symtab->n_numaux; i; --i, ++raw_symtab) {
bfd_coff_swap_aux(abfd,
- raw_symtab + 1,
+ (AUXENT *)(raw_symtab + 1),
raw_symtab->n_type,
raw_symtab->n_sclass);
} /* swap all the aux entries */
table traversals simple. To do that, we need to know whether we will
be prepending the C_FILE symbol before we read the rest of the table.
*/
- if ((s = (SYMENT *) malloc(sizeof(SYMENT) * 2)) == NULL) {
+ if ((s = (SYMENT *) bfd_alloc(abfd, sizeof(SYMENT) * 2)) == NULL) {
bfd_error = no_memory;
return (NULL);
} /* on error */
if (s->n_sclass == C_FILE) {
obj_symbol_slew(abfd) = 0;
- if ((retval = (SYMENT *) malloc(size)) == NULL) {
+ if ((retval = (SYMENT *) bfd_alloc(abfd, size)) == NULL) {
bfd_error = no_memory;
return (NULL);
} /* on malloc error */
CONST char *filename;
obj_symbol_slew(abfd) = 2;
- if ((retval = (SYMENT *) malloc(size
+ if ((retval = (SYMENT *) bfd_alloc(abfd, size
+ (obj_symbol_slew(abfd)
* sizeof(SYMENT)))) == NULL) {
bfd_error = no_memory;
#define FILE_ENTRY_NAME ".file"
- if ((retval->n_offset = (int) malloc(strlen(FILE_ENTRY_NAME)
+ if ((retval->n_offset = (int) bfd_alloc(abfd, strlen(FILE_ENTRY_NAME)
+ 1)) == NULL) {
bfd_error = no_memory;
return (NULL);
}
else {
if ((((AUXENT *) (retval + 1))->x_file.x_n.x_offset
- = (int) malloc(namelength+1)) == NULL) {
+ = (int) bfd_alloc(abfd, namelength+1)) == NULL) {
bfd_error = no_memory;
return (NULL);
} /* on error */
} /* if "short" name */
} /* missing file entry. */
- free(s);
+
if (bfd_seek(abfd, obj_sym_filepos(abfd), SEEK_SET) == -1
|| bfd_read(retval + obj_symbol_slew(abfd), size, 1, abfd) != size) {
} /* if end of string */
} /* possible lengths of this string. */
- if ((newstring = (PTR) malloc(++i)) == NULL) {
+ if ((newstring = (PTR) bfd_alloc(abfd, ++i)) == NULL) {
bfd_error = no_memory;
return (NULL);
} /* on error */
} /* on error */
sp(string_table_size);
- if ((string_table = (PTR) malloc(string_table_size -= 4)) == NULL) {
+ if ((string_table = (PTR) bfd_alloc(abfd, string_table_size -= 4)) == NULL) {
bfd_error = no_memory;
return (NULL);
} /* on mallocation error */
return 0;
}
-static int
-coff_get_symcount_upper_bound(ignore_abfd)
- bfd *ignore_abfd;
-{
- BFD_ASSERT(0);
- return 0;
-}
-
-static symindex
-coff_get_first_symbol(ignore_abfd)
- bfd *ignore_abfd;
-{
- return 0;
-}
-
-static symindex
-coff_get_next_symbol(abfd, oidx)
- bfd *abfd;
- symindex oidx;
-{
- if (oidx == BFD_NO_MORE_SYMBOLS)
- return BFD_NO_MORE_SYMBOLS;
- return ++oidx >= bfd_get_symcount(abfd) ? BFD_NO_MORE_SYMBOLS : oidx;
-}
-
-static CONST char *
-coff_symbol_name(abfd, idx)
- bfd *abfd;
- symindex idx;
-{
- return (obj_symbols(abfd) + idx)->symbol.name;
-}
-
-static long
-coff_symbol_value(abfd, idx)
- bfd *abfd;
- symindex idx;
-{
- return (obj_symbols(abfd) + idx)->symbol.value;
-}
-
-static symclass
-coff_classify_symbol(abfd, idx)
- bfd *abfd;
- symindex idx;
-{
- coff_symbol_type *sym = obj_symbols(abfd) + idx;
- if ((sym->symbol.flags & BSF_FORT_COMM) != 0)
- return bfd_symclass_fcommon;
- if ((sym->symbol.flags & BSF_GLOBAL) != 0)
- return bfd_symclass_global;
- if ((sym->symbol.flags & BSF_DEBUGGING) != 0)
- return bfd_symclass_debugger;
- if ((sym->symbol.flags & BSF_UNDEFINED) != 0)
- return bfd_symclass_undefined;
-
- return bfd_symclass_unknown;
-}
-
-static boolean
-coff_symbol_hasclass(abfd, idx, class)
- bfd *abfd;
- symindex idx;
- symclass class;
-{
- coff_symbol_type *sym = obj_symbols(abfd) + idx;
- switch (class) {
- case bfd_symclass_fcommon:
- return (sym->symbol.flags & BSF_FORT_COMM) ? true : false;
- case bfd_symclass_global:
- return (sym->symbol.flags & BSF_GLOBAL) ? true : false;
- case bfd_symclass_debugger:
- return (sym->symbol.flags & BSF_DEBUGGING) ? true : false;;
- case bfd_symclass_undefined:
- return (sym->symbol.flags & BSF_UNDEFINED) ? true : false;;
- default:
- return false;
- }
-}
-
(size_t) (sizeof(struct lineno) *
asect->lineno_count));
lineno_cache =
- (alent *) malloc((size_t) ((asect->lineno_count + 1) * sizeof(alent)));
+ (alent *) bfd_alloc(abfd, (size_t) ((asect->lineno_count + 1) * sizeof(alent)));
if (lineno_cache == NULL) {
bfd_error = no_memory;
return (BFD_FAILURE);
cache_ptr->line_number = 0;
}
- free(native_lineno);
asect->lineno = lineno_cache;
return true;
} /* coff_slurp_line_table() */
/* Allocate enough room for all the symbols in cached form */
cached_area =
(coff_symbol_type *)
- malloc((size_t) (bfd_get_symcount(abfd) * sizeof(coff_symbol_type)));
+ bfd_alloc(abfd, (size_t) (bfd_get_symcount(abfd) * sizeof(coff_symbol_type)));
if (cached_area == NULL) {
bfd_error = no_memory;
} /* on error */
table_ptr =
(unsigned int *)
- malloc((size_t) (bfd_get_symcount(abfd) * sizeof(unsigned int)));
+ bfd_alloc(abfd, (size_t) (bfd_get_symcount(abfd) * sizeof(unsigned int)));
if (table_ptr == NULL) {
bfd_error = no_memory;
(size_t) (sizeof(struct reloc) *
asect->reloc_count));
reloc_cache = (arelent *)
- malloc((size_t) (asect->reloc_count * sizeof(arelent)));
+ bfd_alloc(abfd, (size_t) (asect->reloc_count * sizeof(arelent)));
if (reloc_cache == NULL) {
bfd_error = no_memory;
}
- free(native_relocs);
+
asect->relocation = reloc_cache;
return true;
}
}
#endif
+
+
+#define coff_core_file_failing_command _bfd_dummy_core_file_failing_command
+#define coff_core_file_failing_signal _bfd_dummy_core_file_failing_signal
+#define coff_core_file_matches_executable_p _bfd_dummy_core_file_matches_executable_p
+#define coff_slurp_armap bfd_slurp_coff_armap
+#define coff_slurp_extended_name_table _bfd_slurp_extended_name_table
+#define coff_truncate_arname bfd_dont_truncate_arname
+#define coff_openr_next_archived_file bfd_generic_openr_next_archived_file
+#define coff_generic_stat_arch_elt bfd_generic_stat_arch_elt
#include "sysdep.h"
#include "bfd.h"
#include "libbfd.h"
+#include "obstack.h"
#include "libcoff.h" /* to allow easier abstraction-breaking */
{15},
{16},
- { (unsigned int) R_RELLONG, 0, 2, 32,false, 0, true, true, 0,"rellong", true, 0xffffffff},
+ { (unsigned int) R_RELLONG, 0, 2, 32,false, 0, true, true,
+ 0,"rellong", true, 0xffffffff, 0xffffffff},
{18},
{19},
{20},
{23},
{24},
- { R_IPRMED, 0, 2, 24,true,0, true, true,0,"iprmed ", true, 0x00ffffff},
+ { R_IPRMED, 0, 2, 24,true,0, true, true,0,"iprmed ", true,
+ 0x00ffffff, 0x00ffffff},
{26},
- { R_OPTCALL, 0,2,24,true,0, true, true, optcall_callback, "optcall", true, 0x00ffffff},
+ { R_OPTCALL, 0,2,24,true,0, true, true, optcall_callback,
+ "optcall", true, 0x00ffffff, 0x00ffffff},
};
#define BADMAG(x) I960BADMAG(x)
#include "coff-code.h"
-
-
-bfd_target icoff_big_vec =
+bfd_target icoff_little_vec =
{
- "coff-Intel-big", /* name */
+ "coff-Intel-little", /* name */
bfd_target_coff_flavour_enum,
false, /* data byte order is little */
- true, /* header byte order is big */
+ false, /* header byte order is little */
(HAS_RELOC | EXEC_P | /* object flags */
HAS_LINENO | HAS_DEBUG |
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT),
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* valid reloc types */
'/', /* ar_pad_char */
15, /* ar_max_namelen */
- coff_close_and_cleanup, /* _close_and_cleanup */
- coff_set_section_contents, /* bfd_set_section_contents */
- coff_get_section_contents, /* bfd_get_section_contents */
- coff_new_section_hook, /* new_section_hook */
- _bfd_dummy_core_file_failing_command, /* _core_file_failing_command */
- _bfd_dummy_core_file_failing_signal, /* _core_file_failing_signal */
- _bfd_dummy_core_file_matches_executable_p, /* _core_file_matches_ex...p */
-
- bfd_slurp_coff_armap, /* bfd_slurp_armap */
- _bfd_slurp_extended_name_table, /* bfd_slurp_extended_name_table*/
-#if 0 /* */
- bfd_dont_truncate_arname, /* bfd_truncate_arname */
-#else
- bfd_bsd_truncate_arname,
-#endif
-
- coff_get_symtab_upper_bound, /* get_symtab_upper_bound */
- coff_get_symtab, /* canonicalize_symtab */
- (void (*)())bfd_false, /* bfd_reclaim_symbol_table */
- coff_get_reloc_upper_bound, /* get_reloc_upper_bound */
- coff_canonicalize_reloc, /* bfd_canonicalize_reloc */
- (void (*)())bfd_false, /* bfd_reclaim_reloc */
-
- coff_get_symcount_upper_bound, /* bfd_get_symcount_upper_bound */
- coff_get_first_symbol, /* bfd_get_first_symbol */
- coff_get_next_symbol, /* bfd_get_next_symbol */
- coff_classify_symbol, /* bfd_classify_symbol */
- coff_symbol_hasclass, /* bfd_symbol_hasclass */
- coff_symbol_name, /* bfd_symbol_name */
- coff_symbol_value, /* bfd_symbol_value */
_do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* data */
- _do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* hdrs */
+ _do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* hdrs */
{_bfd_dummy_target, coff_object_p, /* bfd_check_format */
bfd_generic_archive_p, _bfd_dummy_target},
- {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
- bfd_false},
- coff_make_empty_symbol,
- coff_print_symbol,
- coff_get_lineno,
- coff_set_arch_mach,
- coff_write_armap,
- bfd_generic_openr_next_archived_file,
- coff_find_nearest_line,
- bfd_generic_stat_arch_elt /* bfd_stat_arch_elt */
- };
+ {bfd_false, coff_mkobject, /* bfd_set_format */
+ _bfd_generic_mkarchive, bfd_false},
+JUMP_TABLE(coff)
+};
-bfd_target icoff_little_vec =
+
+bfd_target icoff_big_vec =
{
- "coff-Intel-little", /* name */
+ "coff-Intel-big", /* name */
bfd_target_coff_flavour_enum,
false, /* data byte order is little */
- false, /* header byte order is little */
+ true, /* header byte order is big */
(HAS_RELOC | EXEC_P | /* object flags */
HAS_LINENO | HAS_DEBUG |
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT),
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* valid reloc types */
'/', /* ar_pad_char */
15, /* ar_max_namelen */
- coff_close_and_cleanup, /* _close_and_cleanup */
- coff_set_section_contents, /* bfd_set_section_contents */
- coff_get_section_contents, /* bfd_get_section_contents */
- coff_new_section_hook, /* new_section_hook */
- _bfd_dummy_core_file_failing_command, /* _core_file_failing_command */
- _bfd_dummy_core_file_failing_signal, /* _core_file_failing_signal */
- _bfd_dummy_core_file_matches_executable_p, /* _core_file_matches_ex...p */
-
- bfd_slurp_coff_armap, /* bfd_slurp_armap */
- _bfd_slurp_extended_name_table, /* bfd_slurp_extended_name_table*/
-#if 1 /* */
- bfd_dont_truncate_arname, /* bfd_truncate_arname */
-#else
- bfd_bsd_truncate_arname,
-#endif
- coff_get_symtab_upper_bound, /* get_symtab_upper_bound */
- coff_get_symtab, /* canonicalize_symtab */
- (void (*)())bfd_false, /* bfd_reclaim_symbol_table */
- coff_get_reloc_upper_bound, /* get_reloc_upper_bound */
- coff_canonicalize_reloc, /* bfd_canonicalize_reloc */
- (void (*)())bfd_false, /* bfd_reclaim_reloc */
-
- coff_get_symcount_upper_bound, /* bfd_get_symcount_upper_bound */
- coff_get_first_symbol, /* bfd_get_first_symbol */
- coff_get_next_symbol, /* bfd_get_next_symbol */
- coff_classify_symbol, /* bfd_classify_symbol */
- coff_symbol_hasclass, /* bfd_symbol_hasclass */
- coff_symbol_name, /* bfd_symbol_name */
- coff_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, coff_object_p, /* bfd_check_format */
- bfd_generic_archive_p, _bfd_dummy_target},
- {bfd_false, coff_mkobject, /* bfd_set_format */
- _bfd_generic_mkarchive, bfd_false},
- coff_make_empty_symbol,
- coff_print_symbol,
- coff_get_lineno,
- coff_set_arch_mach,
- coff_write_armap,
- bfd_generic_openr_next_archived_file,
- coff_find_nearest_line,
- bfd_generic_stat_arch_elt /* bfd_stat_arch_elt */
-};
+ _do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* hdrs */
+ {_bfd_dummy_target, coff_object_p, bfd_generic_archive_p, _bfd_dummy_target},
+ {bfd_false, coff_mkobject, _bfd_generic_mkarchive, bfd_false},
+ JUMP_TABLE(coff)
+ };
#include <sysdep.h>
#include "bfd.h"
#include "libbfd.h"
-#include "libcoff.h"
+#include "obstack.h"
#include "m88k-bcs.h"
+#include "libcoff.h"
+
static reloc_howto_type howto_table[] =
{
/* type rtshift size bitsize pc_rel bitpos abs ovff sf name partial inplace mask*/
- R_PCR16L, 2, 1, 16, true, 0, false, true, 0,"PCR16L", false, 0x0000ffff,
- R_PCR26L, 2, 2, 26, true, 0, false, true, 0,"PCR26L", false, 0x03ffffff,
- R_VRT16, 0, 1, 16, false, 0, false, true, 0,"VRT16", false, 0x0000ffff,
- R_HVRT16,16, 1, 16, false, 0, false, true, 0,"HVRT16", false, 0x0000ffff,
- R_LVRT16, 0, 1, 16, false, 0, false, true, 0,"LVRT16", false, 0x0000ffff,
- R_VRT32, 0, 2, 32, false, 0, false, true, 0,"VRT32", false, 0xffffffff,
+ R_PCR16L, 2, 1, 16, true, 0, false, true, 0,"PCR16L", false, 0x0000ffff,0x0000ffff,
+ R_PCR26L, 2, 2, 26, true, 0, false, true, 0,"PCR26L", false, 0x03ffffff,0x03ffffff,
+ R_VRT16, 0, 1, 16, false, 0, false, true, 0,"VRT16", false, 0x0000ffff,0x0000ffff,
+ R_HVRT16,16, 1, 16, false, 0, false, true, 0,"HVRT16", false, 0x0000ffff,0x0000ffff,
+ R_LVRT16, 0, 1, 16, false, 0, false, true, 0,"LVRT16", false, 0x0000ffff,0x0000ffff,
+ R_VRT32, 0, 2, 32, false, 0, false, true, 0,"VRT32", false, 0xffffffff,0xffffffff,
};
+
+#define coff_write_armap bsd_write_armap
+
+
bfd_target m88k_bcs_vec =
{
- "m88k-bcs", /* name */
+ "m88kbcs", /* name */
bfd_target_coff_flavour_enum,
- false, /* data byte order is little */
+ true, /* data byte order is big */
true, /* header byte order is big */
(HAS_RELOC | EXEC_P | /* object flags */
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT),
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* valid reloc types */
'/', /* ar_pad_char */
15, /* ar_max_namelen */
- coff_close_and_cleanup, /* _close_and_cleanup */
- coff_set_section_contents, /* bfd_set_section_contents */
- coff_get_section_contents, /* bfd_get_section_contents */
- coff_new_section_hook, /* new_section_hook */
- _bfd_dummy_core_file_failing_command, /* _core_file_failing_command */
- _bfd_dummy_core_file_failing_signal, /* _core_file_failing_signal */
- _bfd_dummy_core_file_matches_executable_p, /* _core_file_matches_ex...p */
-
- bfd_slurp_coff_armap, /* bfd_slurp_armap */
- _bfd_slurp_extended_name_table, /* bfd_slurp_extended_name_table*/
-#if 0 /* */
- bfd_dont_truncate_arname, /* bfd_truncate_arname */
-#else
- bfd_bsd_truncate_arname,
-#endif
-
- coff_get_symtab_upper_bound, /* get_symtab_upper_bound */
- coff_get_symtab, /* canonicalize_symtab */
- (void (*)())bfd_false, /* bfd_reclaim_symbol_table */
- coff_get_reloc_upper_bound, /* get_reloc_upper_bound */
- coff_canonicalize_reloc, /* bfd_canonicalize_reloc */
- (void (*)())bfd_false, /* bfd_reclaim_reloc */
-
- coff_get_symcount_upper_bound, /* bfd_get_symcount_upper_bound */
- coff_get_first_symbol, /* bfd_get_first_symbol */
- coff_get_next_symbol, /* bfd_get_next_symbol */
- coff_classify_symbol, /* bfd_classify_symbol */
- coff_symbol_hasclass, /* bfd_symbol_hasclass */
- coff_symbol_name, /* bfd_symbol_name */
- coff_symbol_value, /* bfd_symbol_value */
_do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* data */
_do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* hdrs */
bfd_generic_archive_p, _bfd_dummy_target},
{bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
bfd_false},
- coff_make_empty_symbol,
- coff_print_symbol,
- coff_get_lineno,
- coff_set_arch_mach,
- coff_write_armap,
- bfd_generic_openr_next_archived_file,
- coff_find_nearest_line,
- bfd_generic_stat_arch_elt /* bfd_stat_arch_elt */
+
+ JUMP_TABLE(coff)
+
};
}
-
static int
DEFUN(comp,(ap, bp),
- arelent **ap AND
- arelent **bp)
+ PTR ap AND
+ PTR bp)
{
- arelent *a = *ap;
- arelent *b = *bp;
+ arelent *a = *((arelent **)ap);
+ arelent *b = *((arelent **)bp);
return a->address - b->address;
}
+
/*
Write the section headers
*/
static int
-ieee_stat_arch_elt(abfd, buf)
+ieee_generic_stat_arch_elt(abfd, buf)
bfd *abfd;
struct stat *buf;
{
return 0;
}
}
+#define ieee_core_file_failing_command bfd_false
+#define ieee_core_file_failing_signal bfd_false
+#define ieee_core_file_matches_executable_p bfd_false
+#define ieee_slurp_armap bfd_true
+#define ieee_slurp_extended_name_table bfd_true
+#define ieee_truncate_arname bfd_false
+#define ieee_write_armap bfd_false
+#define ieee_get_lineno bfd_false
+
/*SUPPRESS 460 */
bfd_target ieee_vec =
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
(SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS
|SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* valid reloc types */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- ieee_close_and_cleanup, /* _close_and_cleanup */
- ieee_set_section_contents, /* bfd_set_section_contents */
- ieee_get_section_contents,
- ieee_new_section_hook, /* new_section_hook */
- 0, /* _core_file_failing_command */
- 0, /* _core_file_failing_signal */
- 0, /* _core_file_matches_ex...p */
-
- 0, /* bfd_slurp_bsd_armap, bfd_slurp_armap */
- bfd_true, /* bfd_slurp_extended_name_table */
- bfd_bsd_truncate_arname, /* bfd_truncate_arname */
-
- ieee_get_symtab_upper_bound, /* get_symtab_upper_bound */
- ieee_get_symtab, /* canonicalize_symtab */
- 0, /* ieee_reclaim_symbol_table, bfd_reclaim_symbol_table */
- ieee_get_reloc_upper_bound, /* get_reloc_upper_bound */
- ieee_canonicalize_reloc, /* bfd_canonicalize_reloc */
- 0, /* ieee_reclaim_reloc, bfd_reclaim_reloc */
- 0, /* ieee_get_symcount_upper_bound, bfd_get_symcount_upper_bound */
- 0, /* ieee_get_first_symbol, bfd_get_first_symbol */
- 0, /* ieee_get_next_symbol, bfd_get_next_symbol */
- 0, /* ieee_classify_symbol, bfd_classify_symbol */
- 0, /* ieee_symbol_hasclass, bfd_symbol_hasclass */
- 0, /* ieee_symbol_name, bfd_symbol_name */
- 0, /* ieee_symbol_value, bfd_symbol_value */
_do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* data */
_do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* hdrs */
_bfd_generic_mkarchive,
bfd_false
},
- ieee_make_empty_symbol,
- ieee_print_symbol,
- bfd_false, /* ieee_get_lineno,*/
- ieee_set_arch_mach, /* bfd_set_arch_mach,*/
- bfd_false,
- ieee_openr_next_archived_file,
- ieee_find_nearest_line, /* bfd_find_nearest_line */
- ieee_stat_arch_elt
+JUMP_TABLE(ieee)
};
/* Object file tdata; access macros */
#define obj_icof(bfd) ((struct icofdata *) ((bfd)->tdata))
+#define coff_data(bfd) ((struct icofdata *) ((bfd)->tdata))
#define exec_hdr(bfd) (obj_icof(bfd)->hdr)
#define obj_symbols(bfd) (obj_icof(bfd)->symbols)
#define obj_sym_filepos(bfd) (obj_icof(bfd)->sym_filepos)
struct lineno_cache_entry *lineno;
} coff_symbol_type;
-struct icofdata {
+typedef struct icofdata
+{
struct aouthdr *hdr; /* exec file header */
coff_symbol_type *symbols; /* symtab for input bfd */
unsigned int *conversion_table;
struct lineno *raw_linenos;
unsigned int raw_syment_count;
char *string_table;
+ unsigned short flags;
/* These are only valid once writing has begun */
long int relocbase;
-
-};
+} coff_data_type;
/* We cast the address of the first element of a asymbol to ensure that the
* macro is only ever applied to an asymbol. */
-#define obstack_chunk_alloc malloc
-#define obstack_chunk_free free
-#define oasys_malloc(abfd,size) \
- obstack_alloc( &( oasys_data(abfd)->oasys_obstack), (size))
-
-typedef void generic_symbol_type;
static void
}
/* Buy enough memory for all the symbols and all the names */
data->symbols =
- (asymbol *)oasys_malloc(abfd, sizeof(asymbol) * abfd->symcount);
+ (asymbol *)bfd_alloc(abfd, sizeof(asymbol) * abfd->symcount);
#ifdef UNDERSCORE_HACK
/* buy 1 more char for each symbol to keep the underscore in*/
- data->strings = oasys_malloc(abfd, data->symbol_string_length +
+ data->strings = bfd_alloc(abfd, data->symbol_string_length +
abfd->symcount);
#else
- data->strings = oasys_malloc(abfd, data->symbol_string_length);
+ data->strings = bfd_alloc(abfd, data->symbol_string_length);
#endif
dest_undefined = data->symbols;
*/
{
oasys_ar_data_type *ar =
- (oasys_ar_data_type*) oasys_malloc(abfd, sizeof(oasys_ar_data_type));
+ (oasys_ar_data_type*) bfd_alloc(abfd, sizeof(oasys_ar_data_type));
oasys_module_info_type *module =
(oasys_module_info_type*)
- oasys_malloc(abfd, sizeof(oasys_module_info_type) * header.mod_count);
+ bfd_alloc(abfd, sizeof(oasys_module_info_type) * header.mod_count);
oasys_module_table_type record;
swap(record.mod_size);
swap(record.file_offset);
swap(record.mod_name_length);
- module[i].name = oasys_malloc(abfd,record.mod_name_length+1);
+ module[i].name = bfd_alloc(abfd,record.mod_name_length+1);
bfd_read(module[i].name, 1, record.mod_name_length +1, abfd);
/* SKip some stuff */
DEFUN(oasys_mkobject,(abfd),
bfd *abfd)
{
- struct obstack tmp_obstack;
oasys_data_type *oasys;
- obstack_init(&tmp_obstack);
- BFD_ASSERT(oasys_data(abfd) == 0);
+
oasys_data(abfd) =
- (oasys_data_type*)obstack_alloc(&tmp_obstack,sizeof(oasys_data_type));
+ (oasys_data_type*)bfd_alloc(abfd, sizeof(oasys_data_type));
oasys = oasys_data(abfd);
- oasys->oasys_obstack = tmp_obstack;
return true;
}
{
goto fail;
}
- buffer = oasys_malloc(abfd, 3);
+ buffer = bfd_alloc(abfd, 3);
section_number= record.section.relb & RELOCATION_SECT_BITS;
sprintf(buffer,"%u", section_number);
s = bfd_make_section(abfd,buffer);
return abfd->xvec;
fail:
- (void) obstack_finish(&oasys->oasys_obstack);
+ (void) bfd_release(abfd, oasys);
return (bfd_target *)NULL;
}
for (s = abfd->sections; s != (asection *)NULL; s= s->next) {
per = oasys_per_section(s);
if (per->data != (bfd_byte*)NULL) return true;
- per->data = (bfd_byte *) oasys_malloc(abfd, s->size);
+ per->data = (bfd_byte *) bfd_alloc(abfd, s->size);
per->reloc_tail_ptr = (oasys_reloc_type **)&(s->relocation);
per->had_vma = false;
s->reloc_count = 0;
/* Relocate the item relative to the section */
oasys_reloc_type *r =
(oasys_reloc_type *)
- oasys_malloc(abfd,
+ bfd_alloc(abfd,
sizeof(oasys_reloc_type));
*(per->reloc_tail_ptr) = r;
per->reloc_tail_ptr = &r->next;
{
oasys_reloc_type *r =
(oasys_reloc_type *)
- oasys_malloc(abfd,
+ bfd_alloc(abfd,
sizeof(oasys_reloc_type));
*(per->reloc_tail_ptr) = r;
per->reloc_tail_ptr = &r->next;
asection *newsect)
{
newsect->used_by_bfd = (PTR)
- oasys_malloc(abfd, sizeof(oasys_per_section_type));
+ bfd_alloc(abfd, sizeof(oasys_per_section_type));
oasys_per_section( newsect)->data = (bfd_byte *)NULL;
oasys_per_section(newsect)->section = newsect;
oasys_per_section(newsect)->offset = 0;
static int
DEFUN(comp,(ap, bp),
- arelent **ap AND
- arelent **bp)
+ CONST PTR ap AND
+ CONST PTR bp)
{
- arelent *a = *ap;
- arelent *b = *bp;
+ arelent *a = *((arelent **)ap);
+ arelent *b = *((arelent **)bp);
return a->address - b->address;
}
bfd_h_putlong(abfd, s->vma + current_byte_index, processed_data.addr);
- if (long_length + current_byte_index > s->size) {
+ if ((size_t)(long_length + current_byte_index) > (size_t)(s->size)) {
long_length = s->size - current_byte_index;
}
while (long_length > 0 && (dst - (uint8e_type*)&processed_data < 128)) {
if (oasys_per_section(section)->data == (bfd_byte *)NULL )
{
oasys_per_section(section)->data =
- (bfd_byte *)(oasys_malloc(abfd,section->size));
+ (bfd_byte *)(bfd_alloc(abfd,section->size));
}
(void) memcpy(oasys_per_section(section)->data + offset,
location,
{
oasys_symbol_type *new =
- (oasys_symbol_type *)zalloc (sizeof (oasys_symbol_type));
+ (oasys_symbol_type *)bfd_zalloc (abfd, sizeof (oasys_symbol_type));
new->symbol.the_bfd = abfd;
return &new->symbol;
}
- if (oasys_data(abfd) != (oasys_data_type *)NULL) {
- /* It's so easy to throw everything away */
-(void) obstack_finish(&(oasys_data(abfd)->oasys_obstack));
- }
return true;
}
}
static int
-oasys_stat_arch_elt(abfd, buf)
+oasys_generic_stat_arch_elt(abfd, buf)
bfd *abfd;
struct stat *buf;
{
}
+#define oasys_core_file_failing_command bfd_false
+#define oasys_core_file_failing_signal bfd_false
+#define oasys_core_file_matches_executable_p bfd_false
+#define oasys_slurp_armap bfd_false
+#define oasys_slurp_extended_name_table bfd_false
+#define oasys_truncate_arname bfd_false
+#define oasys_write_armap bfd_false
+#define oasys_get_lineno bfd_false
+
+
/*SUPPRESS 460 */
bfd_target oasys_vec =
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
(SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS
|SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* valid reloc types */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- oasys_close_and_cleanup, /* _close_and_cleanup */
- oasys_set_section_contents, /* bfd_set_section_contents */
- oasys_get_section_contents,
- oasys_new_section_hook, /* new_section_hook */
- 0, /* _core_file_failing_command */
- 0, /* _core_file_failing_signal */
- 0, /* _core_file_matches_ex...p */
-
- 0, /* bfd_slurp_bsd_armap, bfd_slurp_armap */
- bfd_true, /* bfd_slurp_extended_name_table */
- bfd_bsd_truncate_arname, /* bfd_truncate_arname */
-
- oasys_get_symtab_upper_bound, /* get_symtab_upper_bound */
- oasys_get_symtab, /* canonicalize_symtab */
- 0, /* oasys_reclaim_symbol_table, bfd_reclaim_symbol_table */
- oasys_get_reloc_upper_bound, /* get_reloc_upper_bound */
- oasys_canonicalize_reloc, /* bfd_canonicalize_reloc */
- 0, /* oasys_reclaim_reloc, bfd_reclaim_reloc */
- 0, /* oasys_get_symcount_upper_bound, bfd_get_symcount_upper_bound */
- 0, /* oasys_get_first_symbol, bfd_get_first_symbol */
- 0, /* oasys_get_next_symbol, bfd_get_next_symbol */
- 0, /* oasys_classify_symbol, bfd_classify_symbol */
- 0, /* oasys_symbol_hasclass, bfd_symbol_hasclass */
- 0, /* oasys_symbol_name, bfd_symbol_name */
- 0, /* oasys_symbol_value, bfd_symbol_value */
_do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* data */
_do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* hdrs */
_bfd_generic_mkarchive,
bfd_false
},
- oasys_make_empty_symbol,
- oasys_print_symbol,
- bfd_false, /* oasys_get_lineno,*/
- oasys_set_arch_mach, /* bfd_set_arch_mach,*/
- bfd_false,
- oasys_openr_next_archived_file,
- oasys_find_nearest_line, /* bfd_find_nearest_line */
- oasys_stat_arch_elt, /* bfd_stat_arch_elt */
+JUMP_TABLE(oasys)
};
#include "libbfd.h"
+
extern void bfd_cache_init();
FILE *bfd_open_file();
we should use the emacs lock scheme?... */
\f
+#define obstack_chunk_alloc malloc
+#define obstack_chunk_free free
+
bfd *new_bfd()
{
- bfd *nbfd = (bfd *)zalloc(sizeof(bfd));
+ struct obstack tmp;
+ bfd *nbfd;
+ obstack_init(&tmp);
+
+ nbfd = (bfd *)obstack_alloc(&tmp,sizeof(bfd));
+ nbfd->memory = tmp;
nbfd->direction = no_direction;
nbfd->iostream = NULL;
if (bfd_open_file (nbfd) == NULL) {
bfd_error = system_call_error; /* File didn't exist, or some such */
- free (nbfd);
+ bfd_release(nbfd,0);
return NULL;
}
return nbfd;
stat(abfd->filename, &buf);
chmod(abfd->filename,buf.st_mode | S_IXUSR | S_IXGRP | S_IXOTH);
}
- free (abfd);
+ obstack_free(&abfd->memory, (PTR)0);
return true;
}
/*
return (bfd *)NULL;
}
nbfd->filename = filename;
- nbfd->xvec = template->xvec;
+ if(template) {
+ nbfd->xvec = template->xvec;
+ }
nbfd->direction = no_direction;
+ bfd_set_format(nbfd, bfd_object);
return nbfd;
}
+
+DEFUN(PTR bfd_alloc, (abfd, size),
+ bfd *abfd AND
+ size_t size)
+{
+ PTR *res = obstack_alloc(&(abfd->memory),size);
+ return res;
+}
+
+DEFUN(PTR bfd_zalloc,(abfd, size),
+ bfd *abfd AND
+ size_t size)
+{
+ PTR res = bfd_alloc(abfd, size);
+ memset(res, 0, size);
+ return res;
+}
+
+DEFUN(PTR bfd_realloc,(abfd, old, size),
+ bfd *abfd AND
+ PTR old AND
+ size_t size)
+{
+ PTR res = bfd_alloc(abfd, size);
+ memcpy(res, old, size);
+ return res;
+}
+
+
+DEFUN(size_t bfd_alloc_size,(abfd),
+ bfd *abfd)
+{
+ struct _obstack_chunk *chunk = abfd->memory.chunk;
+ size_t size = 0;
+ while (chunk) {
+ size += chunk->limit - &(chunk->contents[0]);
+ chunk = chunk->prev;
+ }
+ return size;
+}
/* $Id$
* $Log$
- * Revision 1.2 1991/04/03 22:10:51 steve
+ * Revision 1.4 1991/04/23 16:01:02 steve
+ * *** empty log message ***
+ *
+ * Revision 1.3 1991/04/08 23:22:31 steve
+ * *** empty log message ***
+ *
+ * Revision 1.2 1991/04/03 22:10:51 steve
* Fixed typo
*
* Revision 1.1.1.1 1991/03/21 21:11:22 gumby
}
/*SUPPRESS 460 */
+#define srec_core_file_failing_command bfd_false
+#define srec_core_file_failing_signal bfd_false
+#define srec_core_file_matches_executable_p bfd_false
+#define srec_slurp_armap bfd_false
+#define srec_slurp_extended_name_table bfd_false
+#define srec_truncate_arname bfd_false
+#define srec_write_armap bfd_false
+#define srec_new_section_hook bfd_false
+#define srec_get_symtab_upper_bound bfd_false
+#define srec_get_symtab bfd_false
+#define srec_get_reloc_upper_bound bfd_false
+#define srec_canonicalize_reloc bfd_false
+#define srec_make_empty_symbol bfd_false
+#define srec_print_symbol bfd_false
+#define srec_get_lineno bfd_false
+#define srec_openr_next_archived_file bfd_false
+#define srec_find_nearest_line bfd_false
+#define srec_generic_stat_arch_elt bfd_false
+
bfd_target srec_vec =
{
"srec", /* name */
(HAS_RELOC | EXEC_P | /* object flags */
HAS_LINENO | HAS_DEBUG |
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
- (SEC_CODE|SEC_DATA|SEC_ROM
+ (SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS
|SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- 0, /* valid reloc types */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- srec_close_and_cleanup, /* _close_and_cleanup */
- srec_set_section_contents, /* bfd_set_section_contents */
- srec_get_section_contents,
- bfd_true, /* new_section_hook */
- 0, /* _core_file_failing_command */
- 0, /* _core_file_failing_signal */
- 0, /* _core_file_matches_ex...p */
-
- bfd_false, /* bfd_slurp_armap */
- bfd_false, /* bfd_slurp_extended_name_table */
- bfd_void, /* bfd_truncate_arname */
- bfd_0u, /* get_symtab_upper_bound */
- bfd_0u, /* canonicalize_symtab */
- bfd_void, /* bfd_reclaim_symbol_table */
- bfd_0u, /* get_reloc_upper_bound */
- bfd_0u, /* bfd_canonicalize_reloc */
- bfd_void, /* bfd_reclaim_reloc */
- bfd_0, /* bfd_get_symcount_upper_bound */
- (symindex (*)())bfd_0, /* bfd_get_first_symbol */
- (symindex (*)())bfd_0, /* bfd_get_next_symbol */
- bfd_false, /* bfd_classify_symbol */
- bfd_false, /* bfd_symbol_hasclass */
- (char* (*)())bfd_0, /* bfd_symbol_name */
- bfd_0, /* bfd_symbol_value */
-
_do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* data */
_do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* hdrs */
_bfd_generic_mkarchive,
bfd_false,
},
- (asymbol * (*)()) bfd_nullvoidptr, /* bfd_make_empty_symbol */
- bfd_void, /* bfd_prit_symbol */
- (alent *(*)())bfd_nullvoidptr, /* srec_get_lineno,*/
- srec_set_arch_mach, /* bfd_set_arch_mach,*/
- bfd_false, /* write_armap*/
- (bfd *(*)())bfd_nullvoidptr, /* openr_next_archived_file */
- bfd_false, /* bfd_find_nearest_line */
+JUMP_TABLE(srec)
};
}
/* Use an intermediate variable for clarity */
- rawptr = (PTR) zalloc (sizeof (struct sunexdata) + sizeof (struct exec));
+ rawptr = (PTR) bfd_zalloc (abfd, sizeof (struct sunexdata) + sizeof (struct exec));
if (rawptr == NULL) {
bfd_error = no_memory;
bfd_error = system_call_error;
/* Use an intermediate variable for clarity */
- rawptr = zalloc (sizeof (struct sunexdata) + sizeof (struct exec));
+ rawptr = bfd_zalloc (abfd,sizeof (struct sunexdata) + sizeof (struct exec));
if (rawptr == NULL) {
bfd_error = no_memory;
switch (arch) {
case bfd_arch_sparc:
- if (machine == 0) arch_flags = M_SPARC;
- break;
+ if (machine == 0) arch_flags = M_SPARC;
+ break;
case bfd_arch_m68k:
- switch (machine) {
- case 0: arch_flags = M_UNKNOWN; break;
- case 68000: arch_flags = M_UNKNOWN; break;
- case 68010: arch_flags = M_68010; break;
- case 68020: arch_flags = M_68020; break;
- default: arch_flags = M_UNKNOWN; break;
- }
- break;
+ switch (machine) {
+ case 0: arch_flags = M_68010; break;
+ case 68000: arch_flags = M_UNKNOWN; break;
+ case 68010: arch_flags = M_68010; break;
+ case 68020: arch_flags = M_68020; break;
+ default: arch_flags = M_UNKNOWN; break;
+ }
+ break;
case bfd_arch_i386:
- if (machine == 0) arch_flags = M_386;
- break;
+ if (machine == 0) arch_flags = M_386;
+ break;
case bfd_arch_a29k:
- if (machine == 0) arch_flags = M_29K;
- break;
+ if (machine == 0) arch_flags = M_29K;
+ break;
default:
- arch_flags = M_UNKNOWN;
- break;
+ arch_flags = M_UNKNOWN;
+ break;
}
return arch_flags;
}
if (bfd_seek (abfd, 0L, false) < 0) return 0;
- rawptr = zalloc (core_size + sizeof (struct suncordata));
+ rawptr = bfd_zalloc (abfd, core_size + sizeof (struct suncordata));
if (rawptr == NULL) {
bfd_error = no_memory;
return 0;
/* create the sections. This is raunchy, but bfd_close wants to reclaim
them */
- core_stacksec (abfd) = (asection *) zalloc (sizeof (asection));
+ core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
if (core_stacksec (abfd) == NULL) {
loser:
bfd_error = no_memory;
free ((PTR)rawptr);
return 0;
}
- core_datasec (abfd) = (asection *) zalloc (sizeof (asection));
+ core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
if (core_datasec (abfd) == NULL) {
loser1:
free ((PTR)core_stacksec (abfd));
goto loser;
}
- core_regsec (abfd) = (asection *) zalloc (sizeof (asection));
+ core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
if (core_regsec (abfd) == NULL) {
loser2:
free ((PTR)core_datasec (abfd));
goto loser1;
}
- core_reg2sec (abfd) = (asection *) zalloc (sizeof (asection));
+ core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
if (core_reg2sec (abfd) == NULL) {
free ((PTR)core_regsec (abfd));
goto loser2;
{
asection *section = bfd_make_section(abfd,
cache_ptr->symbol.name);
- arelent_chain *reloc = (arelent_chain *)malloc(sizeof(arelent_chain));
+ arelent_chain *reloc = (arelent_chain *)bfd_alloc(abfd, sizeof(arelent_chain));
switch ( (cache_ptr->type & N_TYPE) ) {
case N_SETA:
bfd *abfd;
{
aout_symbol_type *new =
- (aout_symbol_type *)zalloc (sizeof (aout_symbol_type));
+ (aout_symbol_type *)bfd_zalloc (abfd, sizeof (aout_symbol_type));
new->symbol.the_bfd = abfd;
return &new->symbol;
symbol_count = symbol_size / sizeof (struct nlist);
- /* Malloc (should alloca) space for native symbols, and
- malloc space for string table and symbol cache. */
-
- syms = (struct nlist *) zalloc (symbol_size);
- if (syms == NULL) {
- bfd_error = no_memory;
- return false;
- }
-
- cached = (aout_symbol_type *) zalloc ((size_t)(string_size + 1 +
- (symbol_count * sizeof (aout_symbol_type))));
- if (cached == NULL) {
- bfd_error = no_memory;
- free ((PTR)syms);
- return false;
- }
-
- strings = ((char *) cached) + (symbol_count * sizeof (aout_symbol_type));
+ strings = bfd_alloc(abfd, string_size + 1);
+ cached = bfd_zalloc(abfd, symbol_count * sizeof(aout_symbol_type));
+ syms = bfd_alloc(abfd, symbol_size);
bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET);
if (bfd_read ((PTR)syms, 1, symbol_size, abfd) != symbol_size) {
bailout:
- free ((PTR)cached);
- free ((PTR)syms);
return false;
}
}
/* OK, now walk the new symtable, cacheing symbol properties */
- {
- register struct nlist *sym_pointer;
- register struct nlist *sym_end = syms + symbol_count;
- register aout_symbol_type *cache_ptr = cached;
+ {
+ register struct nlist *sym_pointer;
+ register struct nlist *sym_end = syms + symbol_count;
+ register aout_symbol_type *cache_ptr = cached;
/* run through the table and byte swap if needed */
for (sym_pointer = syms; sym_pointer < sym_end; sym_pointer++) {
}
- /* Run through table and copy values */
- for (sym_pointer = syms, cache_ptr = cached;
- sym_pointer < sym_end; sym_pointer++, cache_ptr++)
- {
- cache_ptr->symbol.the_bfd = abfd;
- if (sym_pointer->n_un.n_strx)
- cache_ptr->symbol.name = sym_pointer->n_un.n_strx + strings;
- else
- cache_ptr->symbol.name = (char *)NULL;
- cache_ptr->symbol.value = sym_pointer->n_value;
- cache_ptr->desc = sym_pointer->n_desc;
- cache_ptr->other = sym_pointer->n_other;
- cache_ptr->type = sym_pointer->n_type;
- cache_ptr->symbol.udata = 0;
- translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd);
+ /* Run through table and copy values */
+ for (sym_pointer = syms, cache_ptr = cached;
+ sym_pointer < sym_end; sym_pointer++, cache_ptr++)
+ {
+ cache_ptr->symbol.the_bfd = abfd;
+ if (sym_pointer->n_un.n_strx)
+ cache_ptr->symbol.name = sym_pointer->n_un.n_strx + strings;
+ else
+ cache_ptr->symbol.name = (char *)NULL;
+ cache_ptr->symbol.value = sym_pointer->n_value;
+ cache_ptr->desc = sym_pointer->n_desc;
+ cache_ptr->other = sym_pointer->n_other;
+ cache_ptr->type = sym_pointer->n_type;
+ cache_ptr->symbol.udata = 0;
+ translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd);
- }
- }
+ }
+ }
obj_aout_symbols (abfd) = cached;
bfd_get_symcount (abfd) = symbol_count;
- free ((PTR)syms);
+ bfd_release (abfd, (PTR)syms);
return true;
}
DEFUN(sunos4_reclaim_symbol_table,(abfd),
bfd *abfd)
{
- asection *section;
-
- if (!bfd_get_symcount (abfd)) return;
- for (section = abfd->sections;
- section != (asection *) NULL;
- section = section->next)
- if (section->relocation) {
- free ((PTR)section->relocation);
- section->relocation = NULL;
- section->reloc_count = 0;
- }
-
- bfd_get_symcount (abfd) = 0;
- free ((PTR)obj_aout_symbols (abfd));
- obj_aout_symbols (abfd) = (aout_symbol_type *)NULL;
}
\f
unsigned int
return bfd_get_symcount(abfd);
}
-\f
-/* Obsolete procedural interface; better to look at the cache directly */
-
-/* User should have checked the file flags; perhaps we should return
- BFD_NO_MORE_SYMBOLS if there are none? */
-
-int
-sunos4_get_symcount_upper_bound (abfd)
- bfd *abfd;
-{
- /* In case we're doing an output file or something...? */
- if (bfd_get_symcount (abfd)) return bfd_get_symcount (abfd);
-
- return (exec_hdr (abfd)->a_syms) / (sizeof (struct nlist));
-}
-
-symindex
-sunos4_get_first_symbol (ignore_abfd)
- bfd * ignore_abfd;
-{
- return 0;
-}
-
-symindex
-sunos4_get_next_symbol (abfd, oidx)
- bfd *abfd;
- symindex oidx;
-{
- if (oidx == BFD_NO_MORE_SYMBOLS) return BFD_NO_MORE_SYMBOLS;
- return ++oidx >= bfd_get_symcount (abfd) ? BFD_NO_MORE_SYMBOLS : oidx;
-}
-
-CONST char *
-sunos4_symbol_name (abfd, idx)
- bfd *abfd;
- symindex idx;
-{
- return (obj_aout_symbols (abfd) + idx)->symbol.name;
-}
-
-long
-sunos4_symbol_value (abfd, idx)
- bfd *abfd;
- symindex idx;
-{
- return (obj_aout_symbols (abfd) + idx)->symbol.value;
-}
-
-symclass
-sunos4_classify_symbol (abfd, idx)
- bfd *abfd;
- symindex idx;
-{
- aout_symbol_type *sym = obj_aout_symbols (abfd) + idx;
-
- if ((sym->symbol.flags & BSF_FORT_COMM) != 0) return bfd_symclass_fcommon;
- if ((sym->symbol.flags & BSF_GLOBAL) != 0) return bfd_symclass_global;
- if ((sym->symbol.flags & BSF_DEBUGGING) != 0) return bfd_symclass_debugger;
- if ((sym->symbol.flags & BSF_UNDEFINED) != 0) return bfd_symclass_undefined;
-
- return bfd_symclass_unknown;
-}
-
-boolean
-sunos4_symbol_hasclass (abfd, idx, class)
- bfd *abfd;
- symindex idx;
- symclass class;
-{
- aout_symbol_type *sym = obj_aout_symbols (abfd) + idx;
- switch (class) {
- case bfd_symclass_fcommon:
- return (sym->symbol.flags & BSF_FORT_COMM) ? true :false;
- case bfd_symclass_global:
- return (sym->symbol.flags & BSF_GLOBAL) ? true:false;
- case bfd_symclass_debugger:
- return (sym->symbol.flags & BSF_DEBUGGING) ? true:false;;
- case bfd_symclass_undefined:
- return (sym->symbol.flags & BSF_UNDEFINED) ? true:false;;
- default: return false;
- }
-}
\f
/* Standard reloc stuff */
/* Output standard relocation information to a file in target byte order. */
count = reloc_size / each_size;
- relocs = (PTR) malloc (reloc_size);
- if (!relocs) {
- bfd_error = no_memory;
- return false;
- }
- reloc_cache = (arelent *) zalloc ((size_t)(count * sizeof (arelent)));
- if (reloc_cache == (arelent *)NULL) {
- free (relocs);
- bfd_error = no_memory;
- return false;
- }
+
+ reloc_cache = (arelent *) bfd_zalloc (abfd, (size_t)(count * sizeof
+ (arelent)));
+ relocs = bfd_alloc (abfd, reloc_size);
if (bfd_read ( relocs, 1, reloc_size, abfd) != reloc_size) {
bfd_error = system_call_error;
- free (reloc_cache);
- free (relocs);
return false;
}
}
}
- free (relocs);
+bfd_release (abfd,relocs);
asect->relocation = reloc_cache;
asect->reloc_count = count;
return true;
each_size = reloc_size_func(abfd);
natsize = each_size * count;
- native = (unsigned char *) zalloc (natsize);
+ native = (unsigned char *) bfd_zalloc (abfd, natsize);
if (!native) {
bfd_error = no_memory;
return false;
}
if ( bfd_write ((PTR) native, 1, natsize, abfd) != natsize) {
- free(native);
+ bfd_release(abfd, native);
return false;
}
- free (native);
+ bfd_release (abfd, native);
return true;
}
bfd *ignore_abfd;
sec_ptr section;
{
- if (section->relocation) {
- free (section->relocation);
- section->relocation = NULL;
- section->reloc_count = 0;
- }
+
}
\f
default: bfd_error = invalid_operation; return false;
}
-#define cleaner(ptr) if (abfd->ptr) free (abfd->ptr)
- cleaner (tdata);
-
- if (abfd->my_archive)
- cleaner (filename);
-
-#undef cleaner
return true;
}
}
+#define sunos4_openr_next_archived_file bfd_generic_openr_next_archived_file
+#define sunos4_generic_stat_arch_elt bfd_generic_stat_arch_elt
+#define sunos4_slurp_armap bfd_slurp_bsd_armap
+#define sunos4_slurp_extended_name_table bfd_true
+#define sunos4_write_armap bsd_write_armap
+#define sunos4_truncate_arname bfd_bsd_truncate_arname
bfd_target aout_big_vec =
{
"a.out-generic-big", /* name */
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_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* data */
_do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* 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 */
+ {_bfd_dummy_target, sunos4_object_p,
+ bfd_generic_archive_p, sunos4_core_file_p},
+ {bfd_false, sunos4_mkobject,
+ _bfd_generic_mkarchive, bfd_false},
+
+ JUMP_TABLE(sunos4)
};
+
bfd_target aout_little_vec =
{
"a.out-generic-little", /* name */
bfd_target_aout_flavour_enum,
- true, /* target byte order */
- true, /* target headers byte order */
+ false, /* target byte order */
+ false, /* 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 */
+
+ {_bfd_dummy_target, sunos4_object_p,
+ bfd_generic_archive_p, sunos4_core_file_p},
+ {bfd_false, sunos4_mkobject,
+ _bfd_generic_mkarchive, bfd_false},
+
+ JUMP_TABLE(sunos4)
};
#define B_OUT_VEC_BIG_HOST b_out_vec_big_host
#endif /* GNU960 */
+#ifndef RESTRICTED
+#define ICOFF_LITTLE_VEC icoff_little_vec
+#define ICOFF_BIG_VEC icoff_big_vec
+#define B_OUT_VEC_LITTLE_HOST b_out_vec_little_host
+#define B_OUT_VEC_BIG_HOST b_out_vec_big_host
+#define AOUT_VEC_LITTLE_HOST aout_little_vec
+#define AOUT_VEC_BIG_HOST aout_big_vec
+#define OASYS_VEC oasys_vec
+#define IEEE_VEC ieee_vec
+#define M88K_BCS_VEC m88k_bcs_vec
+#define SREC_VEC srec_vec
+#endif
bfd_target *target_vector[] = {
#ifdef DEFAULT_VECTOR
&OASYS_VEC,
#endif /* OASYS_VEC */
-#ifdef AOUT_LITTLE_VEC
- &AOUT_LITTLE_VEC,
+#ifdef AOUT_VEC_LITTLE_HOST
+ &AOUT_VEC_LITTLE_HOST,
#endif /* AOUT_LITTLE_VEC */
-#ifdef AOUT_BIG_VEC
- &AOUT_BIG_VEC,
+#ifdef AOUT_VEC_BIG_HOST
+ &AOUT_VEC_BIG_HOST,
#endif /* AOUT_BIG_VEC */
#ifdef M88K_BCS_VEC
/* This is ugly! XXX */
-PROTO(struct ar_hdr *, bfd_special_undocumented_glue, (char *filename));
+PROTO(struct ar_hdr *, bfd_special_undocumented_glue, (bfd *abfd, char *filename));
void
do_quick_append(archive_filename, files_to_append)
fseek(ofile, 0, 2);
for (; files_to_append && *files_to_append; ++files_to_append) {
- struct ar_hdr *hdr = bfd_special_undocumented_glue(*files_to_append);
+ struct ar_hdr *hdr = bfd_special_undocumented_glue(temp, *files_to_append);
if (hdr == NULL) {
bfd_perror(*files_to_append);
exit(1);
int dump_ar_hdrs; /* -a */
int with_line_numbers; /* -l */
boolean disassemble; /* -d */
+boolean info; /* -i */
char *only;
PROTO (void, display_file, (char *filename, char *target));
usage ()
{
fprintf (stderr,
- "usage: %s [-ahfdrtxsl] [-m machine] [-j section_name] obj ...\n",
+ "usage: %s [-ahifdrtxsl] [-m machine] [-j section_name] obj ...\n",
program_name);
exit (1);
}
}
}
+static void
+DEFUN_VOID(display_info)
+{
+ unsigned int i;
+ extern bfd_target *target_vector[];
+
+ enum bfd_architecture j;
+ i = 0;
+ printf("BFD header file version %s\n", BFD_VERSION);
+ while (target_vector[i] != (bfd_target *)NULL)
+ {
+ bfd_target *p = target_vector[i];
+ bfd *abfd = bfd_openw("##dummy",p->name);
+ printf("%s\n (header %s, data %s)\n", p->name,
+ p->header_byteorder_big_p ? "big endian" : "little endian",
+ p->byteorder_big_p ? "big endian" : "little endian" );
+ {
+ enum bfd_architecture j;
+ for (j = bfd_arch_obscure +1; j < bfd_arch_last; j++)
+ {
+ if (bfd_set_arch_mach(abfd, j, 0))
+ {
+ printf(" %s\n", bfd_printable_arch_mach(j,0));
+ }
+ }
+ }
+ i++;
+ }
+ /* Again as a table */
+ printf("%12s"," ");
+ for (i = 0; target_vector[i]; i++) {
+ printf("%s ",target_vector[i]->name);
+ }
+ printf("\n");
+ for (j = bfd_arch_obscure +1; j < bfd_arch_last; j++) {
+ printf("%11s ", bfd_printable_arch_mach(j,0));
+ for (i = 0; target_vector[i]; i++) {
+ {
+ bfd_target *p = target_vector[i];
+ bfd *abfd = bfd_openw("##dummy",p->name);
+ int l = strlen(p->name);
+ int ok = bfd_set_arch_mach(abfd, j, 0);
+ if (ok) {
+ printf("%s ", p->name);
+ }
+ else {
+ while (l--) {
+ printf("%c",ok?'*':'-');
+ }
+ printf(" ");
+ }
+
+ }
+ }
+
+ printf("\n");
+ }
+}
/** main and like trivia */
int
main (argc, argv)
program_name = *argv;
- while ((c = getopt_long (argc, argv, "b:m:dlfahrtxsj:", long_options, &ind))
+ while ((c = getopt_long (argc, argv, "ib:m:dlfahrtxsj:", long_options, &ind))
!= EOF) {
seenflag = true;
switch (c) {
case 'f':
dump_file_header = true;
break;
+ case 'i':
+ info = true;
+ break;
case 'x':
dump_symtab = 1;
dump_reloc_info = 1;
if (seenflag == false)
usage ();
+ if (info) {
+ display_info();
+ }
+ else {
if (optind == argc)
display_file ("a.out", target);
else
for (; optind < argc;)
display_file (argv[optind++], target);
+}
return 0;
}