summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cc
Commit message (Collapse)AuthorAgeFilesLines
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Fix Mac compilation.Evgeniy Stepanov2019-01-081-0/+4
| | | | | | Provide an implementation of MemoryMappingLayout::Error() for Mac. llvm-svn: 350601
* [sanitizer] Don't call task_for_pid(mach_task_self). NFC.Kuba Mracek2018-08-231-7/+1
| | | | | | | | | | Calling task_for_pid with mach_task_self is just returning mach_task_self anyway, but it also triggers system warnings (task_for_pid is only supposed to be used by high-privileged executables). NFC. rdar://problem/39198248 Differential Revision: https://reviews.llvm.org/D51119 llvm-svn: 340587
* [compiler-rt] Fix const and volatile qualifier warningsKuba Mracek2017-11-101-5/+6
| | | | | | | | Building with a new clang produces a bunch of warnings about dropped 'const' and 'volatile' qualifiers on pointers. Let's fix them. Differential Revision: https://reviews.llvm.org/D39861 llvm-svn: 317929
* Move LoadedModule list to a NoCtor vector and initialize on demand.Francis Ricci2017-09-291-1/+1
| | | | | | | Unreverting this patch because llvm-clang-lld-x86_64-debian-fast started passing again before the revert hit. Must've been just a flake. llvm-svn: 314556
* Revert "Move LoadedModule list to a NoCtor vector and initialize on demand."Francis Ricci2017-09-291-1/+1
| | | | | | | | | I think this may have introduced a failure on llvm-clang-lld-x86_64-debian-fast This reverts commit r314533 llvm-svn: 314552
* Move LoadedModule list to a NoCtor vector and initialize on demand.Francis Ricci2017-09-291-1/+1
| | | | llvm-svn: 314533
* Revert "Add support for custom loaders to the sanitizer symbolizer"Francis Ricci2017-09-281-1/+1
| | | | | | | | This causes the gcc sanitizer buildbot to timeout. This reverts commit 81f388fe570e5b6460dd5bc9b9a36b72714eeb68. llvm-svn: 314453
* Add support for custom loaders to the sanitizer symbolizerFrancis Ricci2017-09-281-1/+1
| | | | | | | | | | | | | | | | | Summary: Adds a fallback mode to procmaps when the symbolizer fails to locate a module for a given address by using dl_iterate_phdr. Reviewers: kubamracek, rnk, vitalybuka, eugenis Reviewed By: eugenis Subscribers: srhines, llvm-commits Differential Revision: https://reviews.llvm.org/D37269 llvm-svn: 314431
* Revert "Add support for custom loaders to symbolizer"Francis Ricci2017-09-271-1/+1
| | | | | | | | This broke the windows buildbots, revert for now. This reverts commit 24050b5ddef42f6f3306aa94d4a1f42a7893a9a7. llvm-svn: 314347
* Add support for custom loaders to symbolizerFrancis Ricci2017-09-271-1/+1
| | | | | Change-Id: I5594bd6b216deca2c73cf0a7001f9aec1e803c60 llvm-svn: 314342
* Removed platform-specific ifdefs from sanitizer_procmaps.hFrancis Ricci2017-09-221-48/+53
| | | | | | | | | | | | | | | | Summary: Removed platform-specific ifdefs for linux, mac, freebsd and netbsd from sanitizer_procmaps.h Patch by Yicheng Wang <yichengfb@fb.com> Reviewers: kcc, kubamracek, alekseyshl, fjricci, vitalybuka Reviewed By: fjricci, vitalybuka Subscribers: vitalybuka, emaste, krytarowski, llvm-commits Differential Revision: https://reviews.llvm.org/D38098 llvm-svn: 313999
* Only scan global sections containing data in LSan on darwinFrancis Ricci2017-07-251-2/+7
| | | | | | | | | | | | | | | | | | | | Summary: __DATA segments on Darwin contain a large number of separate sections, many of which cannot actually contain pointers, and contain const values or objc metadata. Not scanning sections which cannot contain pointers significantly improves performance. On a medium-sized (~4000 files) internal project, I saw a speedup of about 30% in standalone LSan's execution time (30% improvement in the time spent running LSan, not the total program time). Reviewers: kcc, kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35432 llvm-svn: 308999
* Add address ranges for individual macho sections on darwinFrancis Ricci2017-07-251-8/+64
| | | | | | | | | | | | | | | Summary: This is a re-upload of the reverted commit r308644. It has changed quite a bit to reflect post-commit comments by kcc, so I'm re-uploading as a new review. Reviewers: kubamracek, alekseyshl, kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35799 llvm-svn: 308977
* Revert "Add MemoryMappedSection struct for two-level memory map iteration"Francis Ricci2017-07-201-39/+8
| | | | | | | | This probably broke lib0 tsan unit test on 10.11 buildbots This reverts commit 35ad307c385e384f47a7fb348c14b3602d3a33c4. llvm-svn: 308676
* Add MemoryMappedSection struct for two-level memory map iterationFrancis Ricci2017-07-201-8/+39
| | | | | | | | | | | | Summary: This will allow sanitizer_procmaps on mac to expose section information. Reviewers: kubamracek, alekseyshl, kcc Subscribers: llvm-commits, emaste Differential Revision: https://reviews.llvm.org/D35422 llvm-svn: 308644
* Revert "Add MemoryMappedSection struct for two-level memory map iteration"Francis Ricci2017-07-181-37/+8
| | | | | | | | This reverts commit c8095ce74118dee8544b0f1ffaba8f46aa10215c. Reverted due to some buildbot timeouts, perhaps due to 10.11 issues. llvm-svn: 308395
* Revert "Only scan global sections containing data in LSan on darwin"Francis Ricci2017-07-181-4/+2
| | | | | | This reverts commit 7e46d78d47832f03ce42adcf56417fbfd47cbaad. llvm-svn: 308394
* Only scan global sections containing data in LSan on darwinFrancis Ricci2017-07-171-2/+4
| | | | | | | | | | | | | | | | | | | | Summary: __DATA segments on Darwin contain a large number of separate sections, most of which cannot actually contain pointers, and contain const values or objc metadata. Only scanning sections which can contain pointers greatly improves performance. On a medium-sized (~4000 files) internal project, I saw a speedup of about 50% in standalone LSan's execution time (50% improvement in the time spent running LSan, not the total program time). Reviewers: kcc, kubamracek, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35432 llvm-svn: 308231
* Add MemoryMappedSection struct for two-level memory map iterationFrancis Ricci2017-07-171-8/+37
| | | | | | | | | | | | Summary: This will allow sanitizer_procmaps on mac to expose section information. Reviewers: kubamracek, alekseyshl, kcc Subscribers: llvm-commits, emaste Differential Revision: https://reviews.llvm.org/D35422 llvm-svn: 308210
* Inline function to get mac segment address rangeFrancis Ricci2017-07-111-61/+58
| | | | | | | | | | | | | | Summary: This function is only called once and is fairly simple. Inline to keep API simple. Reviewers: alekseyshl, kubamracek Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35270 llvm-svn: 307695
* Refactor MemoryMappingLayout::Next to use a single struct instead of output ↵Francis Ricci2017-07-111-58/+30
| | | | | | | | | | | | | | | | | | | | | | | | | parameters. NFC. Summary: This is the first in a series of patches to refactor sanitizer_procmaps to allow MachO section information to be exposed on darwin. In addition, grouping all segment information in a single struct is cleaner than passing it through a large set of output parameters, and avoids the need for annotations of NULL parameters for unneeded information. The filename string is optional and must be managed and supplied by the calling function. This is to allow the MemoryMappedSegment struct to be stored on the stack without causing overly large stack sizes. Reviewers: alekseyshl, kubamracek, glider Subscribers: emaste, llvm-commits Differential Revision: https://reviews.llvm.org/D35135 llvm-svn: 307688
* Use write instead of read permissions to check for global sections on macFrancis Ricci2017-05-191-1/+1
| | | | | | | | | | | | | | | Summary: The LINKEDIT section is very large and is read-only. Scanning this section caused LSan on darwin to be very slow. When only writable sections are scanned for global pointers, performance improved by a factor of about 25x. Reviewers: alekseyshl, kubamracek Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33322 llvm-svn: 303422
* Add dyld to sanitizer procmaps on darwinFrancis Ricci2017-05-121-7/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Sanitizer procmaps uses dyld apis to iterate over the list of images in the process. This is much more performan than manually recursing over all of the memory regions in the process, however, dyld does not report itself in the list of images. In order to prevent reporting leaks from dyld globals and to symbolize dyld functions in stack traces, this patch special-cases dyld and ensures that it is added to the list of modules. This is accomplished by recursing through the memory map of the process until a dyld Mach header is found. While this recursion is expensive, it is run before the full set of images has been loaded in the process, so only a few calls are required. The result is cached so that it never needs to be searched for when the full process memory map exists, as this would be incredibly slow, on the order of minutes for leak sanitizer with only 25 or so libraries loaded. Reviewers: alekseyshl, kubamracek Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32968 llvm-svn: 302899
* Revert "Add dyld to sanitizer procmaps on darwin"Francis Ricci2017-05-101-79/+7
| | | | | | | | | This breaks several tests because we don't always have access to __cxa_guard functions This reverts commit 45eb470c3e9e8f6993a204e247c33d4092237efe. llvm-svn: 302693
* Revert "Disable static caching of dyld header on Go sanitizers"Francis Ricci2017-05-101-4/+0
| | | | | | | This is a problem on more than just the go sanitizers, so it's not a good enough fix for the issue. llvm-svn: 302692
* Disable static caching of dyld header on Go sanitizersFrancis Ricci2017-05-101-0/+4
| | | | | | This causes buildbot failures due to undefined __cxa_guard_acquire llvm-svn: 302681
* Add dyld to sanitizer procmaps on darwinFrancis Ricci2017-05-101-7/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Sanitizer procmaps uses dyld apis to iterate over the list of images in the process. This is much more performan than manually recursing over all of the memory regions in the process, however, dyld does not report itself in the list of images. In order to prevent reporting leaks from dyld globals and to symbolize dyld functions in stack traces, this patch special-cases dyld and ensures that it is added to the list of modules. This is accomplished by recursing through the memory map of the process until a dyld Mach header is found. While this recursion is expensive, it is run before the full set of images has been loaded in the process, so only a few calls are required. The result is cached so that it never needs to be searched for when the full process memory map exists, as this would be incredibly slow, on the order of minutes for leak sanitizer with only 25 or so libraries loaded. Reviewers: alekseyshl, kubamracek Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32968 llvm-svn: 302673
* Don't read non-readable address ranges during lsan pointer scanningFrancis Ricci2017-04-171-1/+2
| | | | | | | | | | | | Summary: This specifically addresses the Mach-O zero page, which we cannot read from. Reviewers: kubamracek, samsonov, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32044 llvm-svn: 300456
* [sanitizer] Track which modules are instrumented in LoadedModule objectsKuba Mracek2017-01-061-14/+30
| | | | | | | | This patch adds tracking which modules are instrumented and which are not. On macOS, instrumented modules link against the ASan/TSan/... dylib, so we can just check if such a load command exists or not. Differential Revision: https://reviews.llvm.org/D28263 llvm-svn: 291268
* [sanitizer] Define some CPU type symbols (like CPU_SUBTYPE_X86_64_H) when ↵Kuba Mracek2016-12-251-0/+14
| | | | | | | | | | they're not available. This allows compiler-rt to be built on older macOS SDKs, where there symbols are not defined. Patch by Jeremy Huddleston Sequoia <jeremyhu@apple.com>. llvm-svn: 290521
* [sanitizer] Track architecture and UUID of modules in LoadedModuleKuba Mracek2016-12-021-10/+67
| | | | | | | | | | When we enumerate loaded modules, we only track the module name and base address, which then has several problems on macOS. Dylibs and executables often have several architecture slices and not storing which architecture/UUID is actually loaded creates problems with symbolication: A file path + offset isn't enough to correctly symbolicate, since the offset can be valid in multiple slices. This is especially common for Haswell+ X86_64 machines, where x86_64h slices are preferred, but if one is not available, a regular x86_64 is loaded instead. But the same issue exists for i386 vs. x86_64 as well. This patch adds tracking of arch and UUID for each LoadedModule. At this point, this information isn't used in reports, but this is the first step. The goal is to correctly identify which slice is loaded in symbolication, and also to output this information in reports so that we can tell which exact slices were loaded in post-mortem analysis. Differential Revision: https://reviews.llvm.org/D26632 llvm-svn: 288537
* [Sanitizer] Introduce ListOfModules object and use it to replace ↵Alexey Samsonov2016-02-221-15/+9
| | | | | | | | | | | | | | | | | | | | GetListOfModules(). Summary: This removes the hard limit on the number of loaded modules (used to be 16K), and makes it easier to use LoadedModules w/o causing a memory leak: ListOfModules owns the modules, and makes sure to properly clean them in destructor. Remove filtering functionality that is only needed in one place (LSan). Reviewers: aizatsky Subscribers: llvm-commits, kcc Differential Revision: http://reviews.llvm.org/D17470 llvm-svn: 261554
* [libsanitizer] Fix bugs and wiki links to point to GitHub.Alexander Potapenko2015-12-041-1/+1
| | | | llvm-svn: 254738
* [ASan] Unify handling of loaded modules between POSIX and WindowsTimur Iskhodzhanov2015-04-061-3/+3
| | | | | | Reviewed at http://reviews.llvm.org/D8805 llvm-svn: 234150
* Replace InternalScopedBuffer<char> with InternalScopedString where applicable.Alexey Samsonov2014-12-021-1/+1
| | | | | | | | | | | | | | | | Summary: No functionality change. Test Plan: make check-all Reviewers: kcc Reviewed By: kcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6472 llvm-svn: 223164
* [ASan] When iterating over segments on OSX, treat the segments' initialAlexander Potapenko2014-06-251-2/+4
| | | | | | | protection level as their current protection level. This fixes the UNIMPLEMENTED check that started to fire on OSX after r210649. llvm-svn: 211713
* [asan] Exclude non-executable mappings from coverage.Evgeniy Stepanov2014-06-111-3/+3
| | | | llvm-svn: 210649
* [Sanitizer] Remove now unused symbolization functionality from ↵Alexey Samsonov2013-12-251-8/+0
| | | | | | MemoryMappingLayout llvm-svn: 198014
* [Sanitizer] Use different MemoryMappingLayout::DumpListOfModules on Linux ↵Alexey Samsonov2013-12-251-0/+31
| | | | | | | | and Mac. Make a unit test added in r198004 more robust. llvm-svn: 198012
* [Sanitizer] Move OS-specific code for MemoryMappingLayout into separate ↵Alexey Samsonov2013-12-251-0/+165
source files. llvm-svn: 198003
OpenPOWER on IntegriCloud