[PATCH] D123010: [WIP][asan] Emit .size directive for global object size before redzone

Alex Brachet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 3 21:07:23 PDT 2022


abrachet created this revision.
abrachet added reviewers: phosek, vitalybuka, MaskRay.
Herald added subscribers: StephenFan, dexonsmith, sunfish, hiraditya, dschuff.
Herald added a project: All.
abrachet requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.

This matches gcc's behavior of keeping an objects `st_size` as it was before the redzone is added. Keeping the smaller size is beneficial for reducing the amount copied in copy relocations.

This is just a proof of concept, from a quick grep WebAssembly and XCore use `emitELFSize` on global variables, but I did not include that here. The clang test is also not where I would like any real testing of this to live. However, as of right now, this only works when instrumentation and assembly emitting happen in the same process, and will not work when doing something like `opt` piped into `llc`. I think for that to work there would need to be a new llvm attribute added. Not sure if an attribute makes sense given it would have few use cases other than this specific one. Wondering if anyone has any ideas on how to proceed.


https://reviews.llvm.org/D123010

Files:
  clang/test/CodeGen/asan-globals.cpp
  llvm/include/llvm/IR/DerivedTypes.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/IR/Type.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123010.420100.patch
Type: text/x-patch
Size: 9069 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220404/103fdc96/attachment.bin>


More information about the llvm-commits mailing list