Hi all,
I noticed that some asan-instrumented binaries varied in size depending on the length of my build path despite using -ffile-prefix-map. I discovered that asan bakes in the absolute path of whatever I’m compiling through the module ID (https://github.com/llvm/llvm-project/blob/80397d2d12b042586cb3bafdeb12ef8d982b8875/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp#L2254) which is currently unaffected by -ffile-prefix-map. This means binaries shipped in asan-instrumented toolchains, like libunwind, may vary depending on where it’s built.
From what I see, there doesn’t seem to be an existing way of indicating to asan that I’d like to map prefixes, so I have a couple of implementation ideas that I wanted to see if people had opinions on:
-
Have a separate flag orthogonal to
-fmacro-prefix-mapand-fdebug-prefix-mapthat controls which paths sanitizers (or at least asan) use. This can be named something like-fsanitizer-prefix-mapand would also be turned on when-ffile-prefix-mapis used. -
Same as 1, but we wouldn’t be adding a new flag (
-fsanitizer-prefix-map) and the sanitizers would just use whatever value is passed to-ffile-prefix-map.
3/4. Same as 1/2, but instead of catching this at sanitizer creation, we catch this on llvm::Module creation, so anything that calls Module::getModuleIdentifier() will always return a path whose prefix was replaced according to whatever appropriate mapping.
Thanks,
Leonard