Help with building ADDR_EXPR node

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I am a student trying to write a plugin that will insert checks before
all dereferences (similar to mudflap). However, I am having trouble
with building addr_expr nodes for such checks.

My check function accepts three parameters: the value being
dereferenced, the size of the object and the address in memory. I am
using the following two lines to get the third address parameter.

addr = build1 (ADDR_EXPR, build_pointer_type (type), t); // t is the
ARRAY_REF node
fold_convert_loc(location, ptr_type_node, addr); // type case to void *

However, this is failing whenever the array_ref contains a
non-constant expression, say like a[i+1]. The specific failure is
inside the expand_expr_real_1 method in the file expr.c. Looks like
such non-constant indices are not allowed at this stage in the
compilation (I've inserted the pass just before lowering to RTL
happens).

My question is, what would be the right way to get the address? I am
looking for something that will preferably work for all dereferences
like MEM_REF, INDIRECT_REF etc.

Appreciate any help on this one.

Thanks,
Zahed


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux