This is the mail archive of the gcc-help@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: How to insert external global variable declarations and pointer assignment statements through GCC plugin GIMPLE pass


Yes you are right I am looking at a dump file.

My C input file is testcode.c and after I compile with the plugin enabled as :

gcc -fplugin=./test_plugin.so -Wall -fdump-tree-gimple -fdump-tree-all testcode.c molen_htx.c -o testcode

The molen_htx.c has the molen_elfset()

I get the following linker error :

root@slax:/mnt/f/Thesis/gcc-pluginelf# make testcode
cc -I/usr/lib/gcc/i486-slackware-linux/4.5.2/plugin/include -fPIC -Wall -c -o test_plugin.o test_plugin.c
gcc -shared test_plugin.o -o test_plugin.so
gcc -fplugin=./test_plugin.so -Wall -fdump-tree-gimple -fdump-tree-all testcode.c molen_htx.c -o testcode
plugin init test_plugin
testcode.c: In function 'main':
testcode.c:26:7: warning: unused variable 'q'
plugin init test_plugin
/tmp/ccLUccsU.o: In function `main':
testcode.c:(.text+0x82): undefined reference to `_binary_ccu_start' <---------------
collect2: ld returned 1 exit status
make: *** [testcode] Error 1



A dump file called testcode.c.220t.replace is produced which does not show the global declaration(if it is being inserted at all)


But the undefined reference implies that the global extern declaration was not inserted.

Thanks,
Abhi

-----Original Message----- From: Ian Lance Taylor
Sent: Tuesday, June 14, 2011 7:18 PM
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@gmail.com> writes:

I get the following output from it :

;; Function main (main)

main ()
{
 char * p.1;

<bb 2>:
.....
 p.1 = &_binary_ccu_start;
 molen_elfset (p.1);
....
}
------------------------------------------------------------------------------------

To recall I am trying to insert the following in a C program :

extern char _binary_ccu_start;

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

If you are looking at a dump file, then it seems to me that you are getting what you want. A dump file is not a C file; it doesn't list the extern declarations explicitly.

Let me know if I'm missing something.

Ian


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