[llvm-bugs] [Bug 48674] New: -static-pie doesn't work with IFUNC

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 5 15:54:56 PST 2021


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

            Bug ID: 48674
           Summary: -static-pie doesn't work with IFUNC
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: hjl.tools at gmail.com
                CC: i at maskray.me, llvm-bugs at lists.llvm.org,
                    smithp352 at googlemail.com

[hjl at 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 at 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 at 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 at gnu-cfl-2 ifunc-2]$

-- 
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/20210105/fb10a4fe/attachment.html>


More information about the llvm-bugs mailing list