[lld] r353314 - Support R_X86_64_PC8 and R_X86_64_PC16.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 6 08:50:09 PST 2019
Author: ruiu
Date: Wed Feb 6 08:50:09 2019
New Revision: 353314
URL: http://llvm.org/viewvc/llvm-project?rev=353314&view=rev
Log:
Support R_X86_64_PC8 and R_X86_64_PC16.
They are defined by the x86-64 ELF ABI standard.
Differential Revision: https://reviews.llvm.org/D57799
Added:
lld/trunk/test/ELF/x86-64-pcrel.s
Modified:
lld/trunk/ELF/Arch/X86_64.cpp
Modified: lld/trunk/ELF/Arch/X86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/X86_64.cpp?rev=353314&r1=353313&r2=353314&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/X86_64.cpp (original)
+++ lld/trunk/ELF/Arch/X86_64.cpp Wed Feb 6 08:50:09 2019
@@ -101,6 +101,8 @@ RelExpr X86_64<ELFT>::getRelExpr(RelType
return R_SIZE;
case R_X86_64_PLT32:
return R_PLT_PC;
+ case R_X86_64_PC8:
+ case R_X86_64_PC16:
case R_X86_64_PC32:
case R_X86_64_PC64:
return R_PC;
@@ -319,10 +321,12 @@ template <class ELFT>
void X86_64<ELFT>::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
switch (Type) {
case R_X86_64_8:
+ case R_X86_64_PC8:
checkUInt(Loc, Val, 8, Type);
*Loc = Val;
break;
case R_X86_64_16:
+ case R_X86_64_PC16:
checkUInt(Loc, Val, 16, Type);
write16le(Loc, Val);
break;
Added: lld/trunk/test/ELF/x86-64-pcrel.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/x86-64-pcrel.s?rev=353314&view=auto
==============================================================================
--- lld/trunk/test/ELF/x86-64-pcrel.s (added)
+++ lld/trunk/test/ELF/x86-64-pcrel.s Wed Feb 6 08:50:09 2019
@@ -0,0 +1,21 @@
+// REQUIRES: x86
+
+// This is a test for R_X86_64_PC8 and R_X86_64_PC16.
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
+// RUN: echo '.globl foo; foo:' | llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t2.o
+// RUN: ld.lld -o %t.exe %t1.o %t2.o
+// RUN: llvm-objdump -s %t.exe | FileCheck %s
+
+// CHECK: Contents of section .text:
+// CHECK: 2000cccc cccccccc cccccccc cccccccc
+// CHECK: 20cccccc cccccccc cccccccc cccccccc
+
+.globl _start
+_start:
+
+.word foo - _start
+.fill 14,1,0xcc
+
+.byte foo - _start
+.fill 15,1,0xcc
More information about the llvm-commits
mailing list