This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: How to insert external global variable declarations and pointer assignment statements through GCC plugin GIMPLE pass
- From: Ian Lance Taylor <iant at google dot com>
- To: "Abhijit Nandy" <abhijit dot nandy at gmail dot com>
- Cc: "gcc" <gcc-help at gcc dot gnu dot org>
- Date: Tue, 14 Jun 2011 10:38:40 -0700
- Subject: Re: How to insert external global variable declarations and pointer assignment statements through GCC plugin GIMPLE pass
- References: <68C14D8B8C1E48DC8FE5F9DAB722DB7A@abhiPC> <mcrzkmbehqp.fsf@coign.corp.google.com> <E3044324D6DE4D22AAD744F98CFCBE17@abhiPC> <mcrr57fq6my.fsf@coign.corp.google.com> <F619BDBA45C7469FB092874D6CC9C6BB@abhiPC> <mcrhb7spc02.fsf@coign.corp.google.com> <84220E2299EC44BBBB8A67D9B09BBBE1@abhiPC>
"Abhijit Nandy" <abhijit.nandy@gmail.com> writes:
> 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.
A global extern declaration is not a definition. The variable needs to
be defined somewhere.
If your .c file has "extern char _binary_ccu_start;" you still need to
have some .c file which has "char _binary_ccu_start;", right?
Ian