[llvm-dev] [compiler-rt] Proposed changes to MemoryMappingLayout (sanitizer_procmaps)

Francis Ricci via llvm-dev llvm-dev at lists.llvm.org
Wed Jul 5 08:27:09 PDT 2017

Hi all,

LeakSanitizer on Darwin has some performance issues caused by scanning
unnecessary sections in the MachO __DATA segment (things like
objective-c metadata, strings, selectors, etc). Based on the relative
sizes of these sections and profiling data for moderately-sized
Objective-C programs, I estimate that performance would be improved by
70-80% by only scanning __data, __bss, and __common MachO sections for
pointers instead of the entire __DATA segment.

In order to reveal section information using MemoryMappingLayout, I
would like to make a few changes:

1) Move from MemoryMappingLayout::Next() to c++ style iterators
2) Introduce a new class MemoryMappedSegment, which is returned by
MemoryMappingLayout iterators
3) Introduce a new class MemoryMappedSection, which is returned by
MemoryMappedSegment iterators

On ELF targets, each MemoryMappedSegment would contain a single
MemoryMappedSection, which would be the ELF section currently returned
by MemoryMappingLayout::Next(), maintaining current behavior.

On MachO targets, a MemoryMappedSection would correspond to a MachO
section, revealing the necessary section data to LeakSanitizer.

The address ranges in each module returned by
MemoryMappingLayout::DumpListOfModules() would be unchanged on ELF
targets, but would correspond to a MachO section instead of a MachO
segment on MachO targets.

This is a somewhat large and invasive change that will affect
sanitizers beyond just LeakSanitizer, so I'm very open to input about
the design before I write up the implementation.


More information about the llvm-dev mailing list