public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: kum <a.kumaresh@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: DSO: pc relative symbol address
Date: Fri, 19 Mar 2010 09:48:00 -0000	[thread overview]
Message-ID: <302c6e641003190237t51b81746ob43db174f2d08bab@mail.gmail.com> (raw)

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

             reply	other threads:[~2010-03-19  9:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-19  9:48 kum [this message]
2010-03-19 18:15 ` Ian Lance Taylor
2010-03-22  4:38   ` kum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=302c6e641003190237t51b81746ob43db174f2d08bab@mail.gmail.com \
    --to=a.kumaresh@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).