static char sccsid
[] = "@(#)nm.c 4.4 %G%";
* nm - print name list; VAX string table version
#define SELECT archive ? archdr.ar_name : *xargv
int aflg
, gflg
, nflg
, oflg
, pflg
, uflg
;
char mag_armag
[SARMAG
+1];
if (--argc
>0 && argv
[1][0]=='-' && argv
[1][1]!=0) {
while (*++*argv
) switch (**argv
) {
fprintf(stderr
, "nm: invalid argument -%c\n",
fread((char *)&mag_un
, 1, sizeof(mag_un
), fi
);
if (mag_un
.mag_exp
.a_magic
== OARMAG
) {
if (strncmp(mag_un
.mag_armag
, ARMAG
, SARMAG
)==0)
else if (N_BADMAG(mag_un
.mag_exp
)) {
printf("\n%s:\n", *xargv
);
struct nlist
*symp
= NULL
;
fread((char *)&mag_un
.mag_exp
, 1, sizeof(struct exec
), fi
);
if (N_BADMAG(mag_un
.mag_exp
))
o
= N_SYMOFF(mag_un
.mag_exp
) - sizeof (struct exec
);
n
= mag_un
.mag_exp
.a_syms
/ sizeof(struct nlist
);
error(0, "no name list");
if (N_STROFF(mag_un
.mag_exp
) + sizeof (off_t
) >
(archive
? off
: stb
.st_size
))
error(1, "old format .o (no string table) or truncated file");
fread((char *)&sym
, 1, sizeof(sym
), fi
);
if (gflg
&& (sym
.n_type
&N_EXT
)==0)
if ((sym
.n_type
&N_STAB
) && (!aflg
||gflg
||uflg
))
malloc(sizeof(struct nlist
));
(i
+1)*sizeof(struct nlist
));
error(1, "out of memory");
if (archive
&& ftell(fi
)+sizeof(off_t
) >= off
) {
error(0, "no string table (old format .o?)");
if (fread((char *)&strsiz
,sizeof(strsiz
),1,fi
) != 1) {
error(0, "no string table (old format .o?)");
strp
= (char *)malloc(strsiz
);
error(1, "ran out of memory");
if (fread(strp
+sizeof(strsiz
),strsiz
-sizeof(strsiz
),1,fi
) != 1)
error(1, "error reading string table");
symp
[j
].n_un
.n_strx
+ strp
;
symp
[j
].n_un
.n_name
= "";
qsort(symp
, i
, sizeof(struct nlist
), compare
);
if ((archive
|| narg
>1) && oflg
==0)
printf("\n%s:\n", SELECT
);
free((char *)symp
), symp
= 0;
free((char *)strp
), strp
= 0;
} while(archive
&& nextel(fi
));
register struct nlist
*symp
;
for (n
=0; n
<nsyms
; n
++) {
printf("%08x - %02x %04x %5.5s %s\n",
symp
[n
].n_other
& 0xff, symp
[n
].n_desc
& 0xffff,
stab(symp
[n
].n_type
& 0xff),
if (symp
[n
].n_type
&N_EXT
)
printf(N_FORMAT
, symp
[n
].n_value
);
printf("%s\n", symp
[n
].n_un
.n_name
);
if (p1
->n_value
> p2
->n_value
)
if (p1
->n_value
< p2
->n_value
)
return (rflg
* strcmp(p1
->n_un
.n_name
, p2
->n_un
.n_name
));
r
= fread((char *)&archdr
, 1, sizeof(struct ar_hdr
), af
);
if (r
!= sizeof(struct ar_hdr
))
for (cp
= archdr
.ar_name
; cp
< &archdr
.ar_name
[sizeof(archdr
.ar_name
)]; cp
++)
arsize
= atol(archdr
.ar_size
);
off
= ftell(af
) + arsize
; /* beginning of next element */
fprintf(stderr
, "nm: %s:", *xargv
);
fprintf(stderr
, "(%s)", archdr
.ar_name
);
fprintf(stderr
, "%s\n", s
);
register struct stabnames
*sp
;
for (sp
= stabnames
; sp
->st_name
; sp
++)
sprintf(prbuf
, "%02x", val
);