mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-15 05:20:06 +08:00
gen_addrpc32: absolute ptr needs *ABS* relocation
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)
This commit is contained in:
parent
078d8c2c5a
commit
870271ea07
@ -257,8 +257,7 @@ ST_FUNC void gen_addr64(int r, Sym *sym, int64_t c)
|
||||
/* output constant with relocation if 'r & VT_SYM' is true */
|
||||
ST_FUNC void gen_addrpc32(int r, Sym *sym, int c)
|
||||
{
|
||||
if (r & VT_SYM)
|
||||
greloca(cur_text_section, sym, ind, R_X86_64_PC32, c-4), c=4;
|
||||
greloca(cur_text_section, sym, ind, R_X86_64_PC32, 0);
|
||||
gen_le32(c-4);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user