1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00

[X86] Support modifier @PLTOFF for R_X86_64_PLTOFF64

`gcc -mcmodel=large` can emit @PLTOFF.

Reviewed By: grimar

Differential Revision: https://reviews.llvm.org/D92294
This commit is contained in:
Fangrui Song 2020-12-01 08:39:00 -08:00
parent 37d6671aa8
commit 214c071c8d
4 changed files with 28 additions and 0 deletions

View File

@ -224,6 +224,7 @@ public:
VK_WEAKREF, // The link between the symbols in .weakref foo, bar
VK_X86_ABS8,
VK_X86_PLTOFF,
VK_ARM_NONE,
VK_ARM_GOT_PREL,

View File

@ -253,6 +253,7 @@ StringRef MCSymbolRefExpr::getVariantKindName(VariantKind Kind) {
case VK_SIZE: return "SIZE";
case VK_WEAKREF: return "WEAKREF";
case VK_X86_ABS8: return "ABS8";
case VK_X86_PLTOFF: return "PLTOFF";
case VK_ARM_NONE: return "none";
case VK_ARM_GOT_PREL: return "GOT_PREL";
case VK_ARM_TARGET1: return "target1";
@ -410,6 +411,7 @@ MCSymbolRefExpr::getVariantKindForName(StringRef Name) {
.Case("secrel32", VK_SECREL)
.Case("size", VK_SIZE)
.Case("abs8", VK_X86_ABS8)
.Case("pltoff", VK_X86_PLTOFF)
.Case("l", VK_PPC_LO)
.Case("h", VK_PPC_HI)
.Case("ha", VK_PPC_HA)

View File

@ -94,6 +94,12 @@ static void checkIs32(MCContext &Ctx, SMLoc Loc, X86_64RelType Type) {
"32 bit reloc applied to a field with a different size");
}
static void checkIs64(MCContext &Ctx, SMLoc Loc, X86_64RelType Type) {
if (Type != RT64_64)
Ctx.reportError(Loc,
"64 bit reloc applied to a field with a different size");
}
static unsigned getRelocType64(MCContext &Ctx, SMLoc Loc,
MCSymbolRefExpr::VariantKind Modifier,
X86_64RelType Type, bool IsPCRel,
@ -212,6 +218,9 @@ static unsigned getRelocType64(MCContext &Ctx, SMLoc Loc,
return ELF::R_X86_64_REX_GOTPCRELX;
}
llvm_unreachable("unexpected relocation type!");
case MCSymbolRefExpr::VK_X86_PLTOFF:
checkIs64(Ctx, Loc, Type);
return ELF::R_X86_64_PLTOFF64;
}
}

16
test/MC/X86/pltoff.s Normal file
View File

@ -0,0 +1,16 @@
# RUN: llvm-mc -triple=x86_64 %s | FileCheck %s --check-prefix=ASM
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t
# RUN: llvm-objdump -d -r %t | FileCheck %s --check-prefix=OBJ
# RUN: not llvm-mc -filetype=obj -triple=x86_64 --defsym ERR=1 %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR
# ASM: movabsq $puts@PLTOFF, %rax
# OBJ: movabsq $0, %rax
# OBJ-NEXT: 0000000000000002: R_X86_64_PLTOFF64 puts{{$}}
movabsq $puts@PLTOFF, %rax
.ifdef ERR
# ERR: {{.*}}.s:[[#@LINE+1]]:1: error: 64 bit reloc applied to a field with a different size
movl $puts@PLTOFF, %eax
.endif