mirror of
https://github.com/frida/tinycc
synced 2024-11-28 10:33:07 +03:00
Generate PIC for addresses of symbols.
This commit is contained in:
parent
7db1e69df2
commit
b8a32d8d40
19
x86_64-gen.c
19
x86_64-gen.c
@ -197,14 +197,6 @@ static void gen_addr64(int r, Sym *sym, int64_t c)
|
||||
gen_le64(c);
|
||||
}
|
||||
|
||||
/* output constant with relocation if 'r & VT_SYM' is true */
|
||||
static void gen_addr32(int r, Sym *sym, int c)
|
||||
{
|
||||
if (r & VT_SYM)
|
||||
greloc(cur_text_section, sym, ind, R_X86_64_32);
|
||||
gen_le32(c);
|
||||
}
|
||||
|
||||
/* output constant with relocation if 'r & VT_SYM' is true */
|
||||
static void gen_addrpc32(int r, Sym *sym, int c)
|
||||
{
|
||||
@ -317,9 +309,14 @@ void load(int r, SValue *sv)
|
||||
o(0xb8 + REG_VALUE(r)); /* mov $xx, r */
|
||||
gen_addr64(fr, sv->sym, sv->c.ull);
|
||||
} else {
|
||||
o(0xc748);
|
||||
o(0xc0 + REG_VALUE(r)); /* mov $xx, r */
|
||||
gen_addr32(fr, sv->sym, fc);
|
||||
if (fr & VT_SYM) {
|
||||
o(0x8d48);
|
||||
o(0x05 + REG_VALUE(r) * 8); /* lea xx(%rip), r */
|
||||
gen_addrpc32(fr, sv->sym, fc);
|
||||
} else {
|
||||
o(0xb8 + REG_VALUE(r)); /* mov $xx, r */
|
||||
gen_le32(fc);
|
||||
}
|
||||
}
|
||||
} else if (v == VT_LOCAL) {
|
||||
o(0x48 | REX_BASE(r));
|
||||
|
Loading…
Reference in New Issue
Block a user