#include <string.h> /* For strchr and friends */
#include "bfd.h"
#include <sysdep.h>
-#include <ansidecl.h>
#include "bfdlink.h"
#include "libaout.h"
#define TABLE_SIZE(TABLE) (sizeof(TABLE)/sizeof(TABLE[0]))
CONST struct reloc_howto_struct *
-DEFUN(NAME(aout,reloc_type_lookup),(abfd,code),
- bfd *abfd AND
- bfd_reloc_code_real_type code)
+NAME(aout,reloc_type_lookup) (abfd,code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
{
#define EXT(i,j) case i: return &howto_table_ext[j]
#define STD(i,j) case i: return &howto_table_std[j]
#ifndef NAME_swap_exec_header_in
void
-DEFUN(NAME(aout,swap_exec_header_in),(abfd, raw_bytes, execp),
- bfd *abfd AND
- struct external_exec *raw_bytes AND
- struct internal_exec *execp)
+NAME(aout,swap_exec_header_in) (abfd, raw_bytes, execp)
+ bfd *abfd;
+ struct external_exec *raw_bytes;
+ struct internal_exec *execp;
{
struct external_exec *bytes = (struct external_exec *)raw_bytes;
@var{execp} into the buffer @var{raw_bytes} ready for writing to disk.
*/
void
-DEFUN(NAME(aout,swap_exec_header_out),(abfd, execp, raw_bytes),
- bfd *abfd AND
- struct internal_exec *execp AND
- struct external_exec *raw_bytes)
+NAME(aout,swap_exec_header_out) (abfd, execp, raw_bytes)
+ bfd *abfd;
+ struct internal_exec *execp;
+ struct external_exec *raw_bytes;
{
struct external_exec *bytes = (struct external_exec *)raw_bytes;
*/
bfd_target *
-DEFUN(NAME(aout,some_aout_object_p),(abfd, execp, callback_to_real_object_p),
- bfd *abfd AND
- struct internal_exec *execp AND
- bfd_target *(*callback_to_real_object_p) PARAMS ((bfd *)))
+NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p)
+ bfd *abfd;
+ struct internal_exec *execp;
+ bfd_target *(*callback_to_real_object_p) PARAMS ((bfd *));
{
struct aout_data_struct *rawptr, *oldrawptr;
bfd_target *result;
*/
boolean
-DEFUN(NAME(aout,mkobject),(abfd),
- bfd *abfd)
+NAME(aout,mkobject) (abfd)
+ bfd *abfd;
{
struct aout_data_struct *rawptr;
*/
enum machine_type
-DEFUN(NAME(aout,machine_type),(arch, machine),
- enum bfd_architecture arch AND
- unsigned long machine)
+NAME(aout,machine_type) (arch, machine)
+ enum bfd_architecture arch;
+ unsigned long machine;
{
enum machine_type arch_flags;
*/
boolean
-DEFUN(NAME(aout,set_arch_mach),(abfd, arch, machine),
- bfd *abfd AND
- enum bfd_architecture arch AND
- unsigned long machine)
+NAME(aout,set_arch_mach) (abfd, arch, machine)
+ bfd *abfd;
+ enum bfd_architecture arch;
+ unsigned long machine;
{
if (! bfd_default_set_arch_mach (abfd, arch, machine))
return false;
}
boolean
-DEFUN (NAME(aout,adjust_sizes_and_vmas), (abfd, text_size, text_end),
- bfd *abfd AND bfd_size_type *text_size AND file_ptr *text_end)
+NAME(aout,adjust_sizes_and_vmas) (abfd, text_size, text_end)
+ bfd *abfd;
+ bfd_size_type *text_size;
+ file_ptr *text_end;
{
struct internal_exec *execp = exec_hdr (abfd);
request.
*/
boolean
-DEFUN(NAME(aout,new_section_hook),(abfd, newsect),
- bfd *abfd AND
- asection *newsect)
+NAME(aout,new_section_hook) (abfd, newsect)
+ bfd *abfd;
+ asection *newsect;
{
/* align to double at least */
newsect->alignment_power = bfd_get_arch_info(abfd)->section_align_power;
}
boolean
-DEFUN(NAME(aout,set_section_contents),(abfd, section, location, offset, count),
- bfd *abfd AND
- sec_ptr section AND
- PTR location AND
- file_ptr offset AND
- bfd_size_type count)
+NAME(aout,set_section_contents) (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
{
file_ptr text_end;
bfd_size_type text_size;
stabilised these should be inlined into their (single) caller */
static boolean
-DEFUN (translate_from_native_sym_flags, (sym_pointer, cache_ptr, abfd),
- struct external_nlist *sym_pointer AND
- aout_symbol_type * cache_ptr AND
- bfd * abfd)
+translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd)
+ struct external_nlist *sym_pointer;
+ aout_symbol_type * cache_ptr;
+ bfd * abfd;
{
cache_ptr->symbol.section = 0;
switch (cache_ptr->type & N_TYPE)
static boolean
-DEFUN(translate_to_native_sym_flags,(sym_pointer, cache_ptr, abfd),
- struct external_nlist *sym_pointer AND
- asymbol *cache_ptr AND
- bfd *abfd)
+translate_to_native_sym_flags (sym_pointer, cache_ptr, abfd)
+ struct external_nlist *sym_pointer;
+ asymbol *cache_ptr;
+ bfd *abfd;
{
bfd_vma value = cache_ptr->value;
asymbol *
-DEFUN(NAME(aout,make_empty_symbol),(abfd),
- bfd *abfd)
+NAME(aout,make_empty_symbol) (abfd)
+ bfd *abfd;
{
aout_symbol_type *new =
(aout_symbol_type *)bfd_zalloc (abfd, sizeof (aout_symbol_type));
hold them all plus all the cached symbol entries. */
boolean
-DEFUN(NAME(aout,slurp_symbol_table),(abfd),
- bfd *abfd)
+NAME(aout,slurp_symbol_table) (abfd)
+ bfd *abfd;
{
bfd_size_type symbol_size;
bfd_size_type string_size;
}
boolean
-DEFUN(NAME(aout,write_syms),(abfd),
- bfd *abfd)
+NAME(aout,write_syms) (abfd)
+ bfd *abfd;
{
unsigned int count ;
asymbol **generic = bfd_get_outsymbols (abfd);
\f
unsigned int
-DEFUN(NAME(aout,get_symtab),(abfd, location),
- bfd *abfd AND
- asymbol **location)
+NAME(aout,get_symtab) (abfd, location)
+ bfd *abfd;
+ asymbol **location;
{
unsigned int counter = 0;
aout_symbol_type *symbase;
/* Output standard relocation information to a file in target byte order. */
void
-DEFUN(NAME(aout,swap_std_reloc_out),(abfd, g, natptr),
- bfd *abfd AND
- arelent *g AND
- struct reloc_std_external *natptr)
+NAME(aout,swap_std_reloc_out) (abfd, g, natptr)
+ bfd *abfd;
+ arelent *g;
+ struct reloc_std_external *natptr;
{
int r_index;
asymbol *sym = *(g->sym_ptr_ptr);
/* Output extended relocation information to a file in target byte order. */
void
-DEFUN(NAME(aout,swap_ext_reloc_out),(abfd, g, natptr),
- bfd *abfd AND
- arelent *g AND
- register struct reloc_ext_external *natptr)
+NAME(aout,swap_ext_reloc_out) (abfd, g, natptr)
+ bfd *abfd;
+ arelent *g;
+ register struct reloc_ext_external *natptr;
{
int r_index;
int r_extern;
} \
void
-DEFUN(NAME(aout,swap_ext_reloc_in), (abfd, bytes, cache_ptr, symbols),
- bfd *abfd AND
- struct reloc_ext_external *bytes AND
- arelent *cache_ptr AND
- asymbol **symbols)
+NAME(aout,swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols)
+ bfd *abfd;
+ struct reloc_ext_external *bytes;
+ arelent *cache_ptr;
+ asymbol **symbols;
{
int r_index;
int r_extern;
}
void
-DEFUN(NAME(aout,swap_std_reloc_in), (abfd, bytes, cache_ptr, symbols),
- bfd *abfd AND
- struct reloc_std_external *bytes AND
- arelent *cache_ptr AND
- asymbol **symbols)
+NAME(aout,swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols)
+ bfd *abfd;
+ struct reloc_std_external *bytes;
+ arelent *cache_ptr;
+ asymbol **symbols;
{
int r_index;
int r_extern;
/* Reloc hackery */
boolean
-DEFUN(NAME(aout,slurp_reloc_table),(abfd, asect, symbols),
- bfd *abfd AND
- sec_ptr asect AND
- asymbol **symbols)
+NAME(aout,slurp_reloc_table) (abfd, asect, symbols)
+ bfd *abfd;
+ sec_ptr asect;
+ asymbol **symbols;
{
unsigned int count;
bfd_size_type reloc_size;
/* Write out a relocation section into an object file. */
boolean
-DEFUN(NAME(aout,squirt_out_relocs),(abfd, section),
- bfd *abfd AND
- asection *section)
+NAME(aout,squirt_out_relocs) (abfd, section)
+ bfd *abfd;
+ asection *section;
{
arelent **generic;
unsigned char *native, *natptr;
/* This is stupid. This function should be a boolean predicate */
unsigned int
-DEFUN(NAME(aout,canonicalize_reloc),(abfd, section, relptr, symbols),
- bfd *abfd AND
- sec_ptr section AND
- arelent **relptr AND
- asymbol **symbols)
+NAME(aout,canonicalize_reloc) (abfd, section, relptr, symbols)
+ bfd *abfd;
+ sec_ptr section;
+ arelent **relptr;
+ asymbol **symbols;
{
arelent *tblptr = section->relocation;
unsigned int count;
}
unsigned int
-DEFUN(NAME(aout,get_reloc_upper_bound),(abfd, asect),
- bfd *abfd AND
- sec_ptr asect)
+NAME(aout,get_reloc_upper_bound) (abfd, asect)
+ bfd *abfd;
+ sec_ptr asect;
{
bfd_size_type dynrel_count = 0;
}
\f
- unsigned int
-DEFUN(NAME(aout,get_symtab_upper_bound),(abfd),
- bfd *abfd)
+unsigned int
+NAME(aout,get_symtab_upper_bound) (abfd)
+ bfd *abfd;
{
if (!NAME(aout,slurp_symbol_table)(abfd)) return 0;
/*ARGSUSED*/
alent *
-DEFUN(NAME(aout,get_lineno),(ignore_abfd, ignore_symbol),
- bfd *ignore_abfd AND
- asymbol *ignore_symbol)
+NAME(aout,get_lineno) (ignore_abfd, ignore_symbol)
+ bfd *ignore_abfd;
+ asymbol *ignore_symbol;
{
return (alent *)NULL;
}
/*ARGSUSED*/
void
-DEFUN(NAME(aout,get_symbol_info),(ignore_abfd, symbol, ret),
- bfd *ignore_abfd AND
- asymbol *symbol AND
- symbol_info *ret)
+NAME(aout,get_symbol_info) (ignore_abfd, symbol, ret)
+ bfd *ignore_abfd;
+ asymbol *symbol;
+ symbol_info *ret;
{
bfd_symbol_info (symbol, ret);
/*ARGSUSED*/
void
-DEFUN(NAME(aout,print_symbol),(ignore_abfd, afile, symbol, how),
- bfd *ignore_abfd AND
- PTR afile AND
- asymbol *symbol AND
- bfd_print_symbol_type how)
+NAME(aout,print_symbol) (ignore_abfd, afile, symbol, how)
+ bfd *ignore_abfd;
+ PTR afile;
+ asymbol *symbol;
+ bfd_print_symbol_type how;
{
FILE *file = (FILE *)afile;
*/
boolean
-DEFUN(NAME(aout,find_nearest_line),(abfd,
- section,
- symbols,
- offset,
- filename_ptr,
- functionname_ptr,
- line_ptr),
- bfd *abfd AND
- asection *section AND
- asymbol **symbols AND
- bfd_vma offset AND
- CONST char **filename_ptr AND
- CONST char **functionname_ptr AND
- unsigned int *line_ptr)
+NAME(aout,find_nearest_line)
+ (abfd, section, symbols, offset, filename_ptr, functionname_ptr, line_ptr)
+ bfd *abfd;
+ asection *section;
+ asymbol **symbols;
+ bfd_vma offset;
+ CONST char **filename_ptr;
+ CONST char **functionname_ptr;
+ unsigned int *line_ptr;
{
/* Run down the file looking for the filename, function and linenumber */
asymbol **p;
/*ARGSUSED*/
int
-DEFUN(NAME(aout,sizeof_headers),(abfd, execable),
- bfd *abfd AND
- boolean execable)
+NAME(aout,sizeof_headers) (abfd, execable)
+ bfd *abfd;
+ boolean execable;
{
return adata(abfd).exec_bytes_size;
}
to free them. */
syms = ((struct external_nlist *)
malloc ((size_t) count * EXTERNAL_NLIST_SIZE));
- if (syms == (struct external_nlist *) NULL)
+ if (syms == (struct external_nlist *) NULL && count != 0)
{
bfd_set_error (bfd_error_no_memory);
return false;
return false;
stringsize = GET_WORD (abfd, string_chars);
strings = (char *) malloc ((size_t) stringsize);
- if (strings == NULL)
+ if (strings == NULL && stringsize != 0)
{
bfd_set_error (bfd_error_no_memory);
return false;
sym_count = obj_aout_external_sym_count (input_bfd);
symbol_map = (int *) malloc ((size_t) sym_count * sizeof (int));
- if (symbol_map == NULL)
+ if (symbol_map == NULL && sym_count != 0)
{
bfd_set_error (bfd_error_no_memory);
return false;
/* Get the section contents. */
input_size = bfd_section_size (input_bfd, input_section);
contents = (bfd_byte *) malloc (input_size);
- if (contents == NULL)
+ if (contents == NULL && input_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
/* Read in the relocs. */
relocs = (PTR) malloc (rel_size);
- if (relocs == NULL)
+ if (relocs == NULL && rel_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
/* First, read in space names */
space_strings = malloc (file_hdr->space_strings_size);
- if (!space_strings)
+ if (!space_strings && file_hdr->space_strings_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
{
/* Handle a section symbol; these have no pointers back to the
SOM symbol info. So we just use the pointer field (udata)
- to hold the relocation count.
-
- FIXME. While we're here set the name of any section symbol
- to something which will not screw GDB. How do other formats
- deal with this?!? */
- if (som_symbol_data (syms[i]) == NULL)
+ to hold the relocation count. */
+ if (som_symbol_data (syms[i]) == NULL
+ || syms[i]->flags & BSF_SECTION_SYM)
{
syms[i]->flags |= BSF_SECTION_SYM;
- syms[i]->name = "L$0\002";
syms[i]->udata = (PTR) 0;
}
else
we support only the copyright and version headers. */
obj_som_file_hdr (abfd)->aux_header_location = current_offset;
obj_som_file_hdr (abfd)->aux_header_size = 0;
+ if (abfd->flags & EXEC_P)
+ {
+ /* Parts of the exec header will be filled in later, so
+ delay writing the header itself. Just leave space for
+ it. */
+ current_offset += sizeof (struct som_exec_auxhdr);
+ obj_som_file_hdr (abfd)->aux_header_size += sizeof (struct som_exec_auxhdr);
+ }
if (obj_som_version_hdr (abfd) != NULL)
{
unsigned int len;
to hold the symbol table as we build it. */
symtab_size = num_syms * sizeof (struct symbol_dictionary_record);
som_symtab = (struct symbol_dictionary_record *) malloc (symtab_size);
- if (som_symtab == NULL)
+ if (som_symtab == NULL && symtab_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
/* Read in the external SOM representation. */
buf = malloc (symbol_count * symsize);
- if (buf == NULL)
+ if (buf == NULL && symbol_count * symsize != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
/* Mark section symbols and symbols used by the debugger. */
- if (!strcmp (sym->symbol.name, "L$0\002"))
+ if (sym->symbol.name[0] == '$'
+ && sym->symbol.name[strlen (sym->symbol.name) - 1] == '$')
sym->symbol.flags |= BSF_SECTION_SYM;
- else if (!strncmp (sym->symbol.name, "L$0", 3))
+ else if (!strncmp (sym->symbol.name, "L$0\002", 4))
+ {
+ sym->symbol.flags |= BSF_SECTION_SYM;
+ sym->symbol.name = sym->symbol.section->name;
+ }
+ else if (!strncmp (sym->symbol.name, "L$0\001", 4))
sym->symbol.flags |= BSF_DEBUGGING;
/* Note increment at bottom of loop, since we skip some symbols
hash_table =
(unsigned int *) malloc (lst_header->hash_size * sizeof (unsigned int));
- if (hash_table == NULL)
+ if (hash_table == NULL && lst_header->hash_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
hash_table =
(unsigned int *) malloc (lst_header->hash_size * sizeof (unsigned int));
- if (hash_table == NULL)
+ if (hash_table == NULL && lst_header->hash_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
som_dict =
(struct som_entry *) malloc (lst_header->module_count
* sizeof (struct som_entry));
- if (som_dict == NULL)
+ if (som_dict == NULL && lst_header->module_count != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
hash_table =
(unsigned int *) malloc (lst.hash_size * sizeof (unsigned int));
- if (hash_table == NULL)
+ if (hash_table == NULL && lst.hash_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
som_dict =
(struct som_entry *) malloc (lst.module_count
* sizeof (struct som_entry));
- if (som_dict == NULL)
+ if (som_dict == NULL && lst.module_count != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
last_hash_entry =
((struct lst_symbol_record **)
malloc (lst.hash_size * sizeof (struct lst_symbol_record *)));
- if (last_hash_entry == NULL)
+ if (last_hash_entry == NULL && lst.hash_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
/* FIXME should be done with buffers just like everything else... */
lst_syms = malloc (nsyms * sizeof (struct lst_symbol_record));
- if (lst_syms == NULL)
+ if (lst_syms == NULL && nsyms != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
strings = malloc (string_size);
- if (strings == NULL)
+ if (strings == NULL && string_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;