diff options
author | Marco Elver <elver@google.com> | 2025-10-08 20:59:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-10-08 20:59:24 +0200 |
commit | 774ffe5cce7392e6b4e29c83e725337727c2c994 (patch) | |
tree | cd792b0a1bf9661056404d78f7e6836f645a4951 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | |
parent | 761be78dd73436dfa66090ba921ca8154cc42209 (diff) | |
download | llvm-774ffe5cce7392e6b4e29c83e725337727c2c994.zip llvm-774ffe5cce7392e6b4e29c83e725337727c2c994.tar.gz llvm-774ffe5cce7392e6b4e29c83e725337727c2c994.tar.bz2 |
[Clang] Wire up -fsanitize=alloc-token (#156839)
Wire up the `-fsanitize=alloc-token` command-line option, hooking up
the `AllocToken` pass -- it provides allocation tokens to compatible
runtime allocators, enabling different heap organization strategies,
e.g. hardening schemes based on heap partitioning.
The instrumentation rewrites standard allocation calls into variants
that accept an additional `size_t token_id` argument. For example,
calls to `malloc(size)` become `__alloc_token_malloc(size, token_id)`,
and a C++ `new MyType` expression will call
`__alloc_token__Znwm(size, token_id)`.
Currently untyped allocation calls do not yet have `!alloc_token`
metadata, and therefore receive the fallback token only. This will be
fixed in subsequent changes through best-effort type-inference.
One benefit of the instrumentation approach is that it can be applied
transparently to large codebases, and scales in deployment as other
sanitizers.
Similarly to other sanitizers, instrumentation can selectively be
controlled using `__attribute__((no_sanitize("alloc-token")))`. Support
for sanitizer ignorelists to disable instrumentation for specific
functions or source files is implemented.
See clang/docs/AllocToken.rst for more usage instructions.
Link:
https://discourse.llvm.org/t/rfc-a-framework-for-allocator-partitioning-hints/87434
---
This change is part of the following series:
1. https://github.com/llvm/llvm-project/pull/160131
2. https://github.com/llvm/llvm-project/pull/156838
3. https://github.com/llvm/llvm-project/pull/162098
4. https://github.com/llvm/llvm-project/pull/162099
5. https://github.com/llvm/llvm-project/pull/156839
6. https://github.com/llvm/llvm-project/pull/156840
7. https://github.com/llvm/llvm-project/pull/156841
8. https://github.com/llvm/llvm-project/pull/156842
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
0 files changed, 0 insertions, 0 deletions