target jump vector for a specific target.
This information is further split out into more specific files for each
-machine, including @code{sunos.c} - for sun3 and sun4 and
-@code{demo64} for a demonstration of a 64 bit a.out format.
+machine, including @code{sunos.c} for sun3 and sun4, @code{newsos3.c} for
+the Sony NEWS, and @code{demo64.c} for a demonstration of a 64 bit a.out
+format.
The base file @code{aoutx.h} defines general mechanisms for reading
and writing records to and from disk, and various other methods which
sunos_big_vec
@end example
+The file host-aout.c is a special case. It is for a large set of hosts
+that use ``more or less standard'' a.out files, and for which cross-debugging
+is not interesting. It uses the standard 32-bit a.out support routines,
+but determines the file offsets and addresses of the text, data,
+and BSS sections, the machine architecture and machine type,
+and the entry point address, in a host-dependent manner. Once these
+values have been determined, generic code is used to handle the
+object file.
+
+When porting it to run on a new system, you must supply:
+
+ HOST_PAGE_SIZE
+ HOST_SEGMENT_SIZE
+ HOST_MACHINE_ARCH (optional)
+ HOST_MACHINE_MACHINE (optional)
+ HOST_TEXT_START_ADDR
+ HOST_STACK_END_ADDR
+
+in the file ../include/sys/h-XXX.h (for your host). These values, plus
+the structures and macros defined in <a.out.h> on your host system, will
+produce a BFD target that will access ordinary a.out files on your host.
+
+To configure a new machine to use host-aout.c, specify:
+
+TDEFAULTS = -DDEFAULT_VECTOR=host_aout_big_vec
+TDEPFILES= host-aout.o trad-core.o
+
+in the config/mt-XXX file, and modify configure.in to use the
+mt-XXX file (by setting "bfd_target=XXX") when your configuration is
+selected.
+
*/
#define KEEPIT flags
*/
#define CTOR_TABLE_RELOC_IDX 2
-/* start-sanitize-v9 */
-/* Provided the symbol, returns the value reffed */
-static bfd_vma
-DEFUN(get_symbol_value,(symbol, input_section),
- asymbol *symbol AND
- asection *input_section)
-{
- bfd_vma relocation = 0;
-
- if (symbol != (asymbol *)NULL) {
- if (symbol->flags & BSF_FORT_COMM) {
- relocation = 0;
- } else {
- relocation = symbol->value;
- }
- if (symbol->section != (asection *)NULL) {
- relocation += symbol->section->output_section->vma +
- symbol->section->output_offset;
- }
- }
- else {
- /* No symbol, so use the input section value */
- relocation = input_section->output_section->vma + input_section->output_offset;
- }
- return relocation;
-}
-
-static bfd_reloc_status_enum_type
-DEFUN(reloc64,(abfd, reloc_entry, symbol_in, data, input_section),
- bfd *abfd AND
- arelent *reloc_entry AND
- asymbol *symbol_in AND
- unsigned char *data AND
- asection *input_section)
-{
- bfd_vma sym_value = get_symbol_value(symbol_in, input_section);
- bfd_vma value = bfd_get_64(abfd, (bfd_byte *)data + reloc_entry->address);
- value += sym_value + reloc_entry->addend;
- bfd_put_64(abfd, value, (bfd_byte *)data+reloc_entry->address);
- return bfd_reloc_ok;
-}
-
-static bfd_reloc_status_enum_type
-DEFUN(disp64,(abfd, reloc_entry, symbol_in, data, input_section),
- bfd *abfd AND
- arelent *reloc_entry AND
- asymbol *symbol_in AND
- unsigned char *data AND
- asection *input_section)
-{
- bfd_vma sym_value = get_symbol_value(symbol_in, input_section);
-
-/* bfd_get_64(abfd, (bfd_byte *)data + reloc_entry->address);*/
- bfd_vma value = 0;
- value += sym_value + reloc_entry->addend;
-
- /* Subtract from the calculated value the pc */
- value -= reloc_entry->address + input_section->output_section->vma;
- bfd_put_64(abfd, value, (bfd_byte *)data+reloc_entry->address);
- return bfd_reloc_ok;
-}
-
-static bfd_reloc_status_enum_type
-DEFUN(hhi22,(abfd, reloc_entry, symbol_in, data, input_section),
- bfd *abfd AND
- arelent *reloc_entry AND
- asymbol *symbol_in AND
- unsigned char *data AND
- asection *input_section)
-{
- bfd_vma sym_value = get_symbol_value(symbol_in, input_section);
-
- bfd_vma value = bfd_get_32(abfd, (bfd_byte *)data + reloc_entry->address);
-
- value = (value & ~0x3fffff) | ( ((sym_value + reloc_entry->addend) >> 32+10) & 0x3fffff);
-
- bfd_put_32(abfd, value, (bfd_byte *)data+reloc_entry->address);
- return bfd_reloc_ok;
-}
-
-static bfd_reloc_status_enum_type
-DEFUN(hlo10,(abfd, reloc_entry, symbol_in, data, input_section),
- bfd *abfd AND
- arelent *reloc_entry AND
- asymbol *symbol_in AND
- unsigned char *data AND
- asection *input_section)
-{
- bfd_vma sym_value = get_symbol_value(symbol_in, input_section);
-
- bfd_vma value = bfd_get_32(abfd, (bfd_byte *)data + reloc_entry->address);
-
- value = (value & ~0x3ff) | (((sym_value + reloc_entry->addend) >> 32) & 0x3ff);
-
- bfd_put_32(abfd, value, (bfd_byte *)data+reloc_entry->address);
- return bfd_reloc_ok;
-}
-
-static bfd_reloc_status_enum_type
-r64()
-{
- abort();
-}
-
-/* end-sanitize-v9 */
static reloc_howto_type howto_table_ext[] =
{
HOWTO(RELOC_JMP_SLOT,0, 2, 0, false, 0, false, true,0,"JMP_SLOT", false, 0,0x00000000, false),
HOWTO(RELOC_RELATIVE,0, 2, 0, false, 0, false, true,0,"RELATIVE", false, 0,0x00000000, false),
-/* start-sanitize-v9 */
-
- HOWTO(RELOC_11, 0, 2, 21, true, 0, false, true,r64,"11", false, 0,/*0x00000000001fffff*/0, false),
- HOWTO(RELOC_WDISP2_14, 0, 2, 21, true, 0, false, true,r64,"DISP2_14",false, 0,/*0x00000000001fffff*/0, false),
- HOWTO(RELOC_WDISP19, 0, 3, 64, true, 0, false, true,r64,"DISP19", false, 0,/*0xffffffffffffffff*/0, false),
- HOWTO(RELOC_HHI22, 42, 3, 22, false, 0, false, true,hhi22,"HHI22",false, 0,/*0x003fffff00000000*/0, false),
- HOWTO(RELOC_HLO10, 32, 3, 10, false, 0, false, true,hlo10,"HLO10", false, 0,/*0x000003ff00000000*/0, false),
-
- HOWTO(RELOC_JUMPTARG,2, 13, 16, true, 0, false, true,0,"JUMPTARG", false, 0,0x0000ffff, false),
- HOWTO(RELOC_CONST, 0, 13, 16, false, 0, false, true,0,"CONST", false, 0,0x0000ffff, false),
- HOWTO(RELOC_CONSTH, 16, 13, 16, false, 0, false, true,0,"CONSTH", false, 0,0x0000ffff, false),
-
-
- HOWTO(RELOC_64, 0, 3, 64, false, 0, true, true,reloc64,"64", false, 0,/*0xffffffffffffffff*/0, false),
- HOWTO(RELOC_DISP64, 0, 3, 64, true, 0, false, true,disp64,"DISP64", false, 0,/*0xffffffffffffffff*/0, false),
- HOWTO(RELOC_WDISP21,2, 2, 21, true, 0, false, true,r64,"WDISP21",false, 0,/*0x00000000001fffff*/0, false),
- HOWTO(RELOC_DISP21, 0, 2, 21, true, 0, false, true,r64,"DISP21", false, 0,/*0x00000000001fffff*/0, false),
- HOWTO(RELOC_DISP14, 0, 2, 14, true, 0, false, true,r64,"DISP21", false, 0,/*0x0000000000003fff*/0, false),
-
-/* end-sanitize-v9 */
};
/* Convert standard reloc records to "arelent" format (incl byte swap). */
*/
bfd_target *
-DEFUN(NAME(aout,some_aout_object_p),(abfd, callback_to_real_object_p),
+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) ())
{
- struct external_exec exec_bytes;
- struct internal_exec *execp;
struct container *rawptr;
- if (bfd_seek (abfd, 0L, false) < 0) {
- bfd_error = system_call_error;
- return 0;
- }
-
- if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
- != EXEC_BYTES_SIZE) {
- bfd_error = wrong_format;
- return 0;
- }
-
- /* Use an intermediate variable for clarity */
rawptr = (struct container *) bfd_zalloc (abfd, sizeof (struct container));
-
if (rawptr == NULL) {
bfd_error = no_memory;
return 0;
}
- set_tdata (abfd, rawptr);
- exec_hdr (abfd) = execp = &(rawptr->e);
- NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, execp);
+ set_tdata (abfd, &rawptr->a);
+ exec_hdr (abfd) = &rawptr->e;
+ *exec_hdr (abfd) = *execp; /* Copy in the internal_exec struct */
+ execp = exec_hdr (abfd); /* Switch to using the newly malloc'd one */
/* Set the file flags */
abfd->flags = NO_FLAGS;
/* Set the default architecture and machine type. These can be
overridden in the callback routine. */
- abfd->obj_arch = bfd_arch_unknown;
- abfd->obj_machine = 0;
+
+ bfd_default_set_arch_mach(abfd, bfd_arch_unknown, 0);
/* The default relocation entry size is that of traditional V7 Unix. */
obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
+ /* The default symbol entry size is that of traditional Unix. */
+ obj_symbol_entry_size (abfd) = EXTERNAL_NLIST_SIZE;
+
/* create the sections. This is raunchy, but bfd_close wants to reclaim
them */
obj_textsec (abfd) = (asection *)NULL;
obj_datasec (abfd)->size = execp->a_data;
obj_bsssec (abfd)->size = execp->a_bss;
- obj_textsec (abfd)->size = execp->a_text;
-
- if (abfd->flags & D_PAGED) {
- obj_textsec (abfd)->size -= EXEC_BYTES_SIZE;
- }
-
obj_textsec (abfd)->flags = (execp->a_trsize != 0 ?
- (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_HAS_CONTENTS) :
- (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS));
+ (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_HAS_CONTENTS) :
+ (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS));
obj_datasec (abfd)->flags = (execp->a_drsize != 0 ?
- (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_HAS_CONTENTS) :
- (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS));
+ (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_HAS_CONTENTS) :
+ (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS));
obj_bsssec (abfd)->flags = SEC_ALLOC;
#ifdef THIS_IS_ONLY_DOCUMENTATION
+ /* The common code can't fill in these things because they depend
+ on either the start address of the text segment, the rounding
+ up of virtual addersses between segments, or the starting file
+ position of the text segment -- all of which varies among different
+ versions of a.out. */
+
/* Call back to the format-dependent code to fill in the rest of the
fields and do any further cleanup. Things that should be filled
in by the callback: */
struct exec *execp = exec_hdr (abfd);
+ obj_textsec (abfd)->size = N_TXTSIZE(*execp);
+ /* data and bss are already filled in since they're so standard */
+
/* The virtual memory addresses of the sections */
- obj_datasec (abfd)->vma = N_DATADDR(*execp);
- obj_bsssec (abfd)->vma = N_BSSADDR(*execp);
obj_textsec (abfd)->vma = N_TXTADDR(*execp);
+ obj_datasec (abfd)->vma = N_DATADDR(*execp);
+ obj_bsssec (abfd)->vma = N_BSSADDR(*execp);
/* The file offsets of the sections */
obj_textsec (abfd)->filepos = N_TXTOFF(*execp);
obj_str_filepos (abfd) = N_STROFF (*execp);
obj_sym_filepos (abfd) = N_SYMOFF (*execp);
- /* This common code can't fill in those things because they depend
- on either the start address of the text segment, the rounding
- up of virtual addersses between segments, or the starting file
- position of the text segment -- all of which varies among different
- versions of a.out. */
-
/* Determine the architecture and machine type of the object file. */
switch (N_MACHTYPE (*exec_hdr (abfd))) {
default:
obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
}
+ adata(abfd)->page_size = PAGE_SIZE;
+ adata(abfd)->segment_size = SEGMENT_SIZE;
+ adata(abfd)->exec_bytes_size = EXEC_BYTES_SIZE;
+
return abfd->xvec;
/* The architecture is encoded in various ways in various a.out variants,
header, should cope with them in this callback as well. */
#endif /* DOCUMENTATION */
-
return (*callback_to_real_object_p)(abfd);
}
return arch_flags;
}
+
/*doc*
*i aout_<size>_set_arch_mach
enum bfd_architecture arch AND
unsigned long machine)
{
- abfd->obj_arch = arch;
- abfd->obj_machine = machine;
+ bfd_default_set_arch_mach(abfd, arch, machine);
if (arch != bfd_arch_unknown &&
NAME(aout,machine_type) (arch, machine) == M_UNKNOWN)
return false; /* We can't represent this type */
}
/*doc*
-*i aout_<size>new_section_hook
-
-Called by the BFD in response to a @code{bfd_make_section} request.
-*; PROTO(boolean, aout_<size>_new_section_hook,
- (bfd *abfd,
- asection *newsect));
+ *i aout_<size>new_section_hook
+
+ Called by the BFD in response to a @code{bfd_make_section} request.
+ *; PROTO(boolean, aout_<size>_new_section_hook,
+ (bfd *abfd,
+ asection *newsect));
*/
boolean
-DEFUN(NAME(aout,new_section_hook),(abfd, newsect),
- bfd *abfd AND
- asection *newsect)
+ DEFUN(NAME(aout,new_section_hook),(abfd, newsect),
+ bfd *abfd AND
+ asection *newsect)
{
/* align to double at least */
newsect->alignment_power = 3;
}
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)
+ 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)
{
+ file_ptr text_end;
+ bfd_size_type text_header_size; /* exec_bytes_size if if included in
+ text size. */
+ bfd_size_type text_size;
if (abfd->output_has_begun == false)
{ /* set by bfd.c handler */
- if ((obj_textsec (abfd) == NULL) || (obj_datasec (abfd) == NULL))
+ switch (abfd->direction)
{
+ case read_direction:
+ case no_direction:
bfd_error = invalid_operation;
return false;
+
+ case both_direction:
+ break;
+
+ case write_direction:
+ if ((obj_textsec (abfd) == NULL) || (obj_datasec (abfd) == NULL))
+ {
+ bfd_error = invalid_operation;
+ return false;
+ }
+ obj_textsec(abfd)->size =
+ align_power(obj_textsec(abfd)->size,
+ obj_textsec(abfd)->alignment_power);
+ text_size = obj_textsec (abfd)->size;
+ /* Rule (heuristic) for when to pad to a new page.
+ * Note that there are (at least) two ways demand-paged
+ * (ZMAGIC) files have been handled. Most Berkeley-based systems
+ * start the text segment at (PAGE_SIZE). However, newer
+ * versions of SUNOS start the text segment right after the
+ * exec header; the latter is counted in the text segment size,
+ * and is paged in by the kernel with the rest of the text. */
+ if (!(abfd->flags & D_PAGED))
+ { /* Not demand-paged. */
+ obj_textsec(abfd)->filepos = adata(abfd)->exec_bytes_size;
+ }
+ else if (obj_textsec(abfd)->vma % adata(abfd)->page_size
+ < adata(abfd)->exec_bytes_size)
+ { /* Old-style demand-paged. */
+ obj_textsec(abfd)->filepos = adata(abfd)->page_size;
+ }
+ else
+ { /* Sunos-style demand-paged. */
+ obj_textsec(abfd)->filepos = adata(abfd)->exec_bytes_size;
+ text_size += adata(abfd)->exec_bytes_size;
+ }
+ text_end = obj_textsec(abfd)->size + obj_textsec(abfd)->filepos;
+ if (abfd->flags & (D_PAGED|WP_TEXT))
+ {
+ bfd_size_type text_pad =
+ ALIGN(text_size, adata(abfd)->segment_size) - text_size;
+ text_end += text_pad;
+ obj_textsec(abfd)->size += text_pad;
+ }
+ obj_datasec(abfd)->filepos = text_end;
+ obj_datasec(abfd)->size =
+ align_power(obj_datasec(abfd)->size,
+ obj_datasec(abfd)->alignment_power);
}
-/* if (abfd->flags & D_PAGED) {
- obj_textsec(abfd)->filepos = 0;
- }
- else*/ {
- obj_textsec(abfd)->filepos = EXEC_BYTES_SIZE;
- }
- obj_textsec(abfd)->size = align_power(obj_textsec(abfd)->size,
- obj_textsec(abfd)->alignment_power);
- obj_datasec(abfd)->filepos = obj_textsec (abfd)->size + EXEC_BYTES_SIZE;
- obj_datasec(abfd)->size = align_power(obj_datasec(abfd)->size,
- obj_datasec(abfd)->alignment_power);
-
-
}
+
/* regardless, once we know what we're doing, we might as well get going */
if (section != obj_bsssec(abfd))
{
bfd_seek (abfd, section->filepos + offset, SEEK_SET);
-
+
if (count) {
return (bfd_write ((PTR)location, 1, count, abfd) == count) ?
true : false;
/* Classify stabs symbols */
#define sym_in_text_section(sym) \
-(((sym)->type & (N_ABS | N_TEXT | N_DATA | N_BSS))== N_TEXT)
+ (((sym)->type & (N_ABS | N_TEXT | N_DATA | N_BSS))== N_TEXT)
#define sym_in_data_section(sym) \
-(((sym)->type & (N_ABS | N_TEXT | N_DATA | N_BSS))== N_DATA)
+ (((sym)->type & (N_ABS | N_TEXT | N_DATA | N_BSS))== N_DATA)
#define sym_in_bss_section(sym) \
-(((sym)->type & (N_ABS | N_TEXT | N_DATA | N_BSS))== N_BSS)
+ (((sym)->type & (N_ABS | N_TEXT | N_DATA | N_BSS))== N_BSS)
/* Symbol is undefined if type is N_UNDF|N_EXT and if it has
-zero in the "value" field. Nonzeroes there are fortrancommon
-symbols. */
+ zero in the "value" field. Nonzeroes there are fortrancommon
+ symbols. */
#define sym_is_undefined(sym) \
-((sym)->type == (N_UNDF | N_EXT) && (sym)->symbol.value == 0)
+ ((sym)->type == (N_UNDF | N_EXT) && (sym)->symbol.value == 0)
/* Symbol is a global definition if N_EXT is on and if it has
-a nonzero type field. */
+ a nonzero type field. */
#define sym_is_global_defn(sym) \
-(((sym)->type & N_EXT) && (sym)->type & N_TYPE)
+ (((sym)->type & N_EXT) && (sym)->type & N_TYPE)
/* Symbol is debugger info if any bits outside N_TYPE or N_EXT
-are on. */
+ are on. */
#define sym_is_debugger_info(sym) \
-((sym)->type & ~(N_EXT | N_TYPE))
+ ((sym)->type & ~(N_EXT | N_TYPE))
#define sym_is_fortrancommon(sym) \
-(((sym)->type == (N_EXT)) && (sym)->symbol.value != 0)
+ (((sym)->type == (N_EXT)) && (sym)->symbol.value != 0)
/* Symbol is absolute if it has N_ABS set */
#define sym_is_absolute(sym) \
-(((sym)->type & N_TYPE)== N_ABS)
+ (((sym)->type & N_TYPE)== N_ABS)
#define sym_is_indirect(sym) \
-(((sym)->type & N_ABS)== N_ABS)
+ (((sym)->type & N_ABS)== N_ABS)
/* Only in their own functions for ease of debugging; when sym flags have
-stabilised these should be inlined into their (single) caller */
-
+ stabilised these should be inlined into their (single) caller */
+
static void
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)
- {
- switch (cache_ptr->type & N_TYPE) {
- case N_SETA:
- case N_SETT:
- case N_SETD:
- case N_SETB:
- {
- char *copy = bfd_alloc(abfd, strlen(cache_ptr->symbol.name)+1);
- asection *section ;
- arelent_chain *reloc = (arelent_chain *)bfd_alloc(abfd, sizeof(arelent_chain));
- strcpy(copy, cache_ptr->symbol.name);
+struct external_nlist *sym_pointer AND
+aout_symbol_type *cache_ptr AND
+bfd *abfd)
+{
+ switch (cache_ptr->type & N_TYPE) {
+ case N_SETA:
+ case N_SETT:
+ case N_SETD:
+ case N_SETB:
+ {
+ char *copy = bfd_alloc(abfd, strlen(cache_ptr->symbol.name)+1);
+ asection *section ;
+ arelent_chain *reloc = (arelent_chain *)bfd_alloc(abfd, sizeof(arelent_chain));
+ strcpy(copy, cache_ptr->symbol.name);
+ section = bfd_get_section_by_name (abfd, copy);
+ if (!section)
section = bfd_make_section(abfd,copy);
- switch ( (cache_ptr->type & N_TYPE) ) {
- case N_SETA:
- section->flags = SEC_CONSTRUCTOR;
- reloc->relent.section = (asection *)NULL;
- cache_ptr->symbol.section = (asection *)NULL;
- break;
- case N_SETT:
- section->flags = SEC_CONSTRUCTOR_TEXT;
- reloc->relent.section = (asection *)obj_textsec(abfd);
- cache_ptr->symbol.value -= reloc->relent.section->vma;
- break;
- case N_SETD:
- section->flags = SEC_CONSTRUCTOR_DATA;
- reloc->relent.section = (asection *)obj_datasec(abfd);
- cache_ptr->symbol.value -= reloc->relent.section->vma;
- break;
- case N_SETB:
- section->flags = SEC_CONSTRUCTOR_BSS;
- reloc->relent.section = (asection *)obj_bsssec(abfd);
- cache_ptr->symbol.value -= reloc->relent.section->vma;
- break;
- }
- cache_ptr->symbol.section = reloc->relent.section;
- reloc->relent.addend = cache_ptr->symbol.value ;
+
+ switch ( (cache_ptr->type & N_TYPE) ) {
+ case N_SETA:
+ section->flags = SEC_CONSTRUCTOR;
+ reloc->relent.section = (asection *)NULL;
+ cache_ptr->symbol.section = (asection *)NULL;
+ break;
+ case N_SETT:
+ section->flags = SEC_CONSTRUCTOR_TEXT;
+ reloc->relent.section = (asection *)obj_textsec(abfd);
+ cache_ptr->symbol.value -= reloc->relent.section->vma;
+ break;
+ case N_SETD:
+ section->flags = SEC_CONSTRUCTOR_DATA;
+ reloc->relent.section = (asection *)obj_datasec(abfd);
+ cache_ptr->symbol.value -= reloc->relent.section->vma;
+ break;
+ case N_SETB:
+ section->flags = SEC_CONSTRUCTOR_BSS;
+ reloc->relent.section = (asection *)obj_bsssec(abfd);
+ cache_ptr->symbol.value -= reloc->relent.section->vma;
+ break;
+ }
+ cache_ptr->symbol.section = reloc->relent.section;
+ reloc->relent.addend = cache_ptr->symbol.value ;
- /* We modify the symbol to belong to a section depending upon the
- name of the symbol - probably __CTOR__ or __DTOR__ but we don't
- really care, and add to the size of the section to contain a
- pointer to the symbol. Build a reloc entry to relocate to this
- symbol attached to this section. */
+ /* We modify the symbol to belong to a section depending upon the
+ name of the symbol - probably __CTOR__ or __DTOR__ but we don't
+ really care, and add to the size of the section to contain a
+ pointer to the symbol. Build a reloc entry to relocate to this
+ symbol attached to this section. */
- section->reloc_count++;
- section->alignment_power = 2;
- reloc->relent.sym_ptr_ptr = (asymbol **)NULL;
- reloc->next = section->constructor_chain;
- section->constructor_chain = reloc;
- reloc->relent.address = section->size;
- section->size += sizeof(int *);
+ section->reloc_count++;
+ section->alignment_power = 2;
+ reloc->relent.sym_ptr_ptr = (asymbol **)NULL;
+ reloc->next = section->constructor_chain;
+ section->constructor_chain = reloc;
+ reloc->relent.address = section->size;
+ section->size += sizeof(int *);
- reloc->relent.howto = howto_table_ext +CTOR_TABLE_RELOC_IDX;
- cache_ptr->symbol.flags |= BSF_DEBUGGING | BSF_CONSTRUCTOR;
- }
- break;
+ reloc->relent.howto = howto_table_ext +CTOR_TABLE_RELOC_IDX;
+ cache_ptr->symbol.flags |= BSF_DEBUGGING | BSF_CONSTRUCTOR;
+ }
+ break;
default:
if (cache_ptr->type == N_WARNING)
{
- /* This symbol is the text of a warning message, the next symbol
- is the symbol to associate the warning with */
- cache_ptr->symbol.flags = BSF_DEBUGGING | BSF_WARNING;
- cache_ptr->symbol.value = (bfd_vma)((cache_ptr+1));
- /* We furgle with the next symbol in place. We don't want it to be undefined, we'll trample the type */
- (sym_pointer+1)->e_type[0] = 0xff;
- break;
- }
+ /* This symbol is the text of a warning message, the next symbol
+ is the symbol to associate the warning with */
+ cache_ptr->symbol.flags = BSF_DEBUGGING | BSF_WARNING;
+ cache_ptr->symbol.value = (bfd_vma)((cache_ptr+1));
+ /* We furgle with the next symbol in place. We don't want it to be undefined, we'll trample the type */
+ (sym_pointer+1)->e_type[0] = 0xff;
+ break;
+ }
if ((cache_ptr->type | N_EXT) == (N_INDR | N_EXT)) {
/* Two symbols in a row for an INDR message. The first symbol
contains the name we will match, the second symbol contains the
asymbol *
DEFUN(NAME(aout,make_empty_symbol),(abfd),
bfd *abfd)
- {
- aout_symbol_type *new =
- (aout_symbol_type *)bfd_zalloc (abfd, sizeof (aout_symbol_type));
- new->symbol.the_bfd = abfd;
+{
+ aout_symbol_type *new =
+ (aout_symbol_type *)bfd_zalloc (abfd, sizeof (aout_symbol_type));
+ new->symbol.the_bfd = abfd;
- return &new->symbol;
- }
+ return &new->symbol;
+}
boolean
DEFUN(NAME(aout,slurp_symbol_table),(abfd),
bfd *abfd)
- {
- bfd_size_type symbol_size;
- bfd_size_type string_size;
- unsigned char string_chars[BYTES_IN_WORD];
- struct external_nlist *syms;
- char *strings;
- aout_symbol_type *cached;
+{
+ bfd_size_type symbol_size;
+ bfd_size_type string_size;
+ unsigned char string_chars[BYTES_IN_WORD];
+ struct external_nlist *syms;
+ char *strings;
+ aout_symbol_type *cached;
- /* If there's no work to be done, don't do any */
- if (obj_aout_symbols (abfd) != (aout_symbol_type *)NULL) return true;
- symbol_size = exec_hdr(abfd)->a_syms;
- if (symbol_size == 0) {
- bfd_error = no_symbols;
- return false;
- }
+ /* If there's no work to be done, don't do any */
+ if (obj_aout_symbols (abfd) != (aout_symbol_type *)NULL) return true;
+ symbol_size = exec_hdr(abfd)->a_syms;
+ if (symbol_size == 0) {
+ bfd_error = no_symbols;
+ return false;
+ }
- bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET);
- if (bfd_read ((PTR)string_chars, BYTES_IN_WORD, 1, abfd) != BYTES_IN_WORD)
- return false;
- string_size = GET_WORD (abfd, string_chars);
+ bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET);
+ if (bfd_read ((PTR)string_chars, BYTES_IN_WORD, 1, abfd) != BYTES_IN_WORD)
+ return false;
+ string_size = GET_WORD (abfd, string_chars);
- strings =(char *) bfd_alloc(abfd, string_size + 1);
- cached = (aout_symbol_type *)
- bfd_zalloc(abfd, (bfd_size_type)(bfd_get_symcount (abfd) * sizeof(aout_symbol_type)));
-
- /* malloc this, so we can free it if simply. The symbol caching
- might want to allocate onto the bfd's obstack */
- syms = (struct external_nlist *) malloc(symbol_size);
- bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET);
- if (bfd_read ((PTR)syms, 1, symbol_size, abfd) != symbol_size) {
- bailout:
- if (syms) free (syms);
- if (cached) bfd_release (abfd, cached);
- if (strings)bfd_release (abfd, strings);
- return false;
- }
+ strings =(char *) bfd_alloc(abfd, string_size + 1);
+ cached = (aout_symbol_type *)
+ bfd_zalloc(abfd, (bfd_size_type)(bfd_get_symcount (abfd) * sizeof(aout_symbol_type)));
+
+ /* malloc this, so we can free it if simply. The symbol caching
+ might want to allocate onto the bfd's obstack */
+ syms = (struct external_nlist *) bfd_xmalloc(symbol_size);
+ bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET);
+ if (bfd_read ((PTR)syms, 1, symbol_size, abfd) != symbol_size) {
+ bailout:
+ if (syms) free (syms);
+ if (cached) bfd_release (abfd, cached);
+ if (strings)bfd_release (abfd, strings);
+ return false;
+ }
- bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET);
- if (bfd_read ((PTR)strings, 1, string_size, abfd) != string_size) {
- goto bailout;
- }
+ bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET);
+ if (bfd_read ((PTR)strings, 1, string_size, abfd) != string_size) {
+ goto bailout;
+ }
- /* OK, now walk the new symtable, cacheing symbol properties */
- {
- register struct external_nlist *sym_pointer;
- register struct external_nlist *sym_end = syms + bfd_get_symcount (abfd);
- register aout_symbol_type *cache_ptr = cached;
+ /* OK, now walk the new symtable, cacheing symbol properties */
+ {
+ register struct external_nlist *sym_pointer;
+ register struct external_nlist *sym_end = syms + bfd_get_symcount (abfd);
+ register aout_symbol_type *cache_ptr = cached;
- /* Run through table and copy values */
- for (sym_pointer = syms, cache_ptr = cached;
- sym_pointer < sym_end; sym_pointer++, cache_ptr++)
- {
- bfd_vma x = GET_WORD(abfd, sym_pointer->e_strx);
- cache_ptr->symbol.the_bfd = abfd;
- if (x)
- cache_ptr->symbol.name = x + strings;
- else
- cache_ptr->symbol.name = (char *)NULL;
+ /* Run through table and copy values */
+ for (sym_pointer = syms, cache_ptr = cached;
+ sym_pointer < sym_end; sym_pointer++, cache_ptr++)
+ {
+ bfd_vma x = GET_WORD(abfd, sym_pointer->e_strx);
+ cache_ptr->symbol.the_bfd = abfd;
+ if (x)
+ cache_ptr->symbol.name = x + strings;
+ else
+ cache_ptr->symbol.name = (char *)NULL;
- cache_ptr->symbol.value = GET_SWORD(abfd, sym_pointer->e_value);
- cache_ptr->desc = bfd_get_16(abfd, sym_pointer->e_desc);
- cache_ptr->other =bfd_get_8(abfd, sym_pointer->e_other);
- cache_ptr->type = bfd_get_8(abfd, sym_pointer->e_type);
- cache_ptr->symbol.udata = 0;
- translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd);
- }
- }
+ cache_ptr->symbol.value = GET_SWORD(abfd, sym_pointer->e_value);
+ cache_ptr->desc = bfd_get_16(abfd, sym_pointer->e_desc);
+ cache_ptr->other =bfd_get_8(abfd, sym_pointer->e_other);
+ cache_ptr->type = bfd_get_8(abfd, sym_pointer->e_type);
+ cache_ptr->symbol.udata = 0;
+ translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd);
+ }
+ }
- obj_aout_symbols (abfd) = cached;
- free((PTR)syms);
+ obj_aout_symbols (abfd) = cached;
+ free((PTR)syms);
- return true;
- }
+ return true;
+}
void
asymbol *g = generic[count];
struct external_nlist nsp;
-
if (g->name) {
unsigned int length = strlen(g->name) +1;
PUT_WORD (abfd, stindex, (unsigned char *)nsp.e_strx);
bfd_h_put_8(abfd, 0, nsp.e_other);
bfd_h_put_8(abfd, 0, nsp.e_type);
}
-
-
-
+
translate_to_native_sym_flags (&nsp, g, abfd);
-
- bfd_write((PTR)&nsp,1,EXTERNAL_LIST_SIZE, abfd);
+
+ bfd_write((PTR)&nsp,1,EXTERNAL_NLIST_SIZE, abfd);
}
-
/* Now output the strings. Be sure to put string length into correct
- * byte ordering before writing it.
- */
+ byte ordering before writing it. */
{
char buffer[BYTES_IN_WORD];
PUT_WORD (abfd, stindex, (unsigned char *)buffer);
}
else {
BFD_ASSERT(0);
+ r_index = N_ABS | N_EXT;
}
}
}
else {
BFD_ASSERT(0);
+ r_index = N_ABS | N_EXT;
}
}
bfd *ignore_abfd AND
PTR afile AND
asymbol *symbol AND
- bfd_print_symbol_enum_type how)
+ bfd_print_symbol_type how)
{
FILE *file = (FILE *)afile;
switch (how) {
- case bfd_print_symbol_name_enum:
- fprintf(file,"%s", symbol->name);
+ case bfd_print_symbol_name:
+ if (symbol->name)
+ fprintf(file,"%s", symbol->name);
break;
- case bfd_print_symbol_type_enum:
+ case bfd_print_symbol_more:
fprintf(file,"%4x %2x %2x",(unsigned)(aout_symbol(symbol)->desc & 0xffff),
(unsigned)(aout_symbol(symbol)->other & 0xff),
(unsigned)(aout_symbol(symbol)->type));
break;
- case bfd_print_symbol_all_enum:
+ case bfd_print_symbol_all:
{
CONST char *section_name = symbol->section == (asection *)NULL ?
"*abs" : symbol->section->name;
bfd_print_symbol_vandf((PTR)file,symbol);
- fprintf(file," %-5s %04x %02x %02x %s",
+ fprintf(file," %-5s %04x %02x %02x",
section_name,
(unsigned)(aout_symbol(symbol)->desc & 0xffff),
(unsigned)(aout_symbol(symbol)->other & 0xff),
- (unsigned)(aout_symbol(symbol)->type & 0xff),
- symbol->name);
+ (unsigned)(aout_symbol(symbol)->type & 0xff));
+ if (symbol->name)
+ fprintf(file," %s", symbol->name);
+ }
+ break;
+ case bfd_print_symbol_nm:
+ {
+ int section_code = bfd_decode_symclass (symbol);
+
+ if (section_code == 'U')
+ fprintf(file, " ");
+ else if (symbol->section != (asection *)NULL)
+ fprintf_vma(file, symbol->value+symbol->section->vma);
+ else
+ fprintf_vma(file, symbol->value);
+ if (section_code == '?')
+ {
+ int type_code = aout_symbol(symbol)->type & 0xff;
+ char *stab_name = aout_stab_name(type_code);
+ char buf[10];
+ if (stab_name == NULL)
+ {
+ sprintf(buf, "(%d)", type_code);
+ stab_name = buf;
+ }
+ fprintf(file," - %02x %04x %5s",
+ (unsigned)(aout_symbol(symbol)->other & 0xff),
+ (unsigned)(aout_symbol(symbol)->desc & 0xffff),
+ stab_name);
+ }
+ else
+ fprintf(file," %c", section_code);
+ if (symbol->name)
+ fprintf(file," %s", symbol->name);
}
break;
}
/* Run down the file looking for the filename, function and linenumber */
asymbol **p;
static char buffer[100];
+ static char filename_buffer[200];
bfd_vma high_line_vma = ~0;
bfd_vma low_func_vma = 0;
asymbol *func = 0;
if (symbols != (asymbol **)NULL) {
for (p = symbols; *p; p++) {
aout_symbol_type *q = (aout_symbol_type *)(*p);
+ next:
switch (q->type){
case N_SO:
*filename_ptr = q->symbol.name;
+ /* Look ahead to next symbol to check if that too is an N_SO. */
+ p++;
+ if (*p == NULL)
+ break;
+ q = (aout_symbol_type *)(*p);
+ if (q->type != N_SO)
+ goto next;
+
+ /* Found a second N_SO First is directory; second is filename. */
+ if (q->symbol.name[0] == '/')
+ *filename_ptr = q->symbol.name;
+ else
+ {
+ sprintf(filename_buffer, "%.140s%.50s",
+ *filename_ptr, q->symbol.name);
+ *filename_ptr = filename_buffer;
+ }
+
if (obj_textsec(abfd) != section) {
return true;
}
buffer[sizeof(buffer)-1] = 0;
/* Have to remove : stuff */
p = strchr(buffer,':');
- if (p != NULL) { *p = NULL; }
+ if (p != NULL) { *p = '\0'; }
*functionname_ptr = buffer;
return true;
}
int
-DEFUN(NAME(aout,sizeof_headers),(ignore_abfd, execable),
- bfd *ignore_abfd AND
+DEFUN(NAME(aout,sizeof_headers),(abfd, execable),
+ bfd *abfd AND
boolean execable)
{
- return EXEC_BYTES_SIZE;
+ return adata(abfd)->exec_bytes_size;
}