aboutsummaryrefslogtreecommitdiffhomepage
path: root/x86_64/isel.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-12-13 14:21:22 +0100
committerlemon <lsof@mailbox.org>2025-12-13 14:24:30 +0100
commit854df54e1839c8b96d1aaa9aeaa32c2ebbf535f8 (patch)
treeba0d2d8b79300d0af2a53aeccd628111733ae7e8 /x86_64/isel.c
parent17e5a9f573b1a60e12ed60948f45f5992914d324 (diff)
fix position independent loads of function symbols.
For `extern int x[1];`, can use PCREL32 for &x. But for `extern int x(int)`, must use GOTREL, when not being called directly (that's PLT). Therefore the type of an external symbol (actually just whether it denotes a function) matters when deciding what kind of relocation to emit, so keep that information.
Diffstat (limited to 'x86_64/isel.c')
-rw-r--r--x86_64/isel.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/x86_64/isel.c b/x86_64/isel.c
index 5d373f3..67a4358 100644
--- a/x86_64/isel.c
+++ b/x86_64/isel.c
@@ -310,7 +310,7 @@ fuseaddr(union ref *r, struct block *blk, int *curi)
if (r->t != RTMP) return 0;
if (!aadd(&addr, blk, curi, *r)) return 0;
- if (isaddrcon(addr.base,0) && (ccopt.pic || (ccopt.pie && addr.index.bits))) {
+ if (isaddrcon(addr.base,0) && (ccopt.pic || (ccopt.pie && addr.index.bits) || conht[addr.base.i].isfunc)) {
/* pic needs to load from GOT */
/* pie cannot encode RIP-relative address with index register */
/* first load symbol address into a temp register */