History

Generate PIC for addresses of symbols.

Shinichiro Hamaji committed 17 years ago

Commit b8a32d81 parent 7db1e691 file · +8 −11Browse files

Unified · Split

x86_64-gen.c+8−11
@@ -197,14 +197,6 @@ static void gen_addr64(int r, Sym *sym, int64_t c) · 196 unmodified lines
197197 gen_le64(c);
198198 }
199199
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−
208200 /* output constant with relocation if 'r & VT_SYM' is true */
209201 static void gen_addrpc32(int r, Sym *sym, int c)
210202 {
@@ -317,9 +309,14 @@ void load(int r, SValue *sv) · 106 unmodified lines
317309 o(0xb8 + REG_VALUE(r)); /* mov $xx, r */
318310 gen_addr64(fr, sv->sym, sv->c.ull);
319311 } 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+ }
323320 }
324321 } else if (v == VT_LOCAL) {
325322 o(0x48 | REX_BASE(r));

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