Skip to content

Commit

Permalink
[symbols] Fix ASLR issue with asm annotations, also fix issue with ex…
Browse files Browse the repository at this point in the history
…ecutable without ASLR
  • Loading branch information
svalat committed Nov 14, 2020
1 parent 1803f66 commit da7fb26
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 5 additions & 2 deletions extern-deps/from-malt-v2/SymbolRegistry.cpp
Expand Up @@ -110,7 +110,7 @@ void convertToJson(htopml::JsonState& json, const SymbolRegistry& value)
json.openStruct();

// json.printField("entries",value.nameMap);

json.printField("lowAddrMap", value.libBaseAddrMap);
json.printField("map",value.procMap);
json.printField("strings",value.strings);
json.printField("instr",value.callSiteMap);
Expand Down Expand Up @@ -301,7 +301,10 @@ void SymbolRegistry::solveNames(LinuxProcMapEntry * procMapEntry)
#endif

hasEntries = true;
addr2lineCmd << ' ' << (void*)((size_t)it->first - (size_t)elf2AddrOffset);
if (elf2AddrOffset == 0x00400000)
addr2lineCmd << ' ' << (void*)((size_t)it->first);
else
addr2lineCmd << ' ' << (void*)((size_t)it->first - (size_t)elf2AddrOffset);
lst.push_back(&it->second);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/ProcessTracker.cpp
Expand Up @@ -397,7 +397,7 @@ void convertToJson(htopml::JsonState& json, const ProcessTracker& value)
{
json.openStruct();
json.openFieldStruct("infos");
json.printField("formatVersion",1);
json.printField("formatVersion",2);
json.printField("tool","numaprof");
if (getGlobalOptions().infoHidden == false)
{
Expand Down
8 changes: 6 additions & 2 deletions src/webview/ProfileHandler.py
Expand Up @@ -23,6 +23,9 @@ def __init__(self,filepath):
def load(self):
json_data=open(self.filepath).read()
self.data = json.loads(json_data)
version = self.data["infos"]["formatVersion"]
if version != 2:
raise Exception("Invalid format version, as {version} expected 2 !")
self.prepare()

def prepare(self):
Expand Down Expand Up @@ -327,9 +330,10 @@ def getSoRelativeAddr(self,addr):
for sym in self.data["symbols"]["map"]:
lower = int(sym["lower"][2:],16)
upper = int(sym["upper"][2:],16)
if addrInt >= lower and addrInt < upper and ".so" in sym["file"]:
if addrInt >= lower and addrInt < upper and (".so" in sym["file"] or lower != int('00400000',16)):
baseAddr = int(self.data["symbols"]["lowAddrMap"][sym["file"]])
#print "Replace in %s : %s => 0x%x"%(sym["file"],addr,(addrInt - lower))
return "%x" % (addrInt - lower)
return "%x" % (addrInt - baseAddr)
#print "Addr not found in memory map, keep addr : %s"%addr
return addr[2:]

Expand Down

0 comments on commit da7fb26

Please sign in to comment.