linkers don't treat relocations using symindex 0 (undefined) very well, it can't be misused as indicator for an absolute number. Just don't bother with special casing this, rather emit an indirect call/jump right away. ARM64 needs the same (and didn't handle calls via constant absolute func pointers before). The testcase as is doesn't fail without the patch, it actually needs separate compilation (to -fPIC .o file, then to shared lib) to fail.
Showing the changes to tests/tests2/07_function.c (1 of 3 files). Show all
Unified · Split
| @@ -15,6 +15,11 @@ void qfunc() · 14 unmodified lines | |||
| 15 | printf("qfunc()\n"); | 15 | printf("qfunc()\n"); |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | void zfunc() | ||
| 19 | { | ||
| 20 | ((void (*)(void))0) (); | ||
| 21 | } | ||
| 22 | |||
| 18 | int main() | 23 | int main() |
| 19 | { | 24 | { |
| 20 | printf("%d\n", myfunc(3)); | 25 | printf("%d\n", myfunc(3)); |