This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Effects of Static Local Variable Relocations not reduced to Section Symbols?
- From: Narendra Kiran Chinnam <narendrakiran at yahoo dot co dot in>
- To: binutils at sources dot redhat dot com
- Date: Fri, 14 May 2004 15:22:53 +0100 (BST)
- Subject: Effects of Static Local Variable Relocations not reduced to Section Symbols?
Due to a project Iam working on, I need to make sure
that the local static variable relocations are not
reduced to section symbols.
For eg,
ex.c
-----
static s1=5;
static s2;
main()
{
static int s3 = 1;
static int s4;
s1=1;
s2=2;
s3=3;
s4=4;
}
[root@localhost gasTesting]# gcc -c ex.c
[root@localhost gasTesting]# readelf -r ex.o
Relocation section '.rel.text' at offset 0x334
contains 5 entries:
Offset Info Type Sym.Value Sym.
Name
00000012 00000b01 R_386_32 00000004 i
0000001c 00000301 R_386_32 00000000 .data
00000026 00000401 R_386_32 00000000 .bss
00000030 00000301 R_386_32 00000000 .data
0000003a 00000401 R_386_32 00000000 .bss
When the same code is compiled with the modified gas,
I could watch the static variable names in the
relocation information just as in the case of global
variables.
Relocation section '.rel.text' at offset 0x334
contains 5 entries:
Offset Info Type Sym.Value Sym.
Name
00000012 00000b01 R_386_32 00000004 i
0000001c 00000501 R_386_32 00000000 s1
00000026 00000801 R_386_32 00000004 s2
00000030 00000601 R_386_32 00000004 s3.0
0000003a 00000701 R_386_32 00000000 s4.1
I have modified 'symbols.c' to achieve this
int
S_FORCE_RELOC (s)
symbolS *s;
{
if (LOCAL_SYMBOL_CHECK (s))
return ((struct local_symbol *) s)->lsy_section ==
undefined_section;
return ((s->bsym->flags & BSF_WEAK) != 0
|| (EXTERN_FORCE_RELOC
&& (s->bsym->flags & BSF_GLOBAL) != 0)
|| s->bsym->section == undefined_section
|| bfd_is_com_section (s->bsym->section)
|| 1)); //MY STUFF
}
I was successful running some sample programs compiled
with the modified gas, but apache crashed giving
segmentation fault (seemed to went wrong in ld.so but
not sure). Does this modification have any side
effects?
Thanks, in advance.
________________________________________________________________________
Yahoo! India Matrimony: Find your partner online. http://yahoo.shaadi.com/india-matrimony/