mirror of
https://github.com/frida/tinycc
synced 2024-11-28 10:33:07 +03:00
added 64-bit relocation types that required to linking against 64-bit (large model) libraries
This commit is contained in:
parent
1ed20a01c9
commit
3a9d6b3655
@ -30,18 +30,23 @@ int code_reloc (int reloc_type)
|
|||||||
case R_X86_64_32:
|
case R_X86_64_32:
|
||||||
case R_X86_64_32S:
|
case R_X86_64_32S:
|
||||||
case R_X86_64_64:
|
case R_X86_64_64:
|
||||||
|
case R_X86_64_GOTPC32:
|
||||||
|
case R_X86_64_GOTPC64:
|
||||||
case R_X86_64_GOTPCREL:
|
case R_X86_64_GOTPCREL:
|
||||||
case R_X86_64_GOTPCRELX:
|
case R_X86_64_GOTPCRELX:
|
||||||
case R_X86_64_REX_GOTPCRELX:
|
case R_X86_64_REX_GOTPCRELX:
|
||||||
case R_X86_64_GOTTPOFF:
|
case R_X86_64_GOTTPOFF:
|
||||||
case R_X86_64_GOT32:
|
case R_X86_64_GOT32:
|
||||||
|
case R_X86_64_GOT64:
|
||||||
case R_X86_64_GLOB_DAT:
|
case R_X86_64_GLOB_DAT:
|
||||||
case R_X86_64_COPY:
|
case R_X86_64_COPY:
|
||||||
case R_X86_64_RELATIVE:
|
case R_X86_64_RELATIVE:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case R_X86_64_PC32:
|
case R_X86_64_PC32:
|
||||||
|
case R_X86_64_PC64:
|
||||||
case R_X86_64_PLT32:
|
case R_X86_64_PLT32:
|
||||||
|
case R_X86_64_PLTOFF64:
|
||||||
case R_X86_64_JUMP_SLOT:
|
case R_X86_64_JUMP_SLOT:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -69,16 +74,21 @@ int gotplt_entry_type (int reloc_type)
|
|||||||
case R_X86_64_32S:
|
case R_X86_64_32S:
|
||||||
case R_X86_64_64:
|
case R_X86_64_64:
|
||||||
case R_X86_64_PC32:
|
case R_X86_64_PC32:
|
||||||
|
case R_X86_64_PC64:
|
||||||
return AUTO_GOTPLT_ENTRY;
|
return AUTO_GOTPLT_ENTRY;
|
||||||
|
|
||||||
case R_X86_64_GOTTPOFF:
|
case R_X86_64_GOTTPOFF:
|
||||||
return BUILD_GOT_ONLY;
|
return BUILD_GOT_ONLY;
|
||||||
|
|
||||||
case R_X86_64_GOT32:
|
case R_X86_64_GOT32:
|
||||||
|
case R_X86_64_GOT64:
|
||||||
|
case R_X86_64_GOTPC32:
|
||||||
|
case R_X86_64_GOTPC64:
|
||||||
case R_X86_64_GOTPCREL:
|
case R_X86_64_GOTPCREL:
|
||||||
case R_X86_64_GOTPCRELX:
|
case R_X86_64_GOTPCRELX:
|
||||||
case R_X86_64_REX_GOTPCRELX:
|
case R_X86_64_REX_GOTPCRELX:
|
||||||
case R_X86_64_PLT32:
|
case R_X86_64_PLT32:
|
||||||
|
case R_X86_64_PLTOFF64:
|
||||||
return ALWAYS_GOTPLT_ENTRY;
|
return ALWAYS_GOTPLT_ENTRY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,6 +233,26 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t
|
|||||||
add32le(ptr, diff);
|
add32le(ptr, diff);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case R_X86_64_PLTOFF64:
|
||||||
|
add64le(ptr, val - s1->got->sh_addr + rel->r_addend);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R_X86_64_PC64:
|
||||||
|
if (s1->output_type == TCC_OUTPUT_DLL) {
|
||||||
|
/* DLL relocation */
|
||||||
|
esym_index = s1->sym_attrs[sym_index].dyn_index;
|
||||||
|
if (esym_index) {
|
||||||
|
qrel->r_offset = rel->r_offset;
|
||||||
|
qrel->r_info = ELFW(R_INFO)(esym_index, R_X86_64_PC64);
|
||||||
|
qrel->r_addend = read64le(ptr) + rel->r_addend;
|
||||||
|
qrel++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
add64le(ptr, val - addr);
|
||||||
|
break;
|
||||||
|
|
||||||
case R_X86_64_GLOB_DAT:
|
case R_X86_64_GLOB_DAT:
|
||||||
case R_X86_64_JUMP_SLOT:
|
case R_X86_64_JUMP_SLOT:
|
||||||
/* They don't need addend */
|
/* They don't need addend */
|
||||||
@ -234,6 +264,12 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t
|
|||||||
add32le(ptr, s1->got->sh_addr - addr +
|
add32le(ptr, s1->got->sh_addr - addr +
|
||||||
s1->sym_attrs[sym_index].got_offset - 4);
|
s1->sym_attrs[sym_index].got_offset - 4);
|
||||||
break;
|
break;
|
||||||
|
case R_X86_64_GOTPC32:
|
||||||
|
add32le(ptr, s1->got->sh_addr - addr + rel->r_addend);
|
||||||
|
break;
|
||||||
|
case R_X86_64_GOTPC64:
|
||||||
|
add64le(ptr, s1->got->sh_addr - addr + rel->r_addend);
|
||||||
|
break;
|
||||||
case R_X86_64_GOTTPOFF:
|
case R_X86_64_GOTTPOFF:
|
||||||
add32le(ptr, val - s1->got->sh_addr);
|
add32le(ptr, val - s1->got->sh_addr);
|
||||||
break;
|
break;
|
||||||
@ -241,6 +277,10 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t
|
|||||||
/* we load the got offset */
|
/* we load the got offset */
|
||||||
add32le(ptr, s1->sym_attrs[sym_index].got_offset);
|
add32le(ptr, s1->sym_attrs[sym_index].got_offset);
|
||||||
break;
|
break;
|
||||||
|
case R_X86_64_GOT64:
|
||||||
|
/* we load the got offset */
|
||||||
|
add64le(ptr, s1->sym_attrs[sym_index].got_offset);
|
||||||
|
break;
|
||||||
case R_X86_64_RELATIVE:
|
case R_X86_64_RELATIVE:
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user