-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathsmol.cc
More file actions
30 lines (25 loc) · 743 Bytes
/
smol.cc
File metadata and controls
30 lines (25 loc) · 743 Bytes
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
#include "libpstack/proc.h"
#include "libpstack/arch.h"
#include <unistd.h>
extern "C" {
int foobar() {
return 42;
}
}
int
main()
{
extern int verbose;
verbose = 0;
PstackOptions options;
Dwarf::ImageCache cache;
getppid();
std::shared_ptr<Process> p = std::make_shared<SelfProcess>(nullptr, options, cache);
p->load();
getppid();
pstack::ProcessLocation li(*p, Elf::Addr(foobar));
auto [ lib, addr, sym ] = p->resolveSymbolDetail("foobar", true);
std::cout << "found foobar in " << *lib->io << "@" << addr << ", value=" << sym.st_value << ", size=" << sym.st_size << std::endl;
std::cout << "match? " << (Elf::Addr(foobar) == addr + sym.st_value) << std::endl;
return foobar();
}