version 1.7, 1998/05/11 20:34:58 |
version 1.8, 1999/05/10 16:14:07 |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
/* XXX get shared code to handle byte-order swaps */ |
|
#include "byte.c" |
|
|
#ifdef MID_MACHINE_OVERRIDE |
|
#undef MID_MACHINE |
|
#define MID_MACHINE MID_MACHINE_OVERRIDE |
|
#endif |
|
|
|
int ignore_bad_archive_entries = 1; |
int ignore_bad_archive_entries = 1; |
int print_only_external_symbols; |
int print_only_external_symbols; |
|
|
int fname(), rname(), value(); |
int fname(), rname(), value(); |
int (*sfunc)() = fname; |
int (*sfunc)() = fname; |
|
|
|
|
/* some macros for symbol type (nlist.n_type) handling */ |
/* some macros for symbol type (nlist.n_type) handling */ |
#define IS_DEBUGGER_SYMBOL(x) ((x) & N_STAB) |
#define IS_DEBUGGER_SYMBOL(x) ((x) & N_STAB) |
#define IS_EXTERNAL(x) ((x) & N_EXT) |
#define IS_EXTERNAL(x) ((x) & N_EXT) |
|
|
} |
} |
rewind(fp); |
rewind(fp); |
|
|
|
if (BAD_OBJECT(exec_head)) { |
/* this could be an archive */ |
/* this could be an archive */ |
#if (MID_MACHINE == MID_M68K) |
|
if (N_BADMAG(exec_head) || ((N_GETMID(exec_head) != MID_MACHINE) && |
|
(N_GETMID(exec_head) != MID_M68K4K))) { |
|
#else |
|
if (N_BADMAG(exec_head) || N_GETMID(exec_head) != MID_MACHINE) { |
|
#endif |
|
if (fread(magic, sizeof(magic), (size_t)1, fp) != 1 || |
if (fread(magic, sizeof(magic), (size_t)1, fp) != 1 || |
strncmp(magic, ARMAG, SARMAG)) { |
strncmp(magic, ARMAG, SARMAG)) { |
warnx("%s: not object file or archive", fname); |
warnx("%s: not object file or archive", fname); |
|
|
return(1); |
return(1); |
} |
} |
|
|
if (N_BADMAG(exec_head)) { |
if (BAD_OBJECT(exec_head)) { |
if (!ignore_bad_archive_entries) { |
if (!ignore_bad_archive_entries) { |
warnx("%s: bad format", name); |
warnx("%s: bad format", name); |
rval = 1; |
rval = 1; |
|
|
return(1); |
return(1); |
} |
} |
|
|
/* stop if this is no valid object file */ |
/* stop if this is no valid object file, or a format we don't dare |
if (N_BADMAG(head)) { |
* playing with |
|
*/ |
|
if (BAD_OBJECT(head)) { |
warnx("%s: bad format", objname); |
warnx("%s: bad format", objname); |
return(1); |
return(1); |
} |
} |
|
|
|
fix_header_order(&head); |
|
|
/* stop if the object file contains no symbol table */ |
/* stop if the object file contains no symbol table */ |
if (!head.a_syms) { |
if (!head.a_syms) { |
warnx("%s: no name list", objname); |
warnx("%s: no name list", objname); |
|
|
(void)free((char *)names); |
(void)free((char *)names); |
return(1); |
return(1); |
} |
} |
|
fix_nlists_order(names, nrawnames, N_GETMID(head)); |
|
|
/* |
/* |
* Following the symbol table comes the string table. The first |
* Following the symbol table comes the string table. The first |
|
|
(void)free((char *)names); |
(void)free((char *)names); |
return(1); |
return(1); |
} |
} |
|
stabsize = fix_long_order(stabsize, N_GETMID(head)); |
stab = emalloc((size_t)stabsize); |
stab = emalloc((size_t)stabsize); |
|
|
/* |
/* |