aboutsummaryrefslogtreecommitdiff
path: root/src/libmach/elfnm.c
blob: 9e6d1eac0ed0f14293567084831f6ec5f9ef4e23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <u.h>
#include <libc.h>
#include <mach.h>
#include <elf.h>

void
usage(void)
{
	fprint(2, "usage: elfnm file...\n");
	exits("usage");
}

void
main(int argc, char **argv)
{
	ElfSym esym;
	Fhdr *fp;
	int i, j;

	ARGBEGIN{
	default:
		usage();
	}ARGEND

	if(argc == 0)
		usage();

	for(i=0; i<argc; i++){
		if((fp = crackhdr(argv[i], OREAD)) == nil){
			fprint(2, "%s: %r\n", argv[i]);
			continue;
		}
		for(j=0; elfsym(fp->elf, j, &esym)>=0; j++)
			print("%s 0x%lux\n", esym.name, esym.value);
		uncrackhdr(fp);
	}
	exits(0);
}