* DSO: pc relative symbol address
@ 2010-03-19 9:48 kum
2010-03-19 18:15 ` Ian Lance Taylor
0 siblings, 1 reply; 3+ messages in thread
From: kum @ 2010-03-19 9:48 UTC (permalink / raw)
To: gcc-help
Hi,
Consider the scrap of code
static int my_foo1(int i)
{...}
int (*my_foo)(int) = my_foo1;
...
The compiler emits code like this (excerpt from .s)
...
lw $2,%got(my_foo1)($28)
...
There are no direct invocation of my_foo1. What prevents the compiler
from emitting a PC relative address to store in my_foo? Something like
lw $2, PC - <offset>
I guess that this offset is compile-time known quantity. Kindly enlighten me.
If this is possible what compile option(s) turns it on? Is it possible
to do this optimization while building (elf) shared objects too?
Thanks for clearing my ignorance,
kumaresh
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: DSO: pc relative symbol address
2010-03-19 9:48 DSO: pc relative symbol address kum
@ 2010-03-19 18:15 ` Ian Lance Taylor
2010-03-22 4:38 ` kum
0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2010-03-19 18:15 UTC (permalink / raw)
To: kum; +Cc: gcc-help
kum <a.kumaresh@gmail.com> writes:
> There are no direct invocation of my_foo1. What prevents the compiler
> from emitting a PC relative address to store in my_foo? Something like
> lw $2, PC - <offset>
You need to get the address of my_foo1 into $2. Using a PC relative
value only works if your processor has a PC-relative load instruction.
Not all processors have such an instruction. If your processor has
one and gcc is not using it, then this may be a bug.
Ian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: DSO: pc relative symbol address
2010-03-19 18:15 ` Ian Lance Taylor
@ 2010-03-22 4:38 ` kum
0 siblings, 0 replies; 3+ messages in thread
From: kum @ 2010-03-22 4:38 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: gcc-help
I am on mips and it neither supports PC relative load nor the PC can
be read . You are correct, I should have looked up MIPS addressing
modes before coming here... Thanks Ian.
kumaresh
On Fri, Mar 19, 2010 at 9:20 PM, Ian Lance Taylor <iant@google.com> wrote:
> kum <a.kumaresh@gmail.com> writes:
>
>> There are no direct invocation of my_foo1. What prevents the compiler
>> from emitting a PC relative address to store in my_foo? Something like
>> lw $2, PC - <offset>
>
> You need to get the address of my_foo1 into $2. Using a PC relative
> value only works if your processor has a PC-relative load instruction.
> Not all processors have such an instruction. If your processor has
> one and gcc is not using it, then this may be a bug.
>
> Ian
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-22 1:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-19 9:48 DSO: pc relative symbol address kum
2010-03-19 18:15 ` Ian Lance Taylor
2010-03-22 4:38 ` kum
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).