[llvm-commits] AddressSanitizer, first patch

John Criswell criswell at illinois.edu
Fri Sep 9 08:21:25 PDT 2011


On 9/8/11 7:57 PM, Kostya Serebryany wrote:
>
>
>
>     A couple review comments:
>
>     AddressSanitizer::appendToGlobalCtors is messy at best; 
>
>
> Agree (the code is stolen from some other part of LLVM and fixed to 
> actually work).
>
>     is there
>     really no better way to get the asan init function to run when it
>     needs to?
>
>
> I see no other way other than to append to llvm.global_ctors.
> Given that I didn't find whether LLVM guaranties the particular order 
> of CTOR execution, I have to call them twice, at the beginning and at 
> the end of llvm.global_ctors
> Suggestions?

SAFECode also adds calls in llvm.global_ctors in 
lib/InsertPoolChecks/RegisterRuntimeInitializer.cpp (line 144).  At the 
time I wrote the code, ctor priorities were not honored as documented in 
the Language Reference Manual.  Through experimentation, I determined 
that they were executed in one order on Linux and another on Mac OS X, 
and the code in RegisterRuntimeInitializer.cpp uses that information.

That said, I seem to recall seeing a commit recently that may have fixed 
the problem with ctor priority numbers.  Has that, in fact, been fixed?  
If so, it would be better to rely upon the documented priority numbers 
instead of on undocumented behavior observed in the wild.
:)

-- John T.


>
>     Please get rid of blockHasException and the dependent code; the
>     eh_exception intrinsic is going away very soon, and you shouldn't run
>     into similar issues with the new exception handling framework.
>
>
> Done.
>
>
>     +  GlobalValue *asan_mapping_offset =
>     +      new GlobalVariable(M, IntPtrTy, true,
>     GlobalValue::LinkOnceODRLinkage,
>     +                     ConstantInt::get(IntPtrTy, 1ULL <<
>     MappingOffsetLog),
>     +                     "__asan_mapping_offset");
>     +  GlobalValue *asan_mapping_scale =
>     +      new GlobalVariable(M, IntPtrTy, true,
>     GlobalValue::LinkOnceODRLinkage,
>     +                         ConstantInt::get(IntPtrTy, MappingScale),
>     +                         "__asan_mapping_scale");
>
>     If you use WeakLinkage for these, you won't need the fake loads.
>
>
> Surprisingly these globals *were* optimized away at -O3, at least at 
> some point.
> Dropped the fake loads for now.
>
>
>     -Eli
>
>
>
>
> _______________________________________________
> 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/20110909/1ac8bf84/attachment.html>


More information about the llvm-commits mailing list