test.c
#include <stdio.h>
#pragma GCC visibility push(hidden)
void __attribute__((__weak__)) xxx(void)
{
printf("weak\n");
}
void call_func(void (*f)(void));
int main()
{
call_func(xxx);
return 0;
}
test1.c
#include <stdio.h>
#pragma GCC visibility push(hidden)
void xxx(void)
{
printf("default\n");
}
void call_func(void (*f)(void))
{
f();
}
opts:
arm32-clang test.c test1.c -fpic
result:
arm32-gcc test.c test1.c -fpic
result:
godbolt:
https://godbolt.org/z/jrT49YKM1
I believe this issue is closely related to how weak symbol function pointers are loaded. How can we fix this problem to align with GCC's behavior?
test.c
test1.c
opts:
arm32-clang test.c test1.c -fpic
result:
arm32-gcc test.c test1.c -fpic
result:
godbolt:
https://godbolt.org/z/jrT49YKM1
I believe this issue is closely related to how weak symbol function pointers are loaded. How can we fix this problem to align with GCC's behavior?