#include "aout/ar.h"
static boolean aout_get_external_symbols PARAMS ((bfd *));
-static boolean translate_symbol_table PARAMS ((bfd *, aout_symbol_type *,
- struct external_nlist *,
- bfd_size_type, char *,
- bfd_size_type,
- boolean dynamic));
/*
SUBSECTION
/* Translate a set of internal symbols into external symbols. */
-static boolean
-translate_symbol_table (abfd, in, ext, count, str, strsize, dynamic)
+boolean
+NAME(aout,translate_symbol_table) (abfd, in, ext, count, str, strsize, dynamic)
bfd *abfd;
aout_symbol_type *in;
struct external_nlist *ext;
struct external_nlist *old_external_syms;
aout_symbol_type *cached;
size_t cached_size;
- bfd_size_type dynsym_count = 0;
- struct external_nlist *dynsyms = NULL;
- char *dynstrs = NULL;
- bfd_size_type dynstr_size;
/* If there's no work to be done, don't do any */
if (obj_aout_symbols (abfd) != (aout_symbol_type *) NULL)
return false;
}
- /* If this is a dynamic object, see if we can get the dynamic symbol
- table. */
- if ((bfd_get_file_flags (abfd) & DYNAMIC) != 0
- && aout_backend_info (abfd)->read_dynamic_symbols)
- {
- dynsym_count = ((*aout_backend_info (abfd)->read_dynamic_symbols)
- (abfd, &dynsyms, &dynstrs, &dynstr_size));
- if (dynsym_count == (bfd_size_type) -1)
- return false;
- }
-
- cached_size = ((obj_aout_external_sym_count (abfd) + dynsym_count)
+ cached_size = (obj_aout_external_sym_count (abfd)
* sizeof (aout_symbol_type));
cached = (aout_symbol_type *) malloc (cached_size);
memset (cached, 0, cached_size);
}
/* Convert from external symbol information to internal. */
- if (! translate_symbol_table (abfd, cached,
- obj_aout_external_syms (abfd),
- obj_aout_external_sym_count (abfd),
- obj_aout_external_strings (abfd),
- obj_aout_external_string_size (abfd),
- false)
- || ! translate_symbol_table (abfd,
- (cached
- + obj_aout_external_sym_count (abfd)),
- dynsyms, dynsym_count, dynstrs,
- dynstr_size, true))
+ if (! (NAME(aout,translate_symbol_table)
+ (abfd, cached,
+ obj_aout_external_syms (abfd),
+ obj_aout_external_sym_count (abfd),
+ obj_aout_external_strings (abfd),
+ obj_aout_external_string_size (abfd),
+ false)))
{
free (cached);
return false;
}
- bfd_get_symcount (abfd) = (obj_aout_external_sym_count (abfd)
- + dynsym_count);
+ bfd_get_symcount (abfd) = obj_aout_external_sym_count (abfd);
obj_aout_symbols (abfd) = cached;
unsigned int count;
bfd_size_type reloc_size;
PTR relocs;
- bfd_size_type dynrel_count = 0;
- PTR dynrels = NULL;
arelent *reloc_cache;
size_t each_size;
unsigned int counter = 0;
return false;
}
- if ((bfd_get_file_flags (abfd) & DYNAMIC) != 0
- && aout_backend_info (abfd)->read_dynamic_relocs)
- {
- dynrel_count = ((*aout_backend_info (abfd)->read_dynamic_relocs)
- (abfd, &dynrels));
- if (dynrel_count == (bfd_size_type) -1)
- return false;
- }
-
if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
return false;
count = reloc_size / each_size;
- reloc_cache = (arelent *) malloc ((size_t) ((count + dynrel_count)
- * sizeof (arelent)));
+ reloc_cache = (arelent *) malloc ((size_t) (count * sizeof (arelent)));
if (reloc_cache == NULL && count != 0)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
- memset (reloc_cache, 0, (count + dynrel_count) * sizeof (arelent));
+ memset (reloc_cache, 0, count * sizeof (arelent));
relocs = malloc (reloc_size);
if (relocs == NULL && reloc_size != 0)
free (relocs);
- if (dynrel_count > 0)
- {
- asymbol **dynsyms;
-
- /* The dynamic symbols are at the end of the symbol table. */
- for (dynsyms = symbols;
- *dynsyms != NULL && ((*dynsyms)->flags & BSF_DYNAMIC) == 0;
- ++dynsyms)
- ;
-
- /* Swap in the dynamic relocs. These relocs may be for either
- section, so we must discard ones we don't want. */
- counter = 0;
- if (each_size == RELOC_EXT_SIZE)
- {
- register struct reloc_ext_external *rptr
- = (struct reloc_ext_external *) dynrels;
-
- for (; counter < dynrel_count; counter++, rptr++, cache_ptr++)
- {
- NAME(aout,swap_ext_reloc_in) (abfd, rptr, cache_ptr, dynsyms);
- cache_ptr->address -= bfd_get_section_vma (abfd, asect);
- if (cache_ptr->address >= bfd_section_size (abfd, asect))
- --cache_ptr;
- }
- }
- else
- {
- register struct reloc_std_external *rptr
- = (struct reloc_std_external *) dynrels;
-
- for (; counter < dynrel_count; counter++, rptr++, cache_ptr++)
- {
- NAME(aout,swap_std_reloc_in) (abfd, rptr, cache_ptr, dynsyms);
- cache_ptr->address -= bfd_get_section_vma (abfd, asect);
- if (cache_ptr->address >= bfd_section_size (abfd, asect))
- --cache_ptr;
- }
- }
- }
-
asect->relocation = reloc_cache;
asect->reloc_count = cache_ptr - reloc_cache;
bfd *abfd;
sec_ptr asect;
{
- bfd_size_type dynrel_count = 0;
-
if (bfd_get_format (abfd) != bfd_object) {
bfd_set_error (bfd_error_invalid_operation);
return -1;
return (sizeof (arelent *) * (asect->reloc_count+1));
}
- if ((bfd_get_file_flags (abfd) & DYNAMIC) != 0
- && aout_backend_info (abfd)->read_dynamic_relocs)
- {
- PTR dynrels;
-
- dynrel_count = ((*aout_backend_info (abfd)->read_dynamic_relocs)
- (abfd, &dynrels));
- if (dynrel_count == (bfd_size_type) -1)
- return -1;
- }
-
if (asect == obj_datasec (abfd))
- return (sizeof (arelent *) *
- ((exec_hdr(abfd)->a_drsize / obj_reloc_entry_size (abfd))
- + dynrel_count + 1));
+ return (sizeof (arelent *)
+ * ((exec_hdr(abfd)->a_drsize / obj_reloc_entry_size (abfd))
+ + 1));
if (asect == obj_textsec (abfd))
- return (sizeof (arelent *) *
- ((exec_hdr(abfd)->a_trsize / obj_reloc_entry_size (abfd))
- + dynrel_count + 1));
+ return (sizeof (arelent *)
+ * ((exec_hdr(abfd)->a_trsize / obj_reloc_entry_size (abfd))
+ + 1));
bfd_set_error (bfd_error_invalid_operation);
return -1;
weird scope. */
struct external_exec;
struct external_nlist;
+struct reloc_ext_external;
+struct reloc_std_external;
/* Back-end information for various a.out targets. */
struct aout_backend_data
to the size of the text section in the file for alignment purposes but
does *not* get counted in the length of the text section. */
unsigned char exec_header_not_counted;
-
- /* A callback function to read in the dynamic symbols of an object
- which is dynamically linked. This returns the number of symbols
- read (or -1 on error) and sets *SYMS to a buffer holding an array
- of external_nlist structures and *STRS and *STRSIZE to the
- associated string table. (This interface works for SunOS, but
- can be changed if some other interface is better for some other
- shared library implementation). */
- bfd_size_type (*read_dynamic_symbols) PARAMS ((bfd *,
- struct external_nlist **syms,
- char **strs,
- bfd_size_type *strsize));
-
- /* A callback function to read in the dynamic relocs of an object
- which is dynamically linked. This returns the number of relocs
- read (or -1 on error) and sets *RELOCS to a buffer holding an
- array of external reloc structures (the type depends upon the
- type of object file). */
- bfd_size_type (*read_dynamic_relocs) PARAMS ((bfd *, PTR *relocs));
};
#define aout_backend_info(abfd) \
((CONST struct aout_backend_data *)((abfd)->xvec->backend_data))
asymbol *
NAME(aout,make_empty_symbol) PARAMS ((bfd *abfd));
+boolean
+NAME(aout,translate_symbol_table) PARAMS ((bfd *, aout_symbol_type *,
+ struct external_nlist *,
+ bfd_size_type, char *,
+ bfd_size_type,
+ boolean dynamic));
+
boolean
NAME(aout,slurp_symbol_table) PARAMS ((bfd *abfd));
long
NAME(aout,get_symtab) PARAMS ((bfd *abfd, asymbol **location));
+void
+NAME(aout,swap_ext_reloc_in) PARAMS ((bfd *, struct reloc_ext_external *,
+ arelent *, asymbol **));
+void
+NAME(aout,swap_std_reloc_in) PARAMS ((bfd *, struct reloc_std_external *,
+ arelent *, asymbol **));
+
boolean
NAME(aout,slurp_reloc_table) PARAMS ((bfd *abfd, sec_ptr asect,
asymbol **symbols));