Error on shared lib call to @local ifunc
authorAlan Modra <amodra@gmail.com>
Mon, 13 Jan 2014 03:21:16 +0000 (13:51 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 13 Jan 2014 04:34:15 +0000 (15:04 +1030)
commitc7e17e05b647f6233c2062d038e5421686217816
tree5a76b6781f9f40342b24ddd40ffa5b1e781a7ff6
parent1a4416c4c7f02a73652429f4e8e8e966f55e3e8b
Error on shared lib call to @local ifunc

On powerpc32, making ifuncs have non-default visibility in shared
libraries or pies can result in runtime failures.  The problem is that
if gcc is told that a given function has non-default visibility, then
calls to that function are assumed to be local (which is true) and
thus need not go via a plt call stub (which is false for ifunc).  If
the caller has no other reason to set up the got pointer (r30), code
won't be emitted to do so.  However, a pic plt call stub makes use of
r30 to load the plt entry.  So a call to an ifunc, which always needs
a plt entry, will fail.

This patch makes ld emit an error for the problem case, and allows
calls to non-default visibility ifuncs to work in normal executables.
I also fix some cases where ifuncs fail when using the old bss-plt.

* elf32-ppc.c (ppc_elf_check_relocs): For @local call to ifunc,
error when shared and force a plt call otherwise.
(ppc_elf_size_dynamic_sections): Don't emit DT_PPC_GOT unless
plt_type == PLT_NEW.
(ppc_elf_relocate_section): Add missing test to resolve ifuncs to
the appropriate call stub.
bfd/elf32-ppc.c