bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/29216] New: [2.39 Regression] IFUNC function pointer reference e


From: hjl.tools at gmail dot com
Subject: [Bug ld/29216] New: [2.39 Regression] IFUNC function pointer reference equality failure
Date: Tue, 31 May 2022 21:03:02 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=29216

            Bug ID: 29216
           Summary: [2.39 Regression] IFUNC function pointer reference
                    equality failure
           Product: binutils
           Version: 2.39 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: hjl.tools at gmail dot com
  Target Milestone: ---

commit 68c4956b1401de70173848a6bdf620cb42fa9358 (refs/bisect/bad)
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Apr 26 09:08:54 2022 -0700

    x86: Properly handle function pointer reference

caused:

[hjl@gnu-tgl-3 tmp]$ cat x.c
#include <stdlib.h>

static inline void *
ifunc_one (int (*f1) (void))
{
  return f1;
}

extern int foo (void);

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

static void * foo_ifunc (void) __asm__ ("foo");
__asm__(".type foo, %gnu_indirect_function");

static void *
__attribute__ ((used))
foo_ifunc (void)
{
  return ifunc_one (one);
}

typedef int (*foo_p) (void);

foo_p foo_ptr = foo;

foo_p
__attribute__ ((noinline))
get_foo_p (void)
{
  return foo_ptr;
}

foo_p
__attribute__ ((noinline))
get_foo (void)
{
  return foo;
}

int
main (void)
{
  foo_p p;

  p = get_foo ();
  if (p != foo)
    abort ();
  if ((*p) () != -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-tgl-3 tmp]$ gcc -fPIC x.c 
[hjl@gnu-tgl-3 tmp]$ ./a.out 
Aborted (core dumped)
[hjl@gnu-tgl-3 tmp]$

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]