* Global addressing
@ 2001-09-04 14:56 Joy Mukherjee
2001-09-04 20:33 ` Alexandre Oliva
0 siblings, 1 reply; 14+ messages in thread
From: Joy Mukherjee @ 2001-09-04 14:56 UTC (permalink / raw)
To: gcc
Hi !
I need to relocate all the global variables of a program to some
other address and then force the executable to use the relocated set
instead of the original one . The problem is that when I looked at the
assembly code generated, it seems that the compiler uses direct addressing
for such globals .
Is there anyway I can force the compiler to use indexed addressing
ONLY for all variables - local/global ? I am working on the Intel-Linux
plateform . I would really appreciate any help .
Joy.
******************************************************************************
JOY MUKHERJEE
OFFICE:
GRADUATE STUDENT
DEPTT. OF COMPUTER SCIENCE
MCBRYDE HALL
VIRGINIA TECH
BLACKSBURG , VA - 24061
PH. - (540) 231 5853
RESIDENCE:
1211 PROGRESS STREET
APT. # 7100 F
BLACKSBURG , VA - 24060
USA.
PH. - (540) 951 7771
Other e-mails : jmukherj@vt.edu
jmjee@lycos.com
******************************************************************************
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Global addressing
2001-09-04 14:56 Global addressing Joy Mukherjee
@ 2001-09-04 20:33 ` Alexandre Oliva
2001-09-06 11:29 ` Joy Mukherjee
0 siblings, 1 reply; 14+ messages in thread
From: Alexandre Oliva @ 2001-09-04 20:33 UTC (permalink / raw)
To: Joy Mukherjee; +Cc: gcc
On Sep 4, 2001, Joy Mukherjee <jmukherj@csgrad.cs.vt.edu> wrote:
> I need to relocate all the global variables of a program to some
> other address
Consider objcopy --change-addresses.
> Is there anyway I can force the compiler to use indexed addressing
> ONLY for all variables - local/global ?
Other than -fPIC?
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Global addressing
2001-09-04 20:33 ` Alexandre Oliva
@ 2001-09-06 11:29 ` Joy Mukherjee
2001-09-09 20:39 ` Alexandre Oliva
0 siblings, 1 reply; 14+ messages in thread
From: Joy Mukherjee @ 2001-09-06 11:29 UTC (permalink / raw)
To: Alexandre Oliva; +Cc: gcc
Dear Alexandre,
I thank you very much for your reply . It has indeed solved quite
a few of my problmes . I had not really tried out -fPICS earlier and it
seems to work . But is there any other way also to force indexed global
addressing ?
Thanking you once again ,
Sincerely,
Joy.
> On Sep 4, 2001, Joy Mukherjee
<jmukherj@csgrad.cs.vt.edu> wrote: >
> > I need to relocate all the global variables of a program to some
> > other address
>
> Consider objcopy --change-addresses.
>
> > Is there anyway I can force the compiler to use indexed addressing
> > ONLY for all variables - local/global ?
>
> Other than -fPIC?
>
> --
> Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
> Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
> CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
> Free Software Evangelist *Please* write to mailing lists, not to me
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Global addressing
2001-09-06 11:29 ` Joy Mukherjee
@ 2001-09-09 20:39 ` Alexandre Oliva
2001-09-10 14:28 ` Joy Mukherjee
0 siblings, 1 reply; 14+ messages in thread
From: Alexandre Oliva @ 2001-09-09 20:39 UTC (permalink / raw)
To: Joy Mukherjee; +Cc: gcc
On Sep 6, 2001, Joy Mukherjee <jmukherj@csgrad.cs.vt.edu> wrote:
> But is there any other way also to force indexed global
> addressing ?
I don't think there's any other mostly target-independent flag. Some
targets may offer flags to do it, but none of those I'm familiar
with do.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Global addressing
2001-09-09 20:39 ` Alexandre Oliva
@ 2001-09-10 14:28 ` Joy Mukherjee
2001-09-13 17:36 ` Alexandre Oliva
0 siblings, 1 reply; 14+ messages in thread
From: Joy Mukherjee @ 2001-09-10 14:28 UTC (permalink / raw)
To: Alexandre Oliva; +Cc: gcc, gcc-help
Hi! Just one more thing to ask - Is there any way I can get the beginning
and end addresses of the Global Offset Table ? The tag
_GLOBAL_OFFSET_TABLE_ points to somewhere in the middle of the .got
section so that both +ve and -ve offsets are possible , but I want to know
the exact addresses where the GOT begins and ends . How can I do that ?
Thank you so much for all your help .
Joy
******************************************************************************
JOY MUKHERJEE
OFFICE:
GRADUATE STUDENT
DEPTT. OF COMPUTER SCIENCE
MCBRYDE HALL
VIRGINIA TECH
BLACKSBURG , VA - 24061
PH. - (540) 231 5853
RESIDENCE:
1211 PROGRESS STREET
APT. # 7100 F
BLACKSBURG , VA - 24060
USA.
PH. - (540) 951 7771
Other e-mails : jmukherj@vt.edu
jmjee@lycos.com
******************************************************************************
On 10 Sep 2001, Alexandre Oliva wrote:
> On Sep 6, 2001, Joy Mukherjee <jmukherj@csgrad.cs.vt.edu> wrote:
>
> > But is there any other way also to force indexed global
> > addressing ?
>
> I don't think there's any other mostly target-independent flag. Some
> targets may offer flags to do it, but none of those I'm familiar
> with do.
>
> --
> Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
> Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
> CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
> Free Software Evangelist *Please* write to mailing lists, not to me
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Global addressing
2001-09-10 14:28 ` Joy Mukherjee
@ 2001-09-13 17:36 ` Alexandre Oliva
2001-09-13 19:27 ` Start and end of the GOT Joy Mukherjee
0 siblings, 1 reply; 14+ messages in thread
From: Alexandre Oliva @ 2001-09-13 17:36 UTC (permalink / raw)
To: Joy Mukherjee; +Cc: gcc, gcc-help
On Sep 10, 2001, Joy Mukherjee <jmukherj@csgrad.cs.vt.edu> wrote:
> I want to know the exact addresses where the GOT begins and ends.
> How can I do that ?
Look for `.got' in the output of `objdump -h'.
In case you want to do it at run-time, it depends on the platform.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me
^ permalink raw reply [flat|nested] 14+ messages in thread
* Start and end of the GOT
2001-09-13 17:36 ` Alexandre Oliva
@ 2001-09-13 19:27 ` Joy Mukherjee
2001-09-14 7:44 ` Alexandre Oliva
0 siblings, 1 reply; 14+ messages in thread
From: Joy Mukherjee @ 2001-09-13 19:27 UTC (permalink / raw)
To: Alexandre Oliva; +Cc: gcc, gcc-help
Alexandre,
Thanks again for your help . I do want to do it at runtime . I am
working on Red Hat Linux (glibc), intel x86, gcc 2.96 ( this I am not very
sure ) . Can you please tell me how this thing might work at runtime ?
Thanks again .
Joy.
Joy Mukherjee
Graduate Student,
Deptt. of CS,
Virginia Tech,
Blacksburg,VA - 24061.
On 13 Sep 2001, Alexandre Oliva wrote:
> On Sep 10, 2001, Joy Mukherjee <jmukherj@csgrad.cs.vt.edu> wrote:
>
> > I want to know the exact addresses where the GOT begins and ends.
> > How can I do that ?
>
> Look for `.got' in the output of `objdump -h'.
>
> In case you want to do it at run-time, it depends on the platform.
>
> --
> Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
> Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
> CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
> Free Software Evangelist *Please* write to mailing lists, not to me
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Start and end of the GOT
2001-09-13 19:27 ` Start and end of the GOT Joy Mukherjee
@ 2001-09-14 7:44 ` Alexandre Oliva
2001-09-14 17:33 ` Joy Mukherjee
0 siblings, 1 reply; 14+ messages in thread
From: Alexandre Oliva @ 2001-09-14 7:44 UTC (permalink / raw)
To: Joy Mukherjee; +Cc: gcc, gcc-help
On Sep 13, 2001, Joy Mukherjee <jmukherj@csgrad.cs.vt.edu> wrote:
> Thanks again for your help . I do want to do it at runtime . I am
> working on Red Hat Linux (glibc), intel x86
AFAIK, all you have to do is to get the value of ebx in a function
compiled with -fPIC.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Start and end of the GOT
2001-09-14 7:44 ` Alexandre Oliva
@ 2001-09-14 17:33 ` Joy Mukherjee
2001-09-17 15:17 ` Richard Henderson
0 siblings, 1 reply; 14+ messages in thread
From: Joy Mukherjee @ 2001-09-14 17:33 UTC (permalink / raw)
To: Alexandre Oliva; +Cc: gcc, gcc-help
True, but %ebx just contains the start address of the GOT. How do I get
the END address ? or in other words , how do I get its size ? Thank again
for your help .
Joy
Joy Mukherjee
Graduate Student,
Deptt. of CS,
Virginia Tech,
Blacksburg,VA - 24061.
On 14 Sep 2001, Alexandre Oliva wrote:
> On Sep 13, 2001, Joy Mukherjee <jmukherj@csgrad.cs.vt.edu> wrote:
>
> > Thanks again for your help . I do want to do it at runtime . I am
> > working on Red Hat Linux (glibc), intel x86
>
> AFAIK, all you have to do is to get the value of ebx in a function
> compiled with -fPIC.
>
> --
> Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
> Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
> CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
> Free Software Evangelist *Please* write to mailing lists, not to me
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Start and end of the GOT
2001-09-14 17:33 ` Joy Mukherjee
@ 2001-09-17 15:17 ` Richard Henderson
2001-09-17 15:36 ` Jakub Jelinek
0 siblings, 1 reply; 14+ messages in thread
From: Richard Henderson @ 2001-09-17 15:17 UTC (permalink / raw)
To: Joy Mukherjee; +Cc: Alexandre Oliva, gcc, gcc-help
On Fri, Sep 14, 2001 at 08:33:21PM -0400, Joy Mukherjee wrote:
> True, but %ebx just contains the start address of the GOT. How do I get
> the END address ? or in other words , how do I get its size ?
You can't.
r~
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Start and end of the GOT
2001-09-17 15:17 ` Richard Henderson
@ 2001-09-17 15:36 ` Jakub Jelinek
2001-09-17 15:53 ` Richard Henderson
0 siblings, 1 reply; 14+ messages in thread
From: Jakub Jelinek @ 2001-09-17 15:36 UTC (permalink / raw)
To: Richard Henderson, Joy Mukherjee, Alexandre Oliva, gcc, gcc-help
On Mon, Sep 17, 2001 at 03:17:52PM -0700, Richard Henderson wrote:
> On Fri, Sep 14, 2001 at 08:33:21PM -0400, Joy Mukherjee wrote:
> > True, but %ebx just contains the start address of the GOT. How do I get
> > the END address ? or in other words , how do I get its size ?
>
> You can't.
Well, assuming IA-32 and nobody playing with linker scripts, end will be
_DYNAMIC because .sdata2/.sbss2 sections are usually not used on IA-32.
Jakub
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Start and end of the GOT
2001-09-17 15:36 ` Jakub Jelinek
@ 2001-09-17 15:53 ` Richard Henderson
2001-09-17 16:08 ` H . J . Lu
0 siblings, 1 reply; 14+ messages in thread
From: Richard Henderson @ 2001-09-17 15:53 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Joy Mukherjee, Alexandre Oliva, gcc, gcc-help
On Tue, Sep 18, 2001 at 12:39:15AM +0200, Jakub Jelinek wrote:
> Well, assuming IA-32 and nobody playing with linker scripts, end will be
> _DYNAMIC because .sdata2/.sbss2 sections are usually not used on IA-32.
I urge you not to rely on this.
The NetBSD ld.so self-relocation code does (did, anyway) this, and it
is the reason that .dynamic is still where it is. Personally, I think
this is a bug in the NetBSD ld.so and should have been fixed rather
than wasting some 400 bytes of the small data area.
r~
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Start and end of the GOT
2001-09-17 15:53 ` Richard Henderson
@ 2001-09-17 16:08 ` H . J . Lu
2001-09-17 16:22 ` Richard Henderson
0 siblings, 1 reply; 14+ messages in thread
From: H . J . Lu @ 2001-09-17 16:08 UTC (permalink / raw)
To: Richard Henderson, Jakub Jelinek, Joy Mukherjee, Alexandre Oliva,
gcc, gcc-help
On Mon, Sep 17, 2001 at 03:53:33PM -0700, Richard Henderson wrote:
> On Tue, Sep 18, 2001 at 12:39:15AM +0200, Jakub Jelinek wrote:
> > Well, assuming IA-32 and nobody playing with linker scripts, end will be
> > _DYNAMIC because .sdata2/.sbss2 sections are usually not used on IA-32.
>
> I urge you not to rely on this.
>
> The NetBSD ld.so self-relocation code does (did, anyway) this, and it
> is the reason that .dynamic is still where it is. Personally, I think
> this is a bug in the NetBSD ld.so and should have been fixed rather
> than wasting some 400 bytes of the small data area.
>
Does that mean Linux also wastes 400 bytes? I'd like to get them back
for Linux.
H.J.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Start and end of the GOT
2001-09-17 16:08 ` H . J . Lu
@ 2001-09-17 16:22 ` Richard Henderson
0 siblings, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2001-09-17 16:22 UTC (permalink / raw)
To: H . J . Lu; +Cc: Jakub Jelinek, Joy Mukherjee, Alexandre Oliva, gcc, gcc-help
On Mon, Sep 17, 2001 at 04:08:37PM -0700, H . J . Lu wrote:
> Does that mean Linux also wastes 400 bytes? I'd like to get them back
> for Linux.
Yes, but do not uglify the linker scripts even more with
such port-specific hacks. 400 bytes isn't worth that.
r~
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2001-09-17 16:22 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-04 14:56 Global addressing Joy Mukherjee
2001-09-04 20:33 ` Alexandre Oliva
2001-09-06 11:29 ` Joy Mukherjee
2001-09-09 20:39 ` Alexandre Oliva
2001-09-10 14:28 ` Joy Mukherjee
2001-09-13 17:36 ` Alexandre Oliva
2001-09-13 19:27 ` Start and end of the GOT Joy Mukherjee
2001-09-14 7:44 ` Alexandre Oliva
2001-09-14 17:33 ` Joy Mukherjee
2001-09-17 15:17 ` Richard Henderson
2001-09-17 15:36 ` Jakub Jelinek
2001-09-17 15:53 ` Richard Henderson
2001-09-17 16:08 ` H . J . Lu
2001-09-17 16:22 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).