Rajesh Paul wrote:
Hi,

I was trying to put in some code in a file . Make it a shared object (.so)
with PIC and am trying to generate some Relative Relocations
(R_XXX_RELATIVE) type. For verifying the same, I take the Elf Dump of the
generated object (.so) file using 'elfdump'.

Can you please suggest me a C code construct or a means which would
make/force the compiler/linker to generate some Relative Relocations for any
data/function objects defined in my source file.

Regards,
Rajesh


Might I suggest [EMAIL PROTECTED] as a place
more likely to have experience here.  This topic was just
covered; I've included the message here.

- Bart

--
Bart Smaalders                  Solaris Kernel Performance
[EMAIL PROTECTED]               http://blogs.sun.com/barts
--- Begin Message ---
Here's a quick example:

collage0021# elfdump -c data.so
collage0021# more data.c
static int local_var = 0;
int *global_data = &local_var;
collage0021# gcc -fpic -shared data.c -o data.so
collage0021# elfdump -r data.so | grep RELATIVE
 R_386_RELATIVE              0x105cc             .rel.data.rel.
 R_386_RELATIVE              0x105d0             .rel.data.rel.
collage0021# elfdump -r data.so | grep RELATIVE
collage0021# nm -xv data.so | grep 105d0
[63]    |0x000105d0|0x00000004|OBJT |GLOB |0    |20     |global_data
collage0021#

Notice that the RELATIVE relocation against 0x105d0 is against the 'global_data'
symbol.  So - it's going to adjust the value of '&local_data' (which
is already stored
there) with the offset of the library (data.so) when it's loaded into its final
location in memory.

_Mike_



On 2/21/07, bhushan verma <[EMAIL PROTECTED]> wrote:
Hi
can anyone give me an c example which produces R_386_RELATIVE type relocation
Thanks


This message posted from opensolaris.org
_______________________________________________
tools-linking mailing list
[EMAIL PROTECTED]




--
Michael Walker
[EMAIL PROTECTED]
_______________________________________________
tools-linking mailing list
[EMAIL PROTECTED]

--- End Message ---
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to