<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57851>57851</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            PPC64 segfault using ifunc with -static and -pie
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          adalava
      </td>
    </tr>
</table>

<pre>
    While investigating a problem with ifunc on FreeBSD/PPC64 kernel I came with a example code[1] that crashes with segmentation fault on FreeBSD. The key appears to be the combination of `-static` and `-pie` flags. The binary works if linked with GNU BFD (`-fuse-ld=bfd`)

On Linux PPC64 the binary works fines, but clang isn't actually producing a PIE binary, and it warns that -pie argument is not being used.

Results:

| Build command | Result |
|---------|-----------|
| CC=clang CFLAGS="-fuse-ld=lld" make && ./ifunc2_static | OK |
| CC=clang CFLAGS="-pie -fuse-ld=lld" make && ./ifunc2_static | SEGFAULT |
|CC=clang CFLAGS="-pie -fuse-ld=bfd" make && ./ifunc2_static | OK |

I'm always availabe on IRC as adalava and I'll be happy to do any test or provide a FreeBSD VM. Thanks!

[1] https://people.freebsd.org/~alfredo/tmp/ifunc-crash.tar.gz



</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydVE1v2zAM_TX2hYiRKLFdH3xok6Yo1q3Fuo_jQFuMrUWWA0tumv36UXK7pTttCwxFoskn8vHRVS9P5ddWaQJlnsg61aBTpgGEw9BXmjo4KteC2o2mht7AdiC6etxEYvvwsM5WsKfBkIZbqLGjyReBnrE7MGTdS4rSq0WUbsC16KAe0LZkJz9LTUfG8X2Mu8NRu7MLEvjUEqOfAA8HwsGC66EihvGwXaXMFNfvIMrmM-that4BGhksB0X-uNPY2AnMxwwnOPbD3nJBoJXZk5xyufnwGa62G4jEhQ_ejZZmWkbLTbWTbIhEEc030fxyWu8N3CkzPsPEgfsTfKcM2UisoRq5Zo3Mp7ImErkDrN2IWp88vXKsJ6ofbq9fAHyQr0A5OOJg7ESbLwZwaEbPF0OB6R2T4YM5UZmc5_aRLDNpo-XluTXK13A1Ki09eV3giC2Tr9_-8pq9_s734fQbaL1mYqay1tu7y5tHPkZCnLGmeRUCOtwTU5rxAwlLJqhIfJuaFTK4fwd_Be0J-B_8x-ub7eXnu09vbvnLS3zr_72IsN5yrztAfcSTBXxCpZG1y3K9_cj9ZZNEzebQau-rtdd2y1I_eZ3Lnt_wjucR-sFL5UlJVsDrcMCX917SaPasssWbPr9MW-vcIWhAbPk5UM_jmOw4urIy6YfG2_Nr1GySPR9cd3gtbRaGNHE4JM2PN9hhjalcZNkyK7KVSGNZLmWxLDB2ymkqp3ngwZ7GebReotO3I4zZy5yGuj3d8Tjo8m2uDfuNVcIy5YPWT69_M2bhO9XOp2nt6Odrm-YX6SJuS0G0kHWRYl3UGS4EpmleLdMKq1WVk5jHnn5tS2aHO2roCAGC98xVrEoxF2JeiPkiT5erNMlEWmWiSIu8ytPFhYhWc-q4h4nPw7MXD2VIqRobyy-1ss7-fonWqsYQhesYH0fX9kP50vM4XF2G1H8CB8KxhA">