History

Use R_AARCH64_MOVW_UABS_G* instead of R_AARCH64_CALL26.

This is a work-around for TCC's linker, on AArch64, not building a PLT when TCC is invoked with "-run". Fixing the linker should be possible: it works on arm and x86_64, apparently.

Edmund Grimley Evans committed 10 years ago

Commit 07ca2df1 parent 7bd30a41 file · +14 −5Browse files

Unified · Split

arm64-gen.c+14−5
@@ -592,13 +592,22 @@ ST_FUNC void store(int r, SValue *sv) · 591 unmodified lines
592 592
593static void arm64_gen_bl_or_b(int b)593static void arm64_gen_bl_or_b(int b)
594{594{
595 // Currently TCC's linker does not generate a PLT when TCC is invoked
596 // with "-run". This means functions can be out of range if we try to
597 // call them in the usual way. Until the linker is fixed, work around
598 // this by using R_AARCH64_MOVW_UABS_G* relocations; see arm64_sym.
599 int avoid_call26 = 1;
600
595 if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {601 if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
596 assert(!b);602 assert(!b && (vtop->r & VT_SYM));
597 if (vtop->r & VT_SYM)603 if (avoid_call26) {
604 arm64_sym(30, vtop->sym, 0);
605 o(0xd63f03c0); // blr x30
606 }
607 else {
598 greloc(cur_text_section, vtop->sym, ind, R_AARCH64_CALL26);608 greloc(cur_text_section, vtop->sym, ind, R_AARCH64_CALL26);
599 else609 o(0x94000000); // bl .
600 assert(0);610 }
601 o(0x94000000); // bl .
602 }611 }
603 else612 else
604 o(0xd61f0000 | (uint32_t)!b << 21 | intr(gv(RC_R30)) << 5); // br/blr613 o(0xd61f0000 | (uint32_t)!b << 21 | intr(gv(RC_R30)) << 5); // br/blr

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t