Re: How to insert external global variable declarations and pointer assignment statements through GCC plugin GIMPLE pass

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

 



Hi Ian,

Thanks for the pointers. I have been trying to make a simple VAR_DECL using the following call :

tree type_node = make_node(POINTER_TYPE);
//TYPE_NAME(type_node) = type_id;
tree var_decl = build0(VAR_DECL, type_node);

I was using this post as a guide :
http://gcc.gnu.org/ml/gcc/2007-01/msg00536.html

But I get a segmentation fault :
testcode.c: In function 'main':
testcode.c:26:7: warning: unused variable 'q'
*** WARNING *** there are active plugins, do not report this as a bug unless you
can reproduce it without enabling any plugins.
Event                            | Plugins
PLUGIN_ATTRIBUTES                | test_plugin
testcode.c:33:1: internal compiler error: Segmentation fault

Can someone please help me out on how to complete the variable declaration and gimplify it.

-------------------

What I am attempting to do is insert the assignment statement in main() as follows(the global extern declaration also needs to be inserted but I can work it out afterwards):

extern char _binary_ccu_start;

int main (int argc, char **argv)
{
....
   char *p = &_binary_ccu_start;
...
}

Thanks,
Abhi

-----Original Message----- From: Ian Lance Taylor
Sent: Wednesday, May 25, 2011 2:39 AM
To: Abhijit Nandy
Cc: gcc
Subject: Re: How to insert external global variable declarations and pointer assignment statements through GCC plugin GIMPLE pass

"Abhijit Nandy" <abhijit.nandy@xxxxxxxxx> writes:

This is ok but I am unable to figure out how to insert a statement
like the following in global scope:
extern char _binary_ccu_start;

or to make an assigment like the following inside main :
char *p = &_binary_ccu_start;

Is this possible to do using a plugin ?

You need to create a VAR_DECL with TREE_STATIC set to 1 and pass it to
rest_of_decl_compilation.  Then you can get an expression which takes it
address by passing the decl to build_fold_addr_expr.

Ian


[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