[BOLT] Add support for *GOTPCRELX relocation type.

Summary:
gcc5 can generate new types of relocations that give linker a freedom
to substitute instructions. These relocations are PC-relative, and
since we manually process such relocations they don't present
much of a problem.

Additionally, detect non-pc-relative access from code into a middle of
a function. Occasionally I've seen such code, but don't know exactly
how to trigger its generation. Just issue a warning for now.

(cherry picked from FBD4566473)
This commit is contained in:
Maksim Panchenko
2017-02-14 22:55:10 -08:00
parent 82965b963f
commit f06a1455ea
3 changed files with 25 additions and 0 deletions

View File

@@ -3834,6 +3834,8 @@ size_t Relocation::getSizeForType(uint64_t Type) {
case ELF::R_X86_64_GOTPCREL:
case ELF::R_X86_64_GOTTPOFF:
case ELF::R_X86_64_TPOFF32:
case ELF::R_X86_64_GOTPCRELX:
case ELF::R_X86_64_REX_GOTPCRELX:
return 4;
case ELF::R_X86_64_PC64:
case ELF::R_X86_64_64:
@@ -3857,6 +3859,8 @@ bool Relocation::isPCRelative(uint64_t Type) {
case ELF::R_X86_64_GOTPCREL:
case ELF::R_X86_64_PLT32:
case ELF::R_X86_64_GOTTPOFF:
case ELF::R_X86_64_GOTPCRELX:
case ELF::R_X86_64_REX_GOTPCRELX:
return true;
}
}