[x86] Support R_386_PC8, R_386_PC16 and R_X86_64_PC8

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198763 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Woodhouse 2014-01-08 12:58:40 +00:00
parent 51a64502bf
commit 38b362617c
3 changed files with 33 additions and 0 deletions

View File

@ -57,6 +57,7 @@ unsigned X86ELFObjectWriter::GetRelocType(const MCValue &Target,
case FK_Data_8: Type = ELF::R_X86_64_PC64; break;
case FK_Data_4: Type = ELF::R_X86_64_PC32; break;
case FK_Data_2: Type = ELF::R_X86_64_PC16; break;
case FK_Data_1: Type = ELF::R_X86_64_PC8; break;
case FK_PCRel_8:
assert(Modifier == MCSymbolRefExpr::VK_None);
@ -160,6 +161,28 @@ unsigned X86ELFObjectWriter::GetRelocType(const MCValue &Target,
Type = ELF::R_386_GOTPC;
break;
case FK_PCRel_1:
case FK_Data_1:
switch (Modifier) {
default:
llvm_unreachable("Unimplemented");
case MCSymbolRefExpr::VK_None:
Type = ELF::R_386_PC8;
break;
}
break;
case FK_PCRel_2:
case FK_Data_2:
switch (Modifier) {
default:
llvm_unreachable("Unimplemented");
case MCSymbolRefExpr::VK_None:
Type = ELF::R_386_PC16;
break;
}
break;
case X86::reloc_signed_4byte:
case FK_PCRel_4:
case FK_Data_4:

View File

@ -58,6 +58,10 @@
// CHECK-NEXT: 0x94 R_386_GOTPC _GLOBAL_OFFSET_TABLE_ 0x0
// Relocation 26 (und_symbol-bar2) is of type R_386_PC32
// CHECK-NEXT: 0x9A R_386_PC32 und_symbol 0x0
// Relocation 27 (und_symbol-bar2) is of type R_386_PC16
// CHECK-NEXT: 0x9E R_386_PC16 und_symbol 0x0
// Relocation 28 (und_symbol-bar2) is of type R_386_PC8
// CHECK-NEXT: 0xA0 R_386_PC8 und_symbol 0x0
// CHECK-NEXT: }
// CHECK-NEXT: ]
@ -120,6 +124,8 @@ bar2:
addl foo@GOTTPOFF(%edx), %eax
subl _GLOBAL_OFFSET_TABLE_-bar2, %ebx
leal und_symbol-bar2(%edx),%ecx
.word und_symbol-bar2
.byte und_symbol-bar2
.section zedsec,"awT",@progbits
zed:

View File

@ -22,6 +22,8 @@ bar:
addq $bar,%rax # R_X86_64_32S
.quad foo@DTPOFF
movabsq $baz@TPOFF, %rax
.word foo-bar
.byte foo-bar
// CHECK: Section {
// CHECK: Name: .rela.text
@ -45,6 +47,8 @@ bar:
// CHECK-NEXT: 0x77 R_X86_64_32S .text 0x0
// CHECK-NEXT: 0x7B R_X86_64_DTPOFF64 foo 0x0
// CHECK-NEXT: 0x85 R_X86_64_TPOFF64 baz 0x0
// CHECK-NEXT: 0x8D R_X86_64_PC16 foo 0x8D
// CHECK-NEXT: 0x8F R_X86_64_PC8 foo 0x8F
// CHECK-NEXT: ]
// CHECK-NEXT: }