Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Unified Diff: util/mac/mach_o_image_segment_reader.cc

Issue 539263003: Add MachOImageSymbolTableReader and hook it up to MachOImageReader (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Address review feedback Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « util/mac/mach_o_image_segment_reader.h ('k') | util/mac/mach_o_image_symbol_table_reader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/mac/mach_o_image_segment_reader.cc
diff --git a/util/mac/mach_o_image_segment_reader.cc b/util/mac/mach_o_image_segment_reader.cc
index ceb9a90d0ad10f574c5cd9eea3d12d0706dc5daf..0625f39287b57e2e6ea8dca0f78be61a09af2e98 100644
--- a/util/mac/mach_o_image_segment_reader.cc
+++ b/util/mac/mach_o_image_segment_reader.cc
@@ -33,7 +33,12 @@ std::string SizeLimitedCString(const char* c_string, size_t max_length) {
} // namespace
MachOImageSegmentReader::MachOImageSegmentReader()
- : segment_command_(), sections_(), section_map_(), initialized_() {
+ : segment_command_(),
+ sections_(),
+ section_map_(),
+ slide_(0),
+ initialized_(),
+ initialized_slide_() {
}
MachOImageSegmentReader::~MachOImageSegmentReader() {
@@ -175,8 +180,21 @@ std::string MachOImageSegmentReader::Name() const {
return NameInternal();
}
+mach_vm_address_t MachOImageSegmentReader::Address() const {
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_);
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_slide_);
+ return vmaddr() + (SegmentSlides() ? slide_ : 0);
+}
+
+mach_vm_size_t MachOImageSegmentReader::Size() const {
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_);
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_slide_);
+ return vmsize() + (SegmentSlides() ? 0 : slide_);
+}
+
const process_types::section* MachOImageSegmentReader::GetSectionByName(
- const std::string& section_name) const {
+ const std::string& section_name,
+ mach_vm_address_t* address) const {
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
const auto& iterator = section_map_.find(section_name);
@@ -184,14 +202,23 @@ const process_types::section* MachOImageSegmentReader::GetSectionByName(
return NULL;
}
- return &sections_[iterator->second];
+ return GetSectionAtIndex(iterator->second, address);
}
const process_types::section* MachOImageSegmentReader::GetSectionAtIndex(
- size_t index) const {
+ size_t index,
+ mach_vm_address_t* address) const {
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
CHECK_LT(index, sections_.size());
- return &sections_[index];
+
+ const process_types::section* section = &sections_[index];
+
+ if (address) {
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_slide_);
+ *address = section->addr + (SegmentSlides() ? slide_ : 0);
+ }
+
+ return section;
}
bool MachOImageSegmentReader::SegmentSlides() const {
@@ -238,4 +265,11 @@ std::string MachOImageSegmentReader::NameInternal() const {
return SegmentNameString(segment_command_.segname);
}
+void MachOImageSegmentReader::SetSlide(mach_vm_size_t slide) {
+ INITIALIZATION_STATE_DCHECK_VALID(initialized_);
+ INITIALIZATION_STATE_SET_INITIALIZING(initialized_slide_);
+ slide_ = slide;
+ INITIALIZATION_STATE_SET_VALID(initialized_slide_);
+}
+
} // namespace crashpad
« no previous file with comments | « util/mac/mach_o_image_segment_reader.h ('k') | util/mac/mach_o_image_symbol_table_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698