This will allow sanitizer_procmaps on mac to expose section information.
Only scan global sections containing data in LSan on darwin
__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).
Is it possible to drop has_sections and MemoryMappedSection, and add the current section info right here, under #if MAC? No other but Mac specific code will need to be changed.
If it turns out to be beneficial to have MemoryMappedSection defined, well, maybe define it inside the MemoryMappedSegment, under the same #if and call it just Segment?
That would lead to a platform specific function AddSegmentAddressRange(MemoryMappedSegment *segment, LoadedModule *module); and all the Mac specific stuff will be contained in _mac files.
What do you think? It's totally possible I miss some details precluding us from doing so.