Index: src/platform-macos.cc |
diff --git a/src/platform-macos.cc b/src/platform-macos.cc |
index 880931e048b3a9a8a417b6441fbadea6995d75cc..5e444b6ce465f526a080366faf64ef257fe02fde 100644 |
--- a/src/platform-macos.cc |
+++ b/src/platform-macos.cc |
@@ -32,6 +32,8 @@ |
#include <unistd.h> |
#include <sys/mman.h> |
#include <mach/mach_init.h> |
+#include <mach-o/dyld.h> |
+#include <mach-o/getsect.h> |
#include <AvailabilityMacros.h> |
@@ -205,7 +207,18 @@ PosixMemoryMappedFile::~PosixMemoryMappedFile() { |
void OS::LogSharedLibraryAddresses() { |
- // TODO(1233579): Implement. |
+ unsigned int images_count = _dyld_image_count(); |
+ for (unsigned int i = 0; i < images_count; ++i) { |
+ const mach_header *header = _dyld_get_image_header(i); |
iposva
2009/07/13 20:18:21
The correct style is "mach_header* header".
Mikhail Naganov
2009/07/14 05:00:42
Done.
|
+ if (header == NULL) continue; |
+ unsigned int size; |
+ char *code_ptr; |
iposva
2009/07/13 20:18:21
The correct style is "char* code_ptr".
I also ass
Mikhail Naganov
2009/07/14 05:00:42
No, it's just a lack of attention. Fixed, thanks!
|
+ code_ptr = getsectdatafromheader(header, SEG_TEXT, SECT_TEXT, &size); |
+ if (code_ptr == NULL) continue; |
+ const uintptr_t slide = _dyld_get_image_vmaddr_slide(i); |
+ const uintptr_t start = reinterpret_cast<uintptr_t>(code_ptr) + slide; |
+ LOG(SharedLibraryEvent(_dyld_get_image_name(i), start, start + size)); |
+ } |
} |