003 File Manager
Current Path:
/usr/src/contrib/llvm-project/compiler-rt/lib/sanitizer_common
usr
/
src
/
contrib
/
llvm-project
/
compiler-rt
/
lib
/
sanitizer_common
/
📁
..
📄
sancov_flags.cpp
(1.64 KB)
📄
sancov_flags.h
(1.08 KB)
📄
sancov_flags.inc
(777 B)
📄
sanitizer_addrhashmap.h
(9.19 KB)
📄
sanitizer_allocator.cpp
(8.73 KB)
📄
sanitizer_allocator.h
(2.69 KB)
📄
sanitizer_allocator_bytemap.h
(3.12 KB)
📄
sanitizer_allocator_checks.cpp
(686 B)
📄
sanitizer_allocator_checks.h
(2.67 KB)
📄
sanitizer_allocator_combined.h
(6.29 KB)
📄
sanitizer_allocator_interface.h
(1.83 KB)
📄
sanitizer_allocator_internal.h
(2.03 KB)
📄
sanitizer_allocator_local_cache.h
(8.95 KB)
📄
sanitizer_allocator_primary32.h
(12.64 KB)
📄
sanitizer_allocator_primary64.h
(32.71 KB)
📄
sanitizer_allocator_report.cpp
(4.68 KB)
📄
sanitizer_allocator_report.h
(1.72 KB)
📄
sanitizer_allocator_secondary.h
(10.78 KB)
📄
sanitizer_allocator_size_class_map.h
(10.12 KB)
📄
sanitizer_allocator_stats.h
(2.76 KB)
📄
sanitizer_asm.h
(2.57 KB)
📄
sanitizer_atomic.h
(1.97 KB)
📄
sanitizer_atomic_clang.h
(3.42 KB)
📄
sanitizer_atomic_clang_mips.h
(3.77 KB)
📄
sanitizer_atomic_clang_other.h
(3.02 KB)
📄
sanitizer_atomic_clang_x86.h
(3.77 KB)
📄
sanitizer_atomic_msvc.h
(8.53 KB)
📄
sanitizer_bitvector.h
(9.43 KB)
📄
sanitizer_bvgraph.h
(4.62 KB)
📄
sanitizer_common.cpp
(10.13 KB)
📄
sanitizer_common.h
(30.64 KB)
📄
sanitizer_common_interceptors.inc
(348.66 KB)
📄
sanitizer_common_interceptors_format.inc
(16.84 KB)
📄
sanitizer_common_interceptors_ioctl.inc
(22.13 KB)
📄
sanitizer_common_interceptors_netbsd_compat.inc
(4.07 KB)
📄
sanitizer_common_interceptors_vfork_aarch64.inc.S
(1.23 KB)
📄
sanitizer_common_interceptors_vfork_arm.inc.S
(1.24 KB)
📄
sanitizer_common_interceptors_vfork_i386.inc.S
(1.66 KB)
📄
sanitizer_common_interceptors_vfork_x86_64.inc.S
(1.03 KB)
📄
sanitizer_common_interface.inc
(2.05 KB)
📄
sanitizer_common_interface_posix.inc
(732 B)
📄
sanitizer_common_libcdep.cpp
(5.4 KB)
📄
sanitizer_common_nolibc.cpp
(1.12 KB)
📄
sanitizer_common_syscalls.inc
(85 KB)
📄
sanitizer_coverage_fuchsia.cpp
(10.1 KB)
📄
sanitizer_coverage_interface.inc
(1.73 KB)
📄
sanitizer_coverage_libcdep_new.cpp
(7.39 KB)
📄
sanitizer_coverage_win_dll_thunk.cpp
(1.03 KB)
📄
sanitizer_coverage_win_dynamic_runtime_thunk.cpp
(1.16 KB)
📄
sanitizer_coverage_win_sections.cpp
(3.36 KB)
📄
sanitizer_coverage_win_weak_interception.cpp
(1.17 KB)
📄
sanitizer_dbghelp.h
(1.44 KB)
📄
sanitizer_deadlock_detector.h
(13.28 KB)
📄
sanitizer_deadlock_detector1.cpp
(5.6 KB)
📄
sanitizer_deadlock_detector2.cpp
(10.84 KB)
📄
sanitizer_deadlock_detector_interface.h
(2.66 KB)
📄
sanitizer_errno.cpp
(1.09 KB)
📄
sanitizer_errno.h
(1.3 KB)
📄
sanitizer_errno_codes.h
(1.1 KB)
📄
sanitizer_file.cpp
(6.24 KB)
📄
sanitizer_file.h
(3.67 KB)
📄
sanitizer_flag_parser.cpp
(5.55 KB)
📄
sanitizer_flag_parser.h
(5.71 KB)
📄
sanitizer_flags.cpp
(3.95 KB)
📄
sanitizer_flags.h
(2.13 KB)
📄
sanitizer_flags.inc
(12.73 KB)
📄
sanitizer_freebsd.h
(3.31 KB)
📄
sanitizer_fuchsia.cpp
(16.58 KB)
📄
sanitizer_fuchsia.h
(1.03 KB)
📄
sanitizer_getauxval.h
(1.73 KB)
📄
sanitizer_glibc_version.h
(748 B)
📄
sanitizer_hash.h
(1.04 KB)
📄
sanitizer_interceptors_ioctl_netbsd.inc
(68.81 KB)
📄
sanitizer_interface_internal.h
(5.28 KB)
📄
sanitizer_internal_defs.h
(14.28 KB)
📄
sanitizer_lfstack.h
(2.08 KB)
📄
sanitizer_libc.cpp
(7.21 KB)
📄
sanitizer_libc.h
(3.23 KB)
📄
sanitizer_libignore.cpp
(4.24 KB)
📄
sanitizer_libignore.h
(3.5 KB)
📄
sanitizer_linux.cpp
(71.58 KB)
📄
sanitizer_linux.h
(5.47 KB)
📄
sanitizer_linux_libcdep.cpp
(25.67 KB)
📄
sanitizer_linux_s390.cpp
(6.91 KB)
📄
sanitizer_list.h
(3.81 KB)
📄
sanitizer_local_address_space_view.h
(3.67 KB)
📄
sanitizer_mac.cpp
(38.67 KB)
📄
sanitizer_mac.h
(2.49 KB)
📄
sanitizer_mac_libcdep.cpp
(968 B)
📄
sanitizer_malloc_mac.inc
(13.06 KB)
📄
sanitizer_mutex.h
(5.17 KB)
📄
sanitizer_netbsd.cpp
(9.95 KB)
📄
sanitizer_openbsd.cpp
(3.17 KB)
📄
sanitizer_persistent_allocator.cpp
(687 B)
📄
sanitizer_persistent_allocator.h
(2.31 KB)
📄
sanitizer_placement_new.h
(885 B)
📄
sanitizer_platform.h
(10.11 KB)
📄
sanitizer_platform_interceptors.h
(24.93 KB)
📄
sanitizer_platform_limits_freebsd.cpp
(19.79 KB)
📄
sanitizer_platform_limits_freebsd.h
(18.41 KB)
📄
sanitizer_platform_limits_linux.cpp
(3.32 KB)
📄
sanitizer_platform_limits_netbsd.cpp
(109.73 KB)
📄
sanitizer_platform_limits_netbsd.h
(81.54 KB)
📄
sanitizer_platform_limits_openbsd.cpp
(8.69 KB)
📄
sanitizer_platform_limits_openbsd.h
(8.68 KB)
📄
sanitizer_platform_limits_posix.cpp
(48.89 KB)
📄
sanitizer_platform_limits_posix.h
(40.65 KB)
📄
sanitizer_platform_limits_solaris.cpp
(11.93 KB)
📄
sanitizer_platform_limits_solaris.h
(12.26 KB)
📄
sanitizer_posix.cpp
(11.93 KB)
📄
sanitizer_posix.h
(5.14 KB)
📄
sanitizer_posix_libcdep.cpp
(16.21 KB)
📄
sanitizer_printf.cpp
(12.07 KB)
📄
sanitizer_procmaps.h
(2.93 KB)
📄
sanitizer_procmaps_bsd.cpp
(3.81 KB)
📄
sanitizer_procmaps_common.cpp
(5.27 KB)
📄
sanitizer_procmaps_fuchsia.cpp
(2.51 KB)
📄
sanitizer_procmaps_linux.cpp
(2.9 KB)
📄
sanitizer_procmaps_mac.cpp
(13.7 KB)
📄
sanitizer_procmaps_solaris.cpp
(2.18 KB)
📄
sanitizer_ptrauth.h
(720 B)
📄
sanitizer_quarantine.h
(9.57 KB)
📄
sanitizer_report_decorator.h
(1.89 KB)
📄
sanitizer_ring_buffer.h
(4.7 KB)
📄
sanitizer_rtems.cpp
(7.61 KB)
📄
sanitizer_rtems.h
(772 B)
📄
sanitizer_signal_interceptors.inc
(2.89 KB)
📄
sanitizer_solaris.cpp
(6.6 KB)
📄
sanitizer_stackdepot.cpp
(4.54 KB)
📄
sanitizer_stackdepot.h
(2.13 KB)
📄
sanitizer_stackdepotbase.h
(5.58 KB)
📄
sanitizer_stacktrace.cpp
(4.58 KB)
📄
sanitizer_stacktrace.h
(5.65 KB)
📄
sanitizer_stacktrace_libcdep.cpp
(5.54 KB)
📄
sanitizer_stacktrace_printer.cpp
(9.08 KB)
📄
sanitizer_stacktrace_printer.h
(3.08 KB)
📄
sanitizer_stacktrace_sparc.cpp
(3.05 KB)
📄
sanitizer_stoptheworld.h
(2.34 KB)
📄
sanitizer_stoptheworld_fuchsia.cpp
(1.28 KB)
📄
sanitizer_stoptheworld_linux_libcdep.cpp
(20.8 KB)
📄
sanitizer_stoptheworld_mac.cpp
(5.29 KB)
📄
sanitizer_stoptheworld_netbsd_libcdep.cpp
(11.02 KB)
📄
sanitizer_suppressions.cpp
(5.67 KB)
📄
sanitizer_suppressions.h
(1.69 KB)
📄
sanitizer_symbolizer.cpp
(3.65 KB)
📄
sanitizer_symbolizer.h
(6.62 KB)
📄
sanitizer_symbolizer_fuchsia.h
(1.56 KB)
📄
sanitizer_symbolizer_internal.h
(5.8 KB)
📄
sanitizer_symbolizer_libbacktrace.cpp
(6.1 KB)
📄
sanitizer_symbolizer_libbacktrace.h
(1.49 KB)
📄
sanitizer_symbolizer_libcdep.cpp
(17.45 KB)
📄
sanitizer_symbolizer_mac.cpp
(8.48 KB)
📄
sanitizer_symbolizer_mac.h
(1.37 KB)
📄
sanitizer_symbolizer_markup.cpp
(5.39 KB)
📄
sanitizer_symbolizer_posix_libcdep.cpp
(16.5 KB)
📄
sanitizer_symbolizer_report.cpp
(10.01 KB)
📄
sanitizer_symbolizer_rtems.h
(1.56 KB)
📄
sanitizer_symbolizer_win.cpp
(11.59 KB)
📄
sanitizer_syscall_generic.inc
(1.06 KB)
📄
sanitizer_syscall_linux_aarch64.inc
(4.58 KB)
📄
sanitizer_syscall_linux_arm.inc
(4.58 KB)
📄
sanitizer_syscall_linux_x86_64.inc
(3.07 KB)
📄
sanitizer_syscalls_netbsd.inc
(120.97 KB)
📄
sanitizer_termination.cpp
(2.86 KB)
📄
sanitizer_thread_registry.cpp
(10.31 KB)
📄
sanitizer_thread_registry.h
(5.44 KB)
📄
sanitizer_tls_get_addr.cpp
(5.29 KB)
📄
sanitizer_tls_get_addr.h
(2.21 KB)
📄
sanitizer_type_traits.cpp
(708 B)
📄
sanitizer_type_traits.h
(1.49 KB)
📄
sanitizer_unwind_linux_libcdep.cpp
(6.13 KB)
📄
sanitizer_unwind_win.cpp
(2.41 KB)
📄
sanitizer_vector.h
(2.57 KB)
📄
sanitizer_win.cpp
(33.3 KB)
📄
sanitizer_win.h
(851 B)
📄
sanitizer_win_defs.h
(7.23 KB)
📄
sanitizer_win_dll_thunk.cpp
(3.41 KB)
📄
sanitizer_win_dll_thunk.h
(11.13 KB)
📄
sanitizer_win_dynamic_runtime_thunk.cpp
(1.16 KB)
📄
sanitizer_win_weak_interception.cpp
(3.49 KB)
📄
sanitizer_win_weak_interception.h
(1.64 KB)
📁
symbolizer
📄
weak_symbols.txt
(230 B)
Editing: sanitizer_procmaps_mac.cpp
//===-- sanitizer_procmaps_mac.cpp ----------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // Information about the process mappings (Mac-specific parts). //===----------------------------------------------------------------------===// #include "sanitizer_platform.h" #if SANITIZER_MAC #include "sanitizer_common.h" #include "sanitizer_placement_new.h" #include "sanitizer_procmaps.h" #include <mach-o/dyld.h> #include <mach-o/loader.h> #include <mach/mach.h> // These are not available in older macOS SDKs. #ifndef CPU_SUBTYPE_X86_64_H #define CPU_SUBTYPE_X86_64_H ((cpu_subtype_t)8) /* Haswell */ #endif #ifndef CPU_SUBTYPE_ARM_V7S #define CPU_SUBTYPE_ARM_V7S ((cpu_subtype_t)11) /* Swift */ #endif #ifndef CPU_SUBTYPE_ARM_V7K #define CPU_SUBTYPE_ARM_V7K ((cpu_subtype_t)12) #endif #ifndef CPU_TYPE_ARM64 #define CPU_TYPE_ARM64 (CPU_TYPE_ARM | CPU_ARCH_ABI64) #endif namespace __sanitizer { // Contains information used to iterate through sections. struct MemoryMappedSegmentData { char name[kMaxSegName]; uptr nsects; const char *current_load_cmd_addr; u32 lc_type; uptr base_virt_addr; uptr addr_mask; }; template <typename Section> static void NextSectionLoad(LoadedModule *module, MemoryMappedSegmentData *data, bool isWritable) { const Section *sc = (const Section *)data->current_load_cmd_addr; data->current_load_cmd_addr += sizeof(Section); uptr sec_start = (sc->addr & data->addr_mask) + data->base_virt_addr; uptr sec_end = sec_start + sc->size; module->addAddressRange(sec_start, sec_end, /*executable=*/false, isWritable, sc->sectname); } void MemoryMappedSegment::AddAddressRanges(LoadedModule *module) { // Don't iterate over sections when the caller hasn't set up the // data pointer, when there are no sections, or when the segment // is executable. Avoid iterating over executable sections because // it will confuse libignore, and because the extra granularity // of information is not needed by any sanitizers. if (!data_ || !data_->nsects || IsExecutable()) { module->addAddressRange(start, end, IsExecutable(), IsWritable(), data_ ? data_->name : nullptr); return; } do { if (data_->lc_type == LC_SEGMENT) { NextSectionLoad<struct section>(module, data_, IsWritable()); #ifdef MH_MAGIC_64 } else if (data_->lc_type == LC_SEGMENT_64) { NextSectionLoad<struct section_64>(module, data_, IsWritable()); #endif } } while (--data_->nsects); } MemoryMappingLayout::MemoryMappingLayout(bool cache_enabled) { Reset(); } MemoryMappingLayout::~MemoryMappingLayout() { } bool MemoryMappingLayout::Error() const { return false; } // More information about Mach-O headers can be found in mach-o/loader.h // Each Mach-O image has a header (mach_header or mach_header_64) starting with // a magic number, and a list of linker load commands directly following the // header. // A load command is at least two 32-bit words: the command type and the // command size in bytes. We're interested only in segment load commands // (LC_SEGMENT and LC_SEGMENT_64), which tell that a part of the file is mapped // into the task's address space. // The |vmaddr|, |vmsize| and |fileoff| fields of segment_command or // segment_command_64 correspond to the memory address, memory size and the // file offset of the current memory segment. // Because these fields are taken from the images as is, one needs to add // _dyld_get_image_vmaddr_slide() to get the actual addresses at runtime. void MemoryMappingLayout::Reset() { // Count down from the top. // TODO(glider): as per man 3 dyld, iterating over the headers with // _dyld_image_count is thread-unsafe. We need to register callbacks for // adding and removing images which will invalidate the MemoryMappingLayout // state. data_.current_image = _dyld_image_count(); data_.current_load_cmd_count = -1; data_.current_load_cmd_addr = 0; data_.current_magic = 0; data_.current_filetype = 0; data_.current_arch = kModuleArchUnknown; internal_memset(data_.current_uuid, 0, kModuleUUIDSize); } // The dyld load address should be unchanged throughout process execution, // and it is expensive to compute once many libraries have been loaded, // so cache it here and do not reset. static mach_header *dyld_hdr = 0; static const char kDyldPath[] = "/usr/lib/dyld"; static const int kDyldImageIdx = -1; // static void MemoryMappingLayout::CacheMemoryMappings() { // No-op on Mac for now. } void MemoryMappingLayout::LoadFromCache() { // No-op on Mac for now. } // _dyld_get_image_header() and related APIs don't report dyld itself. // We work around this by manually recursing through the memory map // until we hit a Mach header matching dyld instead. These recurse // calls are expensive, but the first memory map generation occurs // early in the process, when dyld is one of the only images loaded, // so it will be hit after only a few iterations. static mach_header *get_dyld_image_header() { unsigned depth = 1; vm_size_t size = 0; vm_address_t address = 0; kern_return_t err = KERN_SUCCESS; mach_msg_type_number_t count = VM_REGION_SUBMAP_INFO_COUNT_64; while (true) { struct vm_region_submap_info_64 info; err = vm_region_recurse_64(mach_task_self(), &address, &size, &depth, (vm_region_info_t)&info, &count); if (err != KERN_SUCCESS) return nullptr; if (size >= sizeof(mach_header) && info.protection & kProtectionRead) { mach_header *hdr = (mach_header *)address; if ((hdr->magic == MH_MAGIC || hdr->magic == MH_MAGIC_64) && hdr->filetype == MH_DYLINKER) { return hdr; } } address += size; } } const mach_header *get_dyld_hdr() { if (!dyld_hdr) dyld_hdr = get_dyld_image_header(); return dyld_hdr; } // Next and NextSegmentLoad were inspired by base/sysinfo.cc in // Google Perftools, https://github.com/gperftools/gperftools. // NextSegmentLoad scans the current image for the next segment load command // and returns the start and end addresses and file offset of the corresponding // segment. // Note that the segment addresses are not necessarily sorted. template <u32 kLCSegment, typename SegmentCommand> static bool NextSegmentLoad(MemoryMappedSegment *segment, MemoryMappedSegmentData *seg_data, MemoryMappingLayoutData *layout_data) { const char *lc = layout_data->current_load_cmd_addr; layout_data->current_load_cmd_addr += ((const load_command *)lc)->cmdsize; if (((const load_command *)lc)->cmd == kLCSegment) { const SegmentCommand* sc = (const SegmentCommand *)lc; uptr base_virt_addr, addr_mask; if (layout_data->current_image == kDyldImageIdx) { base_virt_addr = (uptr)get_dyld_hdr(); // vmaddr is masked with 0xfffff because on macOS versions < 10.12, // it contains an absolute address rather than an offset for dyld. // To make matters even more complicated, this absolute address // isn't actually the absolute segment address, but the offset portion // of the address is accurate when combined with the dyld base address, // and the mask will give just this offset. addr_mask = 0xfffff; } else { base_virt_addr = (uptr)_dyld_get_image_vmaddr_slide(layout_data->current_image); addr_mask = ~0; } segment->start = (sc->vmaddr & addr_mask) + base_virt_addr; segment->end = segment->start + sc->vmsize; // Most callers don't need section information, so only fill this struct // when required. if (seg_data) { seg_data->nsects = sc->nsects; seg_data->current_load_cmd_addr = (const char *)lc + sizeof(SegmentCommand); seg_data->lc_type = kLCSegment; seg_data->base_virt_addr = base_virt_addr; seg_data->addr_mask = addr_mask; internal_strncpy(seg_data->name, sc->segname, ARRAY_SIZE(seg_data->name)); } // Return the initial protection. segment->protection = sc->initprot; segment->offset = (layout_data->current_filetype == /*MH_EXECUTE*/ 0x2) ? sc->vmaddr : sc->fileoff; if (segment->filename) { const char *src = (layout_data->current_image == kDyldImageIdx) ? kDyldPath : _dyld_get_image_name(layout_data->current_image); internal_strncpy(segment->filename, src, segment->filename_size); } segment->arch = layout_data->current_arch; internal_memcpy(segment->uuid, layout_data->current_uuid, kModuleUUIDSize); return true; } return false; } ModuleArch ModuleArchFromCpuType(cpu_type_t cputype, cpu_subtype_t cpusubtype) { cpusubtype = cpusubtype & ~CPU_SUBTYPE_MASK; switch (cputype) { case CPU_TYPE_I386: return kModuleArchI386; case CPU_TYPE_X86_64: if (cpusubtype == CPU_SUBTYPE_X86_64_ALL) return kModuleArchX86_64; if (cpusubtype == CPU_SUBTYPE_X86_64_H) return kModuleArchX86_64H; CHECK(0 && "Invalid subtype of x86_64"); return kModuleArchUnknown; case CPU_TYPE_ARM: if (cpusubtype == CPU_SUBTYPE_ARM_V6) return kModuleArchARMV6; if (cpusubtype == CPU_SUBTYPE_ARM_V7) return kModuleArchARMV7; if (cpusubtype == CPU_SUBTYPE_ARM_V7S) return kModuleArchARMV7S; if (cpusubtype == CPU_SUBTYPE_ARM_V7K) return kModuleArchARMV7K; CHECK(0 && "Invalid subtype of ARM"); return kModuleArchUnknown; case CPU_TYPE_ARM64: return kModuleArchARM64; default: CHECK(0 && "Invalid CPU type"); return kModuleArchUnknown; } } static const load_command *NextCommand(const load_command *lc) { return (const load_command *)((const char *)lc + lc->cmdsize); } static void FindUUID(const load_command *first_lc, u8 *uuid_output) { for (const load_command *lc = first_lc; lc->cmd != 0; lc = NextCommand(lc)) { if (lc->cmd != LC_UUID) continue; const uuid_command *uuid_lc = (const uuid_command *)lc; const uint8_t *uuid = &uuid_lc->uuid[0]; internal_memcpy(uuid_output, uuid, kModuleUUIDSize); return; } } static bool IsModuleInstrumented(const load_command *first_lc) { for (const load_command *lc = first_lc; lc->cmd != 0; lc = NextCommand(lc)) { if (lc->cmd != LC_LOAD_DYLIB) continue; const dylib_command *dylib_lc = (const dylib_command *)lc; uint32_t dylib_name_offset = dylib_lc->dylib.name.offset; const char *dylib_name = ((const char *)dylib_lc) + dylib_name_offset; dylib_name = StripModuleName(dylib_name); if (dylib_name != 0 && (internal_strstr(dylib_name, "libclang_rt."))) { return true; } } return false; } bool MemoryMappingLayout::Next(MemoryMappedSegment *segment) { for (; data_.current_image >= kDyldImageIdx; data_.current_image--) { const mach_header *hdr = (data_.current_image == kDyldImageIdx) ? get_dyld_hdr() : _dyld_get_image_header(data_.current_image); if (!hdr) continue; if (data_.current_load_cmd_count < 0) { // Set up for this image; data_.current_load_cmd_count = hdr->ncmds; data_.current_magic = hdr->magic; data_.current_filetype = hdr->filetype; data_.current_arch = ModuleArchFromCpuType(hdr->cputype, hdr->cpusubtype); switch (data_.current_magic) { #ifdef MH_MAGIC_64 case MH_MAGIC_64: { data_.current_load_cmd_addr = (const char *)hdr + sizeof(mach_header_64); break; } #endif case MH_MAGIC: { data_.current_load_cmd_addr = (const char *)hdr + sizeof(mach_header); break; } default: { continue; } } FindUUID((const load_command *)data_.current_load_cmd_addr, data_.current_uuid); data_.current_instrumented = IsModuleInstrumented( (const load_command *)data_.current_load_cmd_addr); } for (; data_.current_load_cmd_count >= 0; data_.current_load_cmd_count--) { switch (data_.current_magic) { // data_.current_magic may be only one of MH_MAGIC, MH_MAGIC_64. #ifdef MH_MAGIC_64 case MH_MAGIC_64: { if (NextSegmentLoad<LC_SEGMENT_64, struct segment_command_64>( segment, segment->data_, &data_)) return true; break; } #endif case MH_MAGIC: { if (NextSegmentLoad<LC_SEGMENT, struct segment_command>( segment, segment->data_, &data_)) return true; break; } } } // If we get here, no more load_cmd's in this image talk about // segments. Go on to the next image. } return false; } void MemoryMappingLayout::DumpListOfModules( InternalMmapVectorNoCtor<LoadedModule> *modules) { Reset(); InternalScopedString module_name(kMaxPathLength); MemoryMappedSegment segment(module_name.data(), kMaxPathLength); MemoryMappedSegmentData data; segment.data_ = &data; while (Next(&segment)) { if (segment.filename[0] == '\0') continue; LoadedModule *cur_module = nullptr; if (!modules->empty() && 0 == internal_strcmp(segment.filename, modules->back().full_name())) { cur_module = &modules->back(); } else { modules->push_back(LoadedModule()); cur_module = &modules->back(); cur_module->set(segment.filename, segment.start, segment.arch, segment.uuid, data_.current_instrumented); } segment.AddAddressRanges(cur_module); } } } // namespace __sanitizer #endif // SANITIZER_MAC
Upload File
Create Folder