[llvm-bugs] [Bug 42759] New: [PowerPC64] lld incorrectly optimizes ifunc TOC relocations

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 25 12:16:01 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42759

            Bug ID: 42759
           Summary: [PowerPC64] lld incorrectly optimizes ifunc TOC
                    relocations
           Product: lld
           Version: unspecified
          Hardware: Other
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: luporl at FreeBSD.org
                CC: llvm-bugs at lists.llvm.org, peter.smith at linaro.org

Consider the following C fragment:

void (*funcptr)(void) = my_ifunc;
(*funcptr)();


Where my_ifunc is an ifunc. When built with clang and linked with lld, the
program will call the ifunc resolver, instead of the function returned by it.

Inspecting the .o file, it can be seen that clang emits code to load the
pointer to my_ifunc from the TOC, which is patched by the dynamic linker or C
startup code (for static binaries).

The problem is that lld is optimizing this load from TOC, replacing it by an
addis/addi pair to get the function address. This is valid for regular
functions, but not for ifuncs.

The issue doesn't happen if --no-toc-optimize is passed to lld, or if the
program is linked with bfd. It also doesn't happen if the ifunc is defined in a
separate .so file.

I have a reproduce tar file, but it has 2.5 MB when compressed with xz, which
is over the 1000 KB attachment limit.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190725/c37abd6a/attachment.html>


More information about the llvm-bugs mailing list