-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathlink_map.cc
More file actions
28 lines (25 loc) · 855 Bytes
/
link_map.cc
File metadata and controls
28 lines (25 loc) · 855 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
#include <stdlib.h>
#include <fstream>
#include <regex>
#include "fuzz.h"
void load_link_map(char* map_path, char* obj_regex, size_t base) {
std::regex rx(obj_regex);
// Need to make sure __llvm_prf_cnts is in the linkmap. Then read the first
// one that is nonzero - which should have the size of the counters map and
// the entire region
std::ifstream infile(map_path);
std::string line;
while (std::getline(infile, line))
{
std::smatch match;
if(std::regex_search(line, match, rx)){
/* printf("MATCH: %s\n", line.c_str()); */
std::istringstream iss(line);
uint64_t start, len;
std::string ignore;
char c;
if (!(iss >> std::hex >> ignore >> start >> len)) { break; }
add_pc_range(base+start, len);
}
}
}