https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114115
--- Comment #1 from Sam James <sjames at gcc dot gnu.org> ---
One of the xz developers, Jia Tan, has kindly minimised it to not need
BIND_NOW. I've adapted it a bit to cleanup flags and warnings.
I can reproduce it with the following, at least:
```
#!/bin/sh
gcc-14 -O2 -march=znver2 -fvisibility=hidden -fPIC -fprofile-update=atomic
-fprofile-dir=$(pwd) -fprofile-generate=$(pwd) -c test.c -o test.o -Wall
-Wextra
gcc-14 -o libapp.so test.o -shared -Wl,-z,now -fPIC -lgcov
gcc-14 -o app main.c -lgcov -L. -lapp
LD_LIBRARY_PATH=. ./app
```
main.c:
```
#include <stdio.h>
extern int func();
int main(void)
{
printf( "Hello world %p\n", func);
return 0;
}
```
test.c:
```
__attribute__((visibility("default")))
void *foo_ifunc2() __attribute__((ifunc("foo_resolver")));
__attribute__((visibility("default")))
void bar(void)
{
}
static int f3()
{
return 5;
}
__attribute__((visibility("default")))
void (*foo_resolver(void))(void)
{
f3();
return bar;
}
__attribute__((optimize("O0")))
__attribute__((visibility("default")))
int func()
{
foo_ifunc2();
return 0;
}
```