Unified · Split
| @@ -197,14 +197,6 @@ static void gen_addr64(int r, Sym *sym, int64_t c) · 196 unmodified lines | ||
| 197 | 197 | gen_le64(c); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | −/* output constant with relocation if 'r & VT_SYM' is true */ | |
| 201 | −static void gen_addr32(int r, Sym *sym, int c) | |
| 202 | −{ | |
| 203 | − if (r & VT_SYM) | |
| 204 | − greloc(cur_text_section, sym, ind, R_X86_64_32); | |
| 205 | − gen_le32(c); | |
| 206 | −} | |
| 207 | − | |
| 208 | 200 | /* output constant with relocation if 'r & VT_SYM' is true */ |
| 209 | 201 | static void gen_addrpc32(int r, Sym *sym, int c) |
| 210 | 202 | { |
| @@ -317,9 +309,14 @@ void load(int r, SValue *sv) · 106 unmodified lines | ||
| 317 | 309 | o(0xb8 + REG_VALUE(r)); /* mov $xx, r */ |
| 318 | 310 | gen_addr64(fr, sv->sym, sv->c.ull); |
| 319 | 311 | } else { |
| 320 | − o(0xc748); | |
| 321 | − o(0xc0 + REG_VALUE(r)); /* mov $xx, r */ | |
| 322 | − gen_addr32(fr, sv->sym, fc); | |
| 312 | + if (fr & VT_SYM) { | |
| 313 | + o(0x8d48); | |
| 314 | + o(0x05 + REG_VALUE(r) * 8); /* lea xx(%rip), r */ | |
| 315 | + gen_addrpc32(fr, sv->sym, fc); | |
| 316 | + } else { | |
| 317 | + o(0xb8 + REG_VALUE(r)); /* mov $xx, r */ | |
| 318 | + gen_le32(fc); | |
| 319 | + } | |
| 323 | 320 | } |
| 324 | 321 | } else if (v == VT_LOCAL) { |
| 325 | 322 | o(0x48 | REX_BASE(r)); |