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

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 11 10:38:22 PDT 2022


efriedma added inline comments.


================
Comment at: llvm/docs/LangRef.rst:7098
+
+The ``explicit_size`` metadata is used to emit a size directive with a different
+size than the objects total size. This can be useful when an object contains
----------------
abrachet wrote:
> efriedma wrote:
> > MaskRay wrote:
> > > Suggest: The ``explicit_size`` metadata  may be attached to a global variable definition with a size different from the object's total size. This can be useful when an instrumentation enlarges the object while the symbol size should reflect the accessible or meaningful part of the object.
> > > 
> > > 
> > > I think this is not meaningful to functions, ifuncs, comdats, etc, and likely not meaningful to scalar types, but it may not be necessary to catch the error in the IR verifier.
> > Probably makes sense to diagnose on anything that isn't a definition of a variable.  Probably not worth trying to catch other dubious cases.
> > 
> > Maybe explicitly note that this doesn't make sense for all object formats?
> Thanks @maskray I've used this comment verbatim. Plus added some about how this is only meaningful on ELF. 
> 
> > Probably makes sense to diagnose on anything that isn't a definition of a variable.
> How do you reckon I would do this? It seems like the current behavior is to just ignore metadata that doesn't get used. Seems difficult to warn about places where `!explicit_size` isn't meaningful. Do you know of an example where this happens in llvm currently I could look at?
It would be pretty easy to add something to Verifier::visitGlobalValue.  I guess we don't actually do much verification for most metadata at the moment, though.  But see Verifier::verifyFunctionMetadata.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123010/new/

https://reviews.llvm.org/D123010



More information about the llvm-commits mailing list