This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc addresssanitizer in MIPS


> On Oct 28, 2013, at 1:36 AM, Jean Lee <xiaoyur347@gmail.com> wrote:
> 
> My port of addresssanitizer is based on GCC 4.8.1.
> I modify "asan_emit_stack_protection" function in gcc/asan.c for the
> following reason:
> Sometimes, the stack variable size > 32 Bytes, and after asan
> generates code to poison the shadow buffer,  it does clear some shadow
> buffer but not all before function return.
> So I use the way of poisoning to recover the shadow.
> Does any of you suffer the problem? It works fine for my platform now.

I don't have this issue with either n32 or n64 on mips64 implementation that we did here internally (Cavium) based on GCC 4.7.  Did you make sure that you make the frame grown down (is it up, I don't have access to the source right now)? 

Thanks,
Andrew Pinski 


> 
> about line 1050:
> #if 0 // I find some false positive for those code
>  for (l = length; l; l -= 2)
>    {
>      offset = base_offset + ((offsets[l - 1] - base_offset)
>     & ~(ASAN_RED_ZONE_SIZE - HOST_WIDE_INT_1));
>      if (last_offset + last_size != offset)
> {
>  shadow_mem = adjust_address (shadow_mem, VOIDmode,
>       (last_offset - prev_offset)
>>> ASAN_SHADOW_SHIFT);
>  prev_offset = last_offset;
>  asan_clear_shadow (shadow_mem, last_size >> ASAN_SHADOW_SHIFT);
>  last_offset = offset;
>  last_size = 0;
> }
>      last_size += base_offset + ((offsets[l - 2] - base_offset)
>  & ~(ASAN_RED_ZONE_SIZE - HOST_WIDE_INT_1))
>   - offset;
>    }
>  if (last_size)
>    {
>      shadow_mem = adjust_address (shadow_mem, VOIDmode,
>   (last_offset - prev_offset)
>>> ASAN_SHADOW_SHIFT);
>      asan_clear_shadow (shadow_mem, last_size >> ASAN_SHADOW_SHIFT);
>    }
> 
> #else
>  for (l = length; l; l -= 2)
>  {
>    if (l == 2)
>      cur_shadow_byte = ASAN_STACK_MAGIC_RIGHT;
>    offset = offsets[l - 1];
>    if ((offset - base_offset) & (ASAN_RED_ZONE_SIZE - 1))
>    {
>      HOST_WIDE_INT aoff
>        = base_offset + ((offset - base_offset)
>                 & ~(ASAN_RED_ZONE_SIZE - HOST_WIDE_INT_1));
>      shadow_mem = adjust_address (shadow_mem, VOIDmode,
>                       (aoff - prev_offset)
>>> ASAN_SHADOW_SHIFT);
>      prev_offset = aoff;
>      aoff += (1 << ASAN_SHADOW_SHIFT) << 2;
> 
>      asan_clear_shadow (shadow_mem, 4);
>      offset = aoff;
>    }
>    while (offset <= offsets[l - 2] - ASAN_RED_ZONE_SIZE)
>    {
>      shadow_mem = adjust_address (shadow_mem, VOIDmode,
>                       (offset - prev_offset)
>>> ASAN_SHADOW_SHIFT);
>      prev_offset = offset;
> 
>      asan_clear_shadow (shadow_mem, 4);
>      offset += ASAN_RED_ZONE_SIZE;
>    }
>  }
>  #endif


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]