<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - -static-pie doesn't work with IFUNC"
   href="https://bugs.llvm.org/show_bug.cgi?id=48674">48674</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-static-pie doesn't work with IFUNC
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>ELF
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>hjl.tools@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>i@maskray.me, llvm-bugs@lists.llvm.org, smithp352@googlemail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>[hjl@gnu-cfl-2 ifunc-2]$ cat ifuncmain6pie.c
#include <stdlib.h>

typedef int (*foo_p) (void);

static int
one (void)
{
  return -30;
}

int foo (void) __attribute__ ((ifunc ("foo_ifunc")));

foo_p foo_ptr = foo;

void *
foo_ifunc (void)
{
  return one;
}

extern int foo (void);
extern int call_foo (void);
extern foo_p get_foo_p (void);

int
main (void)
{
  foo_p p;

  if (call_foo () != -30)
    abort ();

  p = get_foo_p ();
  if (p != foo)
    abort ();
  if ((*p) () != -30)
    abort ();

  if (foo_ptr != foo)
    abort ();
  if ((*foo_ptr) () != -30)
    abort ();
  if (foo () != -30)
    abort ();

  return 0;
}
[hjl@gnu-cfl-2 ifunc-2]$ cat ifuncmod6.c
extern int foo (void);

typedef int (*foo_p) (void);

extern foo_p foo_ptr;

foo_p
get_foo_p (void)
{
  return foo_ptr;
}

int
call_foo (void)
{
  return foo ();
}
[hjl@gnu-cfl-2 ifunc-2]$ make
gcc -fPIE   -c -o ifuncmain6pie.o ifuncmain6pie.c
gcc -fPIE   -c -o ifuncmod6.o ifuncmod6.c
gcc -static-pie -o x.ld ifuncmain6pie.o ifuncmod6.o
gcc -fuse-ld=lld -static-pie -o x.lld ifuncmain6pie.o ifuncmod6.o
./x.ld
./x.lld
make: *** [Makefile:14: all] Segmentation fault (core dumped)
[hjl@gnu-cfl-2 ifunc-2]$</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>