[cfe-dev] Prefix Mapping for Paths used by Sanitizers
Petr Hosek via cfe-dev
cfe-dev at lists.llvm.org
Fri Mar 13 18:07:01 PDT 2020
I vote for option #4, that is use the `-ffile-prefix-map` flag and handle
this on `llvm::Module` creation. I'd like to avoid introducing new flags
unless needed, and handle it in a way that works for all passes, not just
sanitizers.
On Fri, Mar 13, 2020 at 5:44 PM Leonard Chan <leonardchan at google.com> wrote:
> 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:
>
> 1. Have a separate flag orthogonal to `-fmacro-prefix-map` and
> `-fdebug-prefix-map` that controls which paths sanitizers (or at least
> asan) use. This can be named something like `-fsanitizer-prefix-map` and
> would also be turned on when `-ffile-prefix-map` is used.
>
> 2. 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200313/cff73394/attachment.html>
More information about the cfe-dev
mailing list