[LLVMdev] can GlobalAlias point to a middle of a structure?

Kostya Serebryany kcc at google.com
Mon Jun 20 03:53:28 PDT 2011


Nick, Duncan,

Thank you for your replies.
I ended up using only right redzone for globals -- this seems to work.
It may miss left out-of-bound accesses (underruns) in rare cases, but I can
live with that.

--kcc


On Fri, Jun 17, 2011 at 10:42 PM, Duncan Sands <baldrick at free.fr> wrote:

> Hi Kostya,
>
> > In order to find out-of-bound accesses to global objects with
> AddressSanitizer
> > (http://code.google.com/p/address-sanitizer/wiki/AddressSanitizer)
> > I need to create redzones to the left and to the right of every global
> variable.
> >
> > I tried the following:
> > Before:
> >    @Extern = global [10 x i8] zeroinitializer, align 1
> > After:
> >    %0 = type { [32 x i8], [10 x i8], [54 x i8] }
> >    @Extern_asan_redzone = global %0 zeroinitializer, align 1
> >    @0 = global [10 x i8] zeroinitializer, align 1 << the old variable
> >    @Extern = alias getelementptr inbounds (%0* @Extern_asan_redzone, i32
> 0, i32 1)
> > I.e. I created a global struct @Extern_asan_redzone of 3 elements and an
> > alias @Extern that points to the middle element of this struct.
>
> this is not currently possible.  You are not the first person to ask for
> this.
> If targets support it (I don't know if any do) then perhaps it can be
> added.
>
> Ciao, Duncan.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110620/6e32d1c6/attachment.html>


More information about the llvm-dev mailing list