Skip to content

Commit d4ad3fd

Browse files
committed
Apply relocations manually in DWARF parsing.
Hopefully addresses #7480.
1 parent 06ee9fe commit d4ad3fd

File tree

7 files changed

+298
-29
lines changed

7 files changed

+298
-29
lines changed

Cargo.lock

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

binaryninjaapi.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21603,6 +21603,16 @@ namespace BinaryNinja::Collaboration
2160321603
*/
2160421604
std::vector<std::pair<std::string, std::string>> SearchUsers(const std::string& prefix);
2160521605

21606+
struct FileSearchMatch
21607+
{
21608+
std::string projectId;
21609+
std::string projectName;
21610+
std::string fileId;
21611+
std::string fileName;
21612+
};
21613+
21614+
std::vector<FileSearchMatch> FindFiles(const std::string& name);
21615+
2160621616

2160721617
/*!
2160821618
Pull list of users from the remote. Necessary before calling GetUsers()
@@ -22487,4 +22497,3 @@ template<> struct fmt::formatter<BinaryNinja::Type>
2248722497
return it;
2248822498
}
2248922499
};
22490-

binaryninjacore.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,14 @@ extern "C"
312312
typedef struct BNIndirectBranchInfo BNIndirectBranchInfo;
313313
typedef struct BNArchitectureAndAddress BNArchitectureAndAddress;
314314

315+
typedef struct BNRemoteFileSearchMatch
316+
{
317+
char* projectId;
318+
char* projectName;
319+
char* fileId;
320+
char* fileName;
321+
} BNRemoteFileSearchMatch;
322+
315323
typedef bool(*BNProgressFunction)(void*, size_t, size_t);
316324

317325
//! Console log levels
@@ -8240,6 +8248,8 @@ extern "C"
82408248
BINARYNINJACOREAPI BNCollaborationUser* BNRemoteGetUserByUsername(BNRemote* remote, const char* username);
82418249
BINARYNINJACOREAPI BNCollaborationUser* BNRemoteGetCurrentUser(BNRemote* remote);
82428250
BINARYNINJACOREAPI bool BNRemoteSearchUsers(BNRemote* remote, const char* prefix, char*** userIds, char*** usernames, size_t* count);
8251+
BINARYNINJACOREAPI BNRemoteFileSearchMatch* BNRemoteFindFiles(BNRemote* remote, const char* name, size_t* count);
8252+
BINARYNINJACOREAPI void BNFreeRemoteFileSearchMatchList(BNRemoteFileSearchMatch* matches, size_t count);
82438253
BINARYNINJACOREAPI bool BNRemotePullUsers(BNRemote* remote, BNProgressFunction progress, void* progressContext);
82448254
BINARYNINJACOREAPI BNCollaborationUser* BNRemoteCreateUser(BNRemote* remote, const char* username, const char* email, bool isActive, const char* password, const uint64_t* groupIds, size_t groupIdCount, const uint64_t* userPermissionIds, size_t userPermissionIdCount);
82458255
BINARYNINJACOREAPI bool BNRemotePushUser(BNRemote* remote, BNCollaborationUser* user, const char** extraFieldKeys, const char** extraFieldValues, size_t extraFieldCount);

collaboration.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,34 @@ std::vector<std::pair<std::string, std::string>> Remote::SearchUsers(const std::
977977
}
978978

979979

980+
std::vector<Remote::FileSearchMatch> Remote::FindFiles(const std::string& name)
981+
{
982+
size_t count = 0;
983+
BNRemoteFileSearchMatch* matches = BNRemoteFindFiles(m_object, name.c_str(), &count);
984+
std::vector<FileSearchMatch> results;
985+
if (!matches)
986+
return results;
987+
988+
results.reserve(count);
989+
for (size_t i = 0; i < count; i++)
990+
{
991+
FileSearchMatch match;
992+
if (matches[i].projectId)
993+
match.projectId = matches[i].projectId;
994+
if (matches[i].projectName)
995+
match.projectName = matches[i].projectName;
996+
if (matches[i].fileId)
997+
match.fileId = matches[i].fileId;
998+
if (matches[i].fileName)
999+
match.fileName = matches[i].fileName;
1000+
results.push_back(std::move(match));
1001+
}
1002+
1003+
BNFreeRemoteFileSearchMatchList(matches, count);
1004+
return results;
1005+
}
1006+
1007+
9801008
void Remote::PullUsers(ProgressFunction progress)
9811009
{
9821010
ProgressContext pctxt;
@@ -2677,4 +2705,3 @@ CollabUndoEntry::CollabUndoEntry(BNCollaborationUndoEntry* entry)
26772705
{
26782706
m_object = entry;
26792707
}
2680-

plugins/dwarf/dwarf_import/src/helpers.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ pub(crate) fn get_name<R: ReaderType>(
186186
entry: &DebuggingInformationEntry<R>,
187187
debug_info_builder_context: &DebugInfoBuilderContext<R>,
188188
) -> Option<String> {
189+
if entry.offset().0 == 0x2a {
190+
println!("name is {:?}", entry.attr_value_raw(constants::DW_AT_name));
191+
}
189192
match resolve_specification(dwarf, unit, entry, debug_info_builder_context) {
190193
DieReference::UnitAndOffset((dwarf, entry_unit, entry_offset)) => {
191194
let resolved_entry = match entry_unit.entry(entry_offset) {

plugins/dwarf/shared/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ binaryninjacore-sys.workspace = true
1111
gimli = "0.31"
1212
zstd = "0.13.2"
1313
thiserror = "2.0"
14+
object = "0.36"

0 commit comments

Comments
 (0)