Dereferencing of absolute pointers is broken on x86_64, eg: *(int*)NULL does not segfault but returns -4 instead *(char*)(-10L << 20) does not return 0x55 (vsyscall page, push rbp)
Unified · Split
| @@ -257,8 +257,7 @@ ST_FUNC void gen_addr64(int r, Sym *sym, int64_t c) · 256 unmodified lines | ||
| 257 | 257 | /* output constant with relocation if 'r & VT_SYM' is true */ |
| 258 | 258 | ST_FUNC void gen_addrpc32(int r, Sym *sym, int c) |
| 259 | 259 | { |
| 260 | − if (r & VT_SYM) | |
| 261 | − greloca(cur_text_section, sym, ind, R_X86_64_PC32, c-4), c=4; | |
| 260 | + greloca(cur_text_section, sym, ind, R_X86_64_PC32, 0); | |
| 262 | 261 | gen_le32(c-4); |
| 263 | 262 | } |
| 264 | 263 | |