summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2018-07-11 20:46:46 -0400
committerPeter LaFosse <peter@vector35.com>2018-07-11 20:46:46 -0400
commitc6662cbce926c304eef3e4c80429fb66e38ca252 (patch)
tree5abd9f9c20aebe125fd432a90db13b6afa5383c1
parentb35c7de12f675237655565e26a25c290e04e7dab (diff)
Add APIs for getting the underlying symbol from a relocation
-rw-r--r--binaryninjaapi.h1
-rw-r--r--binaryninjacore.h2
-rw-r--r--binaryview.cpp9
3 files changed, 11 insertions, 1 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 510b392a..d8c3d468 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -1394,6 +1394,7 @@ namespace BinaryNinja
Architecture* GetArchitecture() const;
uint64_t GetTarget() const;
uint64_t GetReloc() const;
+ Ref<Symbol> GetSymbol() const;
};
diff --git a/binaryninjacore.h b/binaryninjacore.h
index df378dc4..4eb6d3f7 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -3525,7 +3525,7 @@ extern "C"
BINARYNINJACOREAPI BNArchitecture* BNRelocationGetArchitecture(BNRelocation* reloc);
BINARYNINJACOREAPI uint64_t BNRelocationGetTarget(BNRelocation* reloc);
BINARYNINJACOREAPI uint64_t BNRelocationGetReloc(BNRelocation* reloc);
-
+ BINARYNINJACOREAPI BNSymbol* BNRelocationGetSymbol(BNRelocation* reloc);
// Segment object methods
BINARYNINJACOREAPI BNSegment* BNCreateSegment(uint64_t start, uint64_t length, uint64_t dataOffset, uint64_t dataLength, uint32_t flags,
bool autoDefined);
diff --git a/binaryview.cpp b/binaryview.cpp
index 7aa2118f..6e5c3b14 100644
--- a/binaryview.cpp
+++ b/binaryview.cpp
@@ -2230,6 +2230,15 @@ uint64_t Relocation::GetReloc() const
}
+Ref<Symbol> Relocation::GetSymbol() const
+{
+ BNSymbol* sym = BNRelocationGetSymbol(m_object);
+ if (!sym)
+ return nullptr;
+ return new Symbol(sym);
+}
+
+
BinaryData::BinaryData(FileMetadata* file): BinaryView(BNCreateBinaryDataView(file->GetObject()))
{
}