Skip to content

Commit 35c3ffb

Browse files
committed
Add symbols.r2.js script for xcrun integration ##bin
1 parent 0d6914d commit 35c3ffb

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

scripts/symbols.r2.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* parser symbols files from xcode */
2+
const mapFileName = "r2.map";
3+
4+
function filterFlag(symName) {
5+
return "sym." + symName.replace(/[^a-zA-Z0-9]/g, '_');
6+
}
7+
8+
function loadFlagsFromSymbols(fileName) {
9+
const script = [];
10+
const lines = r2.syscmds("xcrun symbols " + fileName).split("\n");
11+
for (const line of lines) {
12+
if (line.indexOf("0x") !== -1) {
13+
if (line.indexOf("FUNC") !== -1) {
14+
const adr = line.indexOf ("(");
15+
const beg = line.indexOf (")");
16+
const end = line.indexOf ("[");
17+
if (beg !== -1 && end !== -1 && adr !== -1) {
18+
const addr = line.substr (0, adr).trim();
19+
const name = line.substr (beg, end - beg).trim();
20+
script.push("'f " + name + " = " + addr);
21+
}
22+
} else {
23+
const adr = line.indexOf ("(");
24+
const beg = line.indexOf (")");
25+
if (beg !== -1 && adr !== -1) {
26+
const addr = line.substr (0, adr).trim();
27+
const file= line.substr (adr).trim();
28+
script.push("'CL " + addr + " = " + file);
29+
}
30+
}
31+
}
32+
}
33+
return script;
34+
}
35+
36+
loadFlagsFromSymbols(mapFileName).map(r2.cmd);
37+

0 commit comments

Comments
 (0)