This is the mail archive of the
mailing list for the GCC project.
fPIC and %ebx
- From: Joy Mukherjee <jmukherj at csgrad dot cs dot vt dot edu>
- To: <gcc at gcc dot gnu dot org>
- Date: Wed, 14 Nov 2001 22:54:59 -0500 (EST)
- Subject: fPIC and %ebx
I have been trying to force my program compiled using -fPIC to use
a GOT of my own i.e. one I create during program execution. I copy the
entire program segment to a separate location and then change %ebx to
point to the location of the new GOT. The problem is that whenever, I call
a function, the value of %ebx is being reset to the original one at the
beginning of the function.
The assembly code shows that the compiler forces recalculation of
%ebx from the program counter at the beginning of every function. To be
more precise, %ebx is loaded with the present program counter value and
then the difference between the program counter and the original value of
%ebx is added to it. Is there anyway to get around this ? I mean how can I
avoid this reinitialisation of %ebx or what do I need to do to ensure that
this recalculation results in my changed %ebx and not the original one ?
I would be very greatful to anyone who can throw some light on
this . Thanking you in anticipation,
Deptt. of CS,
Blacksburg,VA - 24061.