From 98d431073737cd92addbd2cc1cef5686cdf699c3 Mon Sep 17 00:00:00 2001 From: John Gilmore Date: Thu, 21 Nov 1991 19:52:23 +0000 Subject: [PATCH] * libaout.h (WORK_OUT_FILE_POSITIONS): One more try at this rather complicated seeming problem. Eliminate LOGICAL_ versions, just make N_XXX work by excluding the header from the text segment. * aoutx.h: Fix comments to match. --- bfd/ChangeLog | 47 ++++++++++++++++++++++++++++++++ bfd/aoutx.h | 74 +++++++++++++++++++++++++++++++++++++++++++-------- bfd/libaout.h | 8 +++--- 3 files changed, 115 insertions(+), 14 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index de1e8e69653..5d206052b5c 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,50 @@ +Thu Nov 21 11:50:49 1991 John Gilmore (gnu at cygnus.com) + + * libaout.h (WORK_OUT_FILE_POSITIONS): One more try at this + rather complicated seeming problem. Eliminate LOGICAL_ versions, + just make N_XXX work by excluding the header from the text segment. + * aoutx.h: Fix comments to match. + +Tue Nov 19 18:49:01 1991 Per Bothner (bothner at cygnus.com) + + * libaout.h (WORK_OUT_FILE_POSITIONS): Use new LOGICAL_TXTADDR, + LOGICAL_TXTOFF, LOGICAL_TXTSIZE macros to figure out numbers + for the "logical" text segment (i.e. never consider the exec + header to be part of the text segment). This change is + needed for consistency with various other parts of bfd and ld. + * aoutx.h (NAME(aout,soe_aout_object_p)): Fix comment, + and move calculation of obj_textsec(abfd)->size to libaout.h. + * bfd-in.h: Removed bogus ';'. + + * Makefile.in: Add MINIMIZE flag to select lean + or bloated target_vector. + * targets.c: Use new MINIMIZE macro, and add trad_core if needed. + * newsos3.c: Fixes to ../include/aout64.h remove need + for special N_TXTOFF macro, but require N_HEADER_IN_TEXT. + +Mon Nov 18 12:00:59 1991 Per Bothner (bothner at cygnus.com) + + * aout-target.h, aoutf1.h, newsos3.c: Make aout-target.h + handle both little and big-endian targets, with little + the default unless TARGET_IS_BIG_ENDIAN_P is defined. + * host-aout.c: Add FIXME note. + +Sun Nov 17 13:29:39 1991 Per Bothner (bothner at cygnus.com) + + * targets.c: Make the default target_vector contain + just &DEFAULT_VECTOR. This makes executables a lot smaller. + Old behavior can be gotten by defining ALL_TARGETS. + * aoutf1.h, demo64.c, i386aout.c, newsos3.c, sunos.c: + Factored out common code into new file aout-target.h. + Saves a lot of duplicate code for a.out variants. + +Fri Nov 15 13:00:43 1991 Per Bothner (bothner at cygnus.com) + + Get 'make headers' to work when configured with +subdirs. + * Makefile.in: Add $(subdir) to docdir path. + * doc/Makefile.in (protos): Add $(srcdir) prefix + to name of sed scripts. + Thu Nov 14 19:49:10 1991 Per Bothner (bothner at cygnus.com) * aoutx.h (NAME(aout,print_symbol)): Fix thinko. diff --git a/bfd/aoutx.h b/bfd/aoutx.h index 16208468fc5..9e5886e12fe 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -325,7 +325,6 @@ DEFUN(NAME(aout,some_aout_object_p),(abfd, execp, callback_to_real_object_p), obj_datasec (abfd)->size = execp->a_data; obj_bsssec (abfd)->size = execp->a_bss; - obj_textsec (abfd)->size = execp->a_text; obj_textsec (abfd)->flags = (execp->a_trsize != 0 ? (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_HAS_CONTENTS) : @@ -336,16 +335,25 @@ DEFUN(NAME(aout,some_aout_object_p),(abfd, execp, callback_to_real_object_p), 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); @@ -359,12 +367,6 @@ DEFUN(NAME(aout,some_aout_object_p),(abfd, execp, callback_to_real_object_p), 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: @@ -397,7 +399,6 @@ DEFUN(NAME(aout,some_aout_object_p),(abfd, execp, callback_to_real_object_p), header, should cope with them in this callback as well. */ #endif /* DOCUMENTATION */ - return (*callback_to_real_object_p)(abfd); } @@ -945,7 +946,7 @@ DEFUN(NAME(aout,slurp_symbol_table),(abfd), /* 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); + 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: @@ -1617,6 +1618,37 @@ DEFUN(NAME(aout,print_symbol),(ignore_abfd, afile, symbol, how), 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 = bfd_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; } } @@ -1645,6 +1677,7 @@ DEFUN(NAME(aout,find_nearest_line),(abfd, /* 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; @@ -1654,9 +1687,28 @@ DEFUN(NAME(aout,find_nearest_line),(abfd, 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; } diff --git a/bfd/libaout.h b/bfd/libaout.h index 0797bc51ce3..57d50ed563f 100644 --- a/bfd/libaout.h +++ b/bfd/libaout.h @@ -207,7 +207,7 @@ PROTO (boolean, NAME(aout,close_and_cleanup), (bfd *abfd)); PROTO (boolean, NAME(aout,find_nearest_line), (bfd *abfd, asection *section, asymbol **symbols, bfd_vma offset, CONST char **filename_ptr, CONST char **functionname_ptr, unsigned int *line_ptr)); -PROTO (int, NAME(aout,sizeof_headers), (bfd *ignore_abfd, boolean exec)); +PROTO (int, NAME(aout,sizeof_headers), (bfd *abfd, boolean exec)); PROTO (void, NAME(aout,swap_exec_header_in), (bfd *abfd, @@ -226,10 +226,12 @@ PROTO (void, NAME(aout,swap_exec_header_out),(bfd *abfd, struct internal_exec *e /* Calculate the file positions of the parts of a newly read aout header */ #define WORK_OUT_FILE_POSITIONS(abfd, execp) \ + obj_textsec (abfd)->size = N_TXTSIZE(*execp); \ + \ /* 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); \ -- 2.30.2