[patch/asan] Use lvm.global_ctors instead of symbol name matching to find constructors

Reid Kleckner rnk at google.com
Tue May 6 17:07:10 PDT 2014

This is a good idea, because it will catch more bugs.  Consider this C++:

int foo();
template <int N> struct X { static int x; };
template <int N> int X<N>::x = foo();
int main() { return X<0>::x + X<2>::x + X<3>::x + X<4>::x; }

This will put 4 entries into llvm.global_ctors, none of which are called
_GLOBAL__*.  We should probably have an ASan integration test in
compiler-rt for this, when foo accesses some global in a different TU.

On the other hand, all this poisoning and unpoisoning may be expensive.  We
could batch up all the initializers of equal priority and merge them into
one initializer bracketed by calls to poison and unpoison.

On Tue, May 6, 2014 at 4:55 PM, Nico Weber <thakis at chromium.org> wrote:

> Hi,
> here's how the global_ctors version would look. I haven't tested this
> much (it's different in that it could now instrument multiple
> constructors per module).
> Feel free to play with this, and then land this with tweaks, land it
> as-is, or don't land it, up to you :-)
> Nico
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140506/d33c9374/attachment.html>

More information about the llvm-commits mailing list