This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Section attribute to local external variable
- From: chandrakala chavva <cchavva at yahoo dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 13 Jan 2005 09:40:41 -0800 (PST)
- Subject: Section attribute to local external variable
I configured the toolchain for mips64-elf target and
when i compiled the following testcases, the compiler
generates relocation truncated to fix error message.
def.c
int abc __attribute__ ((section (".ABC")));
main()
{
printf ("main: value of abc is %d\n", abc = 10);
foo ();
return 0;
}
use.c
foo ()
{
int abc;
abc = 20;
printf ("foo: The initial value of abc is %d\n",
abc);
{
extern int abc;
printf ("foo: The value of abc has been changed
%d\n", abc);
}
printf ("foo: The final value of abc is %d\n",
abc);
}
$ mips64-elf-gcc def.c use.c -Tidt.ld
generates this error message
/tmp/ccSaSWo0.o(.text+0x30): In function `foo':
: relocation truncated to fit: R_MIPS_GPREL16 abc
collect2: ld returned 1 exit status
The compiler generates gp_rel code for the local
external variable in use.c. But to use gp_rel
optimized code i need to add section attribute to
local external variable as defined in the definition.
If i change the testcase use.c to
foo ()
{
int abc;
abc = 20;
printf ("foo: The initial value of abc is %d\n",
abc);
{
extern int abc __attribute__ ((section
(".ABC")));
printf ("foo: The value of abc has been changed
%d\n", abc);
}
printf ("foo: The final value of abc is %d\n",
abc);
}
The compiler generate the following error message.
use.c: In function `foo':
use.c:10: error: section attribute cannot be specified
for local variables
Here is the patch to fix this problem. Please let me
know it is okay to apply or not.
Thanks
Chandra
__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail