summaryrefslogtreecommitdiff
path: root/view/sharedcache/core/MachO.cpp
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-04-07 22:28:32 -0400
committerMason Reed <mason@vector35.com>2025-04-07 22:28:32 -0400
commitf902f22843146fb04dddadc5765f6582e3096a18 (patch)
treeeb14746f6d97a8a033eade7a235a24d06d916e9c /view/sharedcache/core/MachO.cpp
parent10996dd1e571f674a6b4ff04c89f91ee0fc1ecd8 (diff)
[SharedCache] Include segment in image section name
This removes some section name collisions where a section name is in two separate image segments. See https://github.com/Vector35/binaryninja-api/pull/6454 for more information. Co-Authored-By: WeiN76LQh <WeiN76LQh@github.com>
Diffstat (limited to 'view/sharedcache/core/MachO.cpp')
-rw-r--r--view/sharedcache/core/MachO.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/view/sharedcache/core/MachO.cpp b/view/sharedcache/core/MachO.cpp
index 0b296af1..e1ec9229 100644
--- a/view/sharedcache/core/MachO.cpp
+++ b/view/sharedcache/core/MachO.cpp
@@ -435,7 +435,18 @@ std::optional<SharedCacheMachOHeader> SharedCacheMachOHeader::ParseHeaderForAddr
char sectionName[17];
memcpy(sectionName, section.sectname, sizeof(section.sectname));
sectionName[16] = 0;
- header.sectionNames.push_back(header.identifierPrefix + "::" + sectionName);
+
+ char segmentName[sizeof(section.segname)+1];
+ memcpy(segmentName, section.segname, sizeof(section.segname));
+ segmentName[sizeof(segmentName)-1] = 0;
+
+ // Section names used to be image name and section only but some images have duplicate section names
+ // so we now also use the segment name, this also is more close to what is seen with LLVM.
+ // Justification: https://github.com/Vector35/binaryninja-api/pull/6454#issuecomment-2777465476
+ if (header.identifierPrefix.empty())
+ header.sectionNames.push_back(fmt::format("{}.{}", segmentName, sectionName));
+ else
+ header.sectionNames.push_back(fmt::format("{}::{}.{}", header.identifierPrefix, segmentName, sectionName));
}
}
catch (ReadException&)