x86-64: Fix calls via absolute function pointers

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.
This commit is contained in:
Michael Matz
2018-07-02 01:54:45 +02:00
parent 65c7f19deb
commit d79caa9ff6
3 changed files with 11 additions and 13 deletions

View File

@@ -15,6 +15,11 @@ void qfunc()
printf("qfunc()\n");
}
void zfunc()
{
((void (*)(void))0) ();
}
int main()
{
printf("%d\n", myfunc(3));