public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Ulrich Drepper <drepper@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: "H.J. Lu" <hongjiu.lu@intel.com>,
	Glibc hackers <libc-hacker@sources.redhat.com>,
	binutils@sources.redhat.com
Subject: Re: Preliminary prelink IFUNC support (x86-64 only so far), some binutils IFUNC issues
Date: Sat, 13 Jun 2009 06:01:00 -0000	[thread overview]
Message-ID: <4A3340A6.8020107@redhat.com> (raw)
In-Reply-To: <20090612160251.GJ3101@sunsite.ms.mff.cuni.cz>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jakub Jelinek wrote:
> On the attached ifunctest.c gcc -O2 -o ifunctest{,.c} compiles/links, but
> no R_*_IRELATIVE relocation is emitted and not surprisingly it crashes
> at runtime.  Prelink testsuite contains similar testcase, just using
> .globl or .globl/.hidden, instead of .local.  I'd say .local @gnu_indirect_function
> symbols should be supported as well.

Indeed, there is no reason why .local symbols shouldn't be supported.



> The other issue can be seen with:
> gcc -O2 -fpic -shared -o ifunc3lib1.{so,c}
> gcc -O2 -o ifunc3 ./ifunc3lib1.so
> ./ifunc3lib1
> Here, &lib1t3 in the binary resolves to a .plt slot in the binary, while
> &lib1t3 in the shared library resolves to the actual address the ifunc
> returned.
> Not sure what exactly we want to do here, but the function pointers should
> be the same.

It's tricky alright.  There really isn't a good answer for this.  The
existing behavior is the only sensible solution.  One could try to make
things more complicated by changing the linker to associate the symbol
with the PLT slot and somehow allow ld.so to recognize such symbols, but
I think it's not worth it.

This all comes about only because IFUNCs are used in situations where
they really were not meant to be used.  IFUNC are supposed to be
definitions in DSOs which can be used in place of FUNC symbols.  This
will work without changes to any semantics.

In your test case you're creating and IFUNC symbol in the executable.
While I have no problem with supporting it this does mean the program
author take responsibility for doing this.  I think we can in this case
very well live with the difference in function addresses.

Therefore I suggest to leave this case and just document it.

- --
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkozQKYACgkQ2ijCOnn/RHS7ggCeIAD4keHAfellDswGieDBNSAX
/AgAoJKzcpoIcLyY25cJAfJ3FirrDd9k
=77gy
-----END PGP SIGNATURE-----

      reply	other threads:[~2009-06-13  6:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-12 16:03 Jakub Jelinek
2009-06-13  6:01 ` Ulrich Drepper [this message]

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=4A3340A6.8020107@redhat.com \
    --to=drepper@redhat.com \
    --cc=binutils@sources.redhat.com \
    --cc=hongjiu.lu@intel.com \
    --cc=jakub@redhat.com \
    --cc=libc-hacker@sources.redhat.com \
    /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).