blob: 6f16639f13b20b5b170e1db5faf0eeb843d80b50 (
plain) (
blame)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#include "elf_parser.h"
#include <cstddef>
#include <cstdio>
#include <elf.h>
#include "elf_parser/libtest-32.h"
#include "elf_parser/libtest-64.h"
void dump_dynsyms(const unsigned char* bytes, size_t len) {
auto elf = elf::parse(bytes, len);
elf->dynsyms([](const char* name, char type, char bind) { // NOLINT
const char* bind_str = "<unnown>";
switch (bind) {
case STB_GLOBAL:
bind_str = "GLOBAL";
break;
case STB_LOCAL:
bind_str = "LOCAL";
break;
case STB_WEAK:
bind_str = "WEAK";
break;
default:
break;
}
const char* type_str = "<unknown>";
switch (type) {
case STT_NOTYPE:
type_str = "NOTYPE";
break;
case STT_FUNC:
type_str = "FUNC";
break;
case STT_OBJECT:
type_str = "OBJECT";
break;
case STT_SECTION:
type_str = "SECTION";
break;
case STT_FILE:
type_str = "FILE";
break;
default:
break;
}
printf("syms type: %10s bind: %10s name: %s\n", type_str, bind_str, name);
return true;
});
}
int main() {
dump_dynsyms(libtest_32_so, libtest_32_so_len);
dump_dynsyms(libtest_64_so, libtest_64_so_len);
}
|