mirror of
git://c9x.me/qbe.git
synced 2026-04-05 18:09:47 +00:00
Modify amd64 fixarg to fix calling constant addresses
On x86_64, direct calls are always PC-relative. This means that in order to call an absolute address, the call must be indirect. To accomplish this, update fixarg to introduce a temporary before emitting.
This commit is contained in:
parent
640c78d0da
commit
cf06ce159d
@ -96,6 +96,14 @@ fixarg(Ref *r, int k, Ins *i, Fn *fn)
|
||||
a.offset.sym.id = intern(buf);
|
||||
fn->mem[fn->nmem-1] = a;
|
||||
}
|
||||
else if (op == Ocall && r == &i->arg[0]
|
||||
&& rtype(r0) == RCon && fn->con[r0.val].type != CAddr) {
|
||||
/* use a temporary register so that we
|
||||
* produce an indirect call
|
||||
*/
|
||||
r1 = newtmp("isel", Kl, fn);
|
||||
emit(Ocopy, Kl, r1, r0, R);
|
||||
}
|
||||
else if (op != Ocopy && k == Kl && noimm(r0, fn)) {
|
||||
/* load constants that do not fit in
|
||||
* a 32bit signed integer into a
|
||||
|
||||
Loading…
Reference in New Issue
Block a user