This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

DSO: pc relative symbol address


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]