aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Chamberlain <steve@cygnus>1991-04-23 16:02:09 +0000
committerSteve Chamberlain <steve@cygnus>1991-04-23 16:02:09 +0000
commit9872a49c27a0cced505d4d94d543c7d0b647186e (patch)
treef656c6bd7a6bc9bd72abeabc8a1124ba72d4675f
parenta37cc0c05c5ee0e72a14a09c547555621371ef1d (diff)
downloadgdb-9872a49c27a0cced505d4d94d543c7d0b647186e.zip
gdb-9872a49c27a0cced505d4d94d543c7d0b647186e.tar.gz
gdb-9872a49c27a0cced505d4d94d543c7d0b647186e.tar.bz2
*** empty log message ***
-rwxr-xr-xbfd/aout.c354
-rw-r--r--bfd/archive.c1
-rw-r--r--bfd/bfd.c12
-rw-r--r--bfd/cache.c69
-rwxr-xr-xbfd/coff-code.h264
-rw-r--r--bfd/coff-i960.c123
-rw-r--r--bfd/coff-m88k.c66
-rw-r--r--bfd/ieee.c56
-rw-r--r--bfd/libcoff.h8
-rw-r--r--bfd/oasys.c102
-rw-r--r--bfd/opncls.c60
-rw-r--r--bfd/srec.c63
-rw-r--r--bfd/sunos.c354
-rw-r--r--bfd/targets.c20
-rw-r--r--binutils/ar.c4
-rw-r--r--binutils/objdump.c71
16 files changed, 564 insertions, 1063 deletions
diff --git a/bfd/aout.c b/bfd/aout.c
index bfb92ba..921c448 100755
--- a/bfd/aout.c
+++ b/bfd/aout.c
@@ -226,7 +226,7 @@ sunos4_object_p (abfd)
}
/* 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;
@@ -340,7 +340,7 @@ sunos4_mkobject (abfd)
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;
@@ -380,30 +380,30 @@ aout_machine_type (arch, machine)
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;
}
@@ -631,7 +631,7 @@ sunos4_core_file_p (abfd)
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;
@@ -651,26 +651,26 @@ sunos4_core_file_p (abfd)
/* 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;
@@ -923,7 +923,7 @@ translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd)
{
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:
@@ -1105,7 +1105,7 @@ sunos4_make_empty_symbol (abfd)
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;
@@ -1137,30 +1137,13 @@ DEFUN(sunos4_slurp_symbol_table, (abfd),
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;
}
@@ -1170,10 +1153,10 @@ DEFUN(sunos4_slurp_symbol_table, (abfd),
}
/* 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++) {
@@ -1190,28 +1173,28 @@ DEFUN(sunos4_slurp_symbol_table, (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);
+ /* 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;
}
@@ -1291,22 +1274,7 @@ void
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;
}
unsigned int
@@ -1335,88 +1303,6 @@ sunos4_get_symtab (abfd, location)
}
-/* 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;
- }
-}
-
/* Standard reloc stuff */
/* Output standard relocation information to a file in target byte order. */
@@ -1747,22 +1633,13 @@ sunos4_slurp_reloc_table (abfd, asect, symbols)
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;
}
@@ -1786,7 +1663,7 @@ sunos4_slurp_reloc_table (abfd, asect, symbols)
}
}
- free (relocs);
+bfd_release (abfd,relocs);
asect->relocation = reloc_cache;
asect->reloc_count = count;
return true;
@@ -1812,7 +1689,7 @@ sunos4_squirt_out_relocs (abfd, section)
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;
@@ -1833,10 +1710,10 @@ sunos4_squirt_out_relocs (abfd, section)
}
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;
}
@@ -1909,11 +1786,7 @@ sunos4_reclaim_reloc (ignore_abfd, section)
bfd *ignore_abfd;
sec_ptr section;
{
- if (section->relocation) {
- free (section->relocation);
- section->relocation = NULL;
- section->reloc_count = 0;
- }
+
}
@@ -1974,13 +1847,6 @@ sunos4_close_and_cleanup (abfd)
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;
}
@@ -2066,6 +1932,12 @@ DEFUN(sunos4_find_nearest_line,(abfd,
}
+#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 */
@@ -2076,105 +1948,41 @@ bfd_target aout_big_vec =
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)
};
diff --git a/bfd/archive.c b/bfd/archive.c
index 8875ad3..530b0aa 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -1,3 +1,4 @@
+
/*** archive.c -- an attempt at combining the machine-independent parts of
archives */
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 78bac79..291850b 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -310,7 +310,7 @@ bfd_set_format (abfd, format)
bfd *abfd;
bfd_format format;
{
- file_ptr filepos;
+
if (bfd_read_p (abfd) ||
((int)abfd->format < (int)bfd_unknown) ||
@@ -324,11 +324,11 @@ bfd_set_format (abfd, format)
/* 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;
}
@@ -371,7 +371,7 @@ DEFUN(bfd_make_section,(abfd, name),
sect = sect->next;
}
- newsect = (asection *) zalloc (sizeof (asection));
+ newsect = (asection *) bfd_zalloc(abfd, sizeof (asection));
if (newsect == NULL) {
bfd_error = no_memory;
return NULL;
@@ -381,13 +381,13 @@ DEFUN(bfd_make_section,(abfd, name),
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;
diff --git a/bfd/cache.c b/bfd/cache.c
index 39ffc7a..d1172fb 100644
--- a/bfd/cache.c
+++ b/bfd/cache.c
@@ -45,7 +45,7 @@ bfd *bfd_last_cache;
static void
-close_one()
+DEFUN_VOID(close_one)
{
bfd *kill = cache_sentinel;
if (kill == 0) /* Nothing in the cache */
@@ -64,8 +64,8 @@ close_one()
}
/* 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;
@@ -73,19 +73,20 @@ snip (abfd)
}
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;
@@ -104,15 +105,15 @@ bfd *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)
@@ -126,8 +127,8 @@ bfd *abfd;
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) {
@@ -165,36 +166,36 @@ bfd_open_file (abfd)
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);
}
diff --git a/bfd/coff-code.h b/bfd/coff-code.h
index cf340c2..0584700 100755
--- a/bfd/coff-code.h
+++ b/bfd/coff-code.h
@@ -25,6 +25,7 @@ Most of this hacked by Steve Chamberlain, steve@cygnus.com
#include "archures.h" /* Machine architectures and types */
+
/* SUPPRESS 558 */
/* SUPPRESS 590 */
/* SUPPRESS 529 */
@@ -244,7 +245,7 @@ DEFUN(make_a_section_from_file,(abfd, hdr),
{
asection *return_section;
{
- char *name = (PTR) malloc(9);
+ char *name = bfd_alloc(abfd, 9);
if (name == NULL) {
bfd_error = no_memory;
return (BFD_FAILURE);
@@ -299,6 +300,19 @@ DEFUN(make_a_section_from_file,(abfd, hdr),
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 *
@@ -307,28 +321,29 @@ DEFUN(coff_real_object_p,(abfd, nscns, opthdr),
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);
@@ -336,19 +351,13 @@ DEFUN(coff_real_object_p,(abfd, nscns, 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++) {
@@ -369,6 +378,7 @@ DEFUN(coff_real_object_p,(abfd, nscns, opthdr),
#ifdef MC88MAGIC
case MC88MAGIC:
case MC88DMAGIC:
+ case MC88OMAGIC:
abfd->obj_arch = bfd_arch_m88k;
abfd->obj_machine = 88100;
break;
@@ -378,28 +388,28 @@ DEFUN(coff_real_object_p,(abfd, nscns, opthdr),
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
@@ -417,20 +427,21 @@ DEFUN(coff_real_object_p,(abfd, nscns, opthdr),
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;
}
@@ -496,25 +507,6 @@ DEFUN(coff_object_p,(abfd),
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;
-}
@@ -941,7 +933,7 @@ coff_write_symbols(abfd)
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);
}
@@ -997,7 +989,9 @@ coff_write_relocs(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);
@@ -1045,7 +1039,7 @@ static asymbol *
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);
@@ -1154,7 +1148,7 @@ coff_set_flags(abfd, magicp, flagsp)
#endif
#ifdef MC88MAGIC
case bfd_arch_m88k:
- *magicp = MC88MAGIC;
+ *magicp = MC88OMAGIC;
return true;
break;
#endif
@@ -1547,7 +1541,7 @@ buy_and_read(abfd, where, seek_direction, size)
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);
@@ -1555,7 +1549,6 @@ buy_and_read(abfd, where, seek_direction, size)
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);
@@ -1633,7 +1626,7 @@ swap_raw_symtab(abfd, raw_symtab)
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 */
@@ -1674,7 +1667,7 @@ get_normalized_symtab(abfd)
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 */
@@ -1688,7 +1681,7 @@ get_normalized_symtab(abfd)
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 */
@@ -1698,7 +1691,7 @@ get_normalized_symtab(abfd)
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;
@@ -1708,7 +1701,7 @@ get_normalized_symtab(abfd)
#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);
@@ -1729,7 +1722,7 @@ get_normalized_symtab(abfd)
}
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 */
@@ -1739,7 +1732,7 @@ get_normalized_symtab(abfd)
} /* 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) {
@@ -1775,7 +1768,7 @@ get_normalized_symtab(abfd)
} /* 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 */
@@ -1802,7 +1795,7 @@ get_normalized_symtab(abfd)
} /* 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 */
@@ -1868,86 +1861,6 @@ section_from_bfd_index(abfd, index)
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;
- }
-}
-
@@ -1968,7 +1881,7 @@ coff_slurp_line_table(abfd, asect)
(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);
@@ -2000,7 +1913,6 @@ coff_slurp_line_table(abfd, asect)
cache_ptr->line_number = 0;
}
- free(native_lineno);
asect->lineno = lineno_cache;
return true;
} /* coff_slurp_line_table() */
@@ -2074,7 +1986,7 @@ coff_slurp_symbol_table(abfd)
/* 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;
@@ -2082,7 +1994,7 @@ coff_slurp_symbol_table(abfd)
} /* 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;
@@ -2311,7 +2223,7 @@ coff_slurp_reloc_table(abfd, asect, symbols)
(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;
@@ -2373,7 +2285,7 @@ coff_slurp_reloc_table(abfd, asect, symbols)
}
- free(native_relocs);
+
asect->relocation = reloc_cache;
return true;
}
@@ -2556,3 +2468,13 @@ return obj_sym_filepos(abfd);
}
#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
diff --git a/bfd/coff-i960.c b/bfd/coff-i960.c
index bd31adb..f5e6f71 100644
--- a/bfd/coff-i960.c
+++ b/bfd/coff-i960.c
@@ -23,6 +23,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "sysdep.h"
#include "bfd.h"
#include "libbfd.h"
+#include "obstack.h"
#include "libcoff.h" /* to allow easier abstraction-breaking */
@@ -118,7 +119,8 @@ static reloc_howto_type howto_table[] =
{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},
@@ -127,10 +129,12 @@ static reloc_howto_type howto_table[] =
{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},
};
@@ -139,133 +143,54 @@ static reloc_howto_type howto_table[] =
#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)
+ };
diff --git a/bfd/coff-m88k.c b/bfd/coff-m88k.c
index a261c8f..7dda5e5 100644
--- a/bfd/coff-m88k.c
+++ b/bfd/coff-m88k.c
@@ -24,19 +24,21 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#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,
};
@@ -46,11 +48,15 @@ static reloc_howto_type howto_table[] =
+
+#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 */
@@ -58,39 +64,8 @@ bfd_target m88k_bcs_vec =
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 */
@@ -99,14 +74,9 @@ bfd_target m88k_bcs_vec =
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)
+
};
diff --git a/bfd/ieee.c b/bfd/ieee.c
index 9e36f07..6d98b10 100644
--- a/bfd/ieee.c
+++ b/bfd/ieee.c
@@ -1290,16 +1290,16 @@ DEFUN(ieee_set_arch_mach,(abfd, arch, machine),
}
-
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
*/
@@ -1879,7 +1879,7 @@ unsigned int *line_ptr;
static int
-ieee_stat_arch_elt(abfd, buf)
+ieee_generic_stat_arch_elt(abfd, buf)
bfd *abfd;
struct stat *buf;
{
@@ -1894,6 +1894,15 @@ 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 =
@@ -1907,34 +1916,8 @@ 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 */
@@ -1950,12 +1933,5 @@ bfd_target ieee_vec =
_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)
};
diff --git a/bfd/libcoff.h b/bfd/libcoff.h
index 46f5a78..ca498f2 100644
--- a/bfd/libcoff.h
+++ b/bfd/libcoff.h
@@ -23,6 +23,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* 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)
@@ -39,7 +40,8 @@ typedef struct {
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;
@@ -52,10 +54,10 @@ struct icofdata {
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. */
diff --git a/bfd/oasys.c b/bfd/oasys.c
index d5657a1..a7cb3d9 100644
--- a/bfd/oasys.c
+++ b/bfd/oasys.c
@@ -24,13 +24,7 @@
-#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
@@ -87,13 +81,13 @@ DEFUN(oasys_slurp_symbol_table,(abfd),
}
/* 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;
@@ -250,12 +244,12 @@ DEFUN(oasys_archive_p,(abfd),
*/
{
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;
@@ -270,7 +264,7 @@ DEFUN(oasys_archive_p,(abfd),
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 */
@@ -289,14 +283,11 @@ static boolean
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;
}
@@ -347,7 +338,7 @@ DEFUN(oasys_object_p,(abfd),
{
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);
@@ -393,7 +384,7 @@ DEFUN(oasys_object_p,(abfd),
return abfd->xvec;
fail:
- (void) obstack_finish(&oasys->oasys_obstack);
+ (void) bfd_release(abfd, oasys);
return (bfd_target *)NULL;
}
@@ -455,7 +446,7 @@ DEFUN(oasys_slurp_section_data,(abfd),
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;
@@ -531,7 +522,7 @@ DEFUN(oasys_slurp_section_data,(abfd),
/* 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;
@@ -556,7 +547,7 @@ DEFUN(oasys_slurp_section_data,(abfd),
{
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;
@@ -608,7 +599,7 @@ DEFUN(oasys_new_section_hook,(abfd, newsect),
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;
@@ -846,11 +837,11 @@ DEFUN(oasys_write_end,(abfd),
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;
}
@@ -893,7 +884,7 @@ DEFUN(oasys_write_data, (abfd),
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)) {
@@ -1018,7 +1009,7 @@ DEFUN(oasys_set_section_contents,(abfd, section, location, offset, count),
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,
@@ -1041,7 +1032,7 @@ DEFUN(oasys_make_empty_symbol,(abfd),
{
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;
@@ -1078,10 +1069,6 @@ bfd *abfd;
}
- 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;
}
@@ -1140,7 +1127,7 @@ unsigned int *line_ptr;
}
static int
-oasys_stat_arch_elt(abfd, buf)
+oasys_generic_stat_arch_elt(abfd, buf)
bfd *abfd;
struct stat *buf;
{
@@ -1158,6 +1145,16 @@ 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 =
@@ -1171,34 +1168,8 @@ 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 */
@@ -1214,12 +1185,5 @@ bfd_target oasys_vec =
_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)
};
diff --git a/bfd/opncls.c b/bfd/opncls.c
index 585acea..c1df552 100644
--- a/bfd/opncls.c
+++ b/bfd/opncls.c
@@ -25,6 +25,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "libbfd.h"
+
extern void bfd_cache_init();
FILE *bfd_open_file();
@@ -53,9 +54,17 @@ FILE *bfd_open_file();
we should use the emacs lock scheme?... */
+#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;
@@ -113,7 +122,7 @@ DEFUN(bfd_openr, (filename, target),
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;
@@ -255,7 +264,7 @@ bfd_close (abfd)
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;
}
/*
@@ -272,10 +281,53 @@ DEFUN(bfd_create,(filename, template),
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;
+}
diff --git a/bfd/srec.c b/bfd/srec.c
index cf77496..7a4ff5d 100644
--- a/bfd/srec.c
+++ b/bfd/srec.c
@@ -42,7 +42,13 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* $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
@@ -408,6 +414,25 @@ bfd *abfd;
}
/*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 */
@@ -417,36 +442,10 @@ bfd_target srec_vec =
(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 */
@@ -461,11 +460,5 @@ bfd_target srec_vec =
_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)
};
diff --git a/bfd/sunos.c b/bfd/sunos.c
index bfb92ba..921c448 100644
--- a/bfd/sunos.c
+++ b/bfd/sunos.c
@@ -226,7 +226,7 @@ sunos4_object_p (abfd)
}
/* 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;
@@ -340,7 +340,7 @@ sunos4_mkobject (abfd)
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;
@@ -380,30 +380,30 @@ aout_machine_type (arch, machine)
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;
}
@@ -631,7 +631,7 @@ sunos4_core_file_p (abfd)
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;
@@ -651,26 +651,26 @@ sunos4_core_file_p (abfd)
/* 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;
@@ -923,7 +923,7 @@ translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd)
{
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:
@@ -1105,7 +1105,7 @@ sunos4_make_empty_symbol (abfd)
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;
@@ -1137,30 +1137,13 @@ DEFUN(sunos4_slurp_symbol_table, (abfd),
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;
}
@@ -1170,10 +1153,10 @@ DEFUN(sunos4_slurp_symbol_table, (abfd),
}
/* 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++) {
@@ -1190,28 +1173,28 @@ DEFUN(sunos4_slurp_symbol_table, (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);
+ /* 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;
}
@@ -1291,22 +1274,7 @@ void
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;
}
unsigned int
@@ -1335,88 +1303,6 @@ sunos4_get_symtab (abfd, location)
}
-/* 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;
- }
-}
-
/* Standard reloc stuff */
/* Output standard relocation information to a file in target byte order. */
@@ -1747,22 +1633,13 @@ sunos4_slurp_reloc_table (abfd, asect, symbols)
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;
}
@@ -1786,7 +1663,7 @@ sunos4_slurp_reloc_table (abfd, asect, symbols)
}
}
- free (relocs);
+bfd_release (abfd,relocs);
asect->relocation = reloc_cache;
asect->reloc_count = count;
return true;
@@ -1812,7 +1689,7 @@ sunos4_squirt_out_relocs (abfd, section)
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;
@@ -1833,10 +1710,10 @@ sunos4_squirt_out_relocs (abfd, section)
}
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;
}
@@ -1909,11 +1786,7 @@ sunos4_reclaim_reloc (ignore_abfd, section)
bfd *ignore_abfd;
sec_ptr section;
{
- if (section->relocation) {
- free (section->relocation);
- section->relocation = NULL;
- section->reloc_count = 0;
- }
+
}
@@ -1974,13 +1847,6 @@ sunos4_close_and_cleanup (abfd)
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;
}
@@ -2066,6 +1932,12 @@ DEFUN(sunos4_find_nearest_line,(abfd,
}
+#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 */
@@ -2076,105 +1948,41 @@ bfd_target aout_big_vec =
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)
};
diff --git a/bfd/targets.c b/bfd/targets.c
index b422638..e4166be 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -45,6 +45,18 @@ extern bfd_target m88k_bcs_vec;
#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
@@ -59,12 +71,12 @@ bfd_target *target_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
diff --git a/binutils/ar.c b/binutils/ar.c
index ab01510..0011dd3 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -540,7 +540,7 @@ extract_file(abfd)
/* 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)
@@ -598,7 +598,7 @@ 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);
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 4f764bd..eae1860 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -48,6 +48,7 @@ int dump_reloc_info; /* -r */
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));
@@ -75,7 +76,7 @@ void
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);
}
@@ -597,7 +598,65 @@ bfd *abfd;
}
}
+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)
@@ -613,7 +672,7 @@ 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) {
@@ -632,6 +691,9 @@ main (argc, argv)
case 'f':
dump_file_header = true;
break;
+ case 'i':
+ info = true;
+ break;
case 'x':
dump_symtab = 1;
dump_reloc_info = 1;
@@ -654,10 +716,15 @@ main (argc, argv)
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;
}