Proposal for STT_GNU_IFUNC and R_*_IRELATIVE

Ulrich Drepper drepper@redhat.com
Wed May 27 18:24:00 GMT 2009


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

H.J. Lu wrote:
> How to do you handle R_*_PC32 relocation to a locally defined
> STT_GNU_IFUNC symbol in dynamic and static executables?

When I compile the test code you sent yesterday I see this in the
executable:

000000000040050c <main>:
  40050c:       55                      push   %rbp
  40050d:       48 89 e5                mov    %rsp,%rbp
  400510:       bf fd ff ff ff          mov    $0xfffffffd,%edi
  400515:       e8 00 00 00 00          callq  40051a <main+0xe>
  40051a:       b8 00 00 00 00          mov    $0x0,%eax
  40051f:       c9                      leaveq
  400520:       c3                      retq


This is of course not going to work.  The program doesn't even contain a
R_*_IRELATIVE relocation.

Every call to an IFUNC must be indirect somewhere.  You cannot change
the relative jmp into an indirect one (opcode is too long).  Therefore,
as I explained before, you allocate and jump to a PLT slot.  The PLT
slot as a GOT entry and that GOT entry in modified by the R_*_IRELATIVE
relocation.

Of course something can be wrong with the code I get.  So, why don't you
take the time to actually explain what you see at the asm level.

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

iEYEARECAAYFAkodflIACgkQ2ijCOnn/RHSk0ACgqqWSCBZ8Mu+vmC1ELvtBeZWA
/I8AoKo14TajUZ8ovA0SUYBSkvEKBJLZ
=eYJl
-----END PGP SIGNATURE-----



More information about the Libc-alpha mailing list