<div dir="ltr">These relocations are added after 8.0 was cut, so this is not a regression. We've been living without these relocations since 4.0, so I think not supporting this for one more cycle is fine.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 7, 2019 at 1:55 PM Shoaib Meenai <<a href="mailto:smeenai@fb.com">smeenai@fb.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Should this be merged to 8.0?<br>
<br>
On 2/7/19, 10:12 AM, "llvm-commits on behalf of Rui Ueyama via llvm-commits" <<a href="mailto:llvm-commits-bounces@lists.llvm.org" target="_blank">llvm-commits-bounces@lists.llvm.org</a> on behalf of <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br>
<br>
Author: ruiu<br>
Date: Thu Feb 7 10:12:57 2019<br>
New Revision: 353437<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D353437-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=SsIV4bxzRk5xcqIODXUWMAKgrjALt2jgK-8molEY6ik&s=cXPyCTPqI-n63UfUmlWURBOeqMLYWXWNr7J7MBI2A9k&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D353437-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=SsIV4bxzRk5xcqIODXUWMAKgrjALt2jgK-8molEY6ik&s=cXPyCTPqI-n63UfUmlWURBOeqMLYWXWNr7J7MBI2A9k&e=</a><br>
Log:<br>
Fix a bug in R_X86_64_PC{8,16} relocation handling.<br>
<br>
R_X86_64_PC{8,16} relocations are sign-extended, so when we check<br>
for relocation overflow, we had to use checkInt instead of checkUInt.<br>
I confirmed that GNU linkers create the same output for the test case.<br>
<br>
Added:<br>
lld/trunk/test/ELF/Inputs/x86-64-pcrel.s<br>
Modified:<br>
lld/trunk/ELF/Arch/X86_64.cpp<br>
lld/trunk/test/ELF/x86-64-pcrel.s<br>
<br>
Modified: lld/trunk/ELF/Arch/X86_64.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_ELF_Arch_X86-5F64.cpp-3Frev-3D353437-26r1-3D353436-26r2-3D353437-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=SsIV4bxzRk5xcqIODXUWMAKgrjALt2jgK-8molEY6ik&s=1z6MXm9dyJ34rii6Pnpfo2Z6p1hjqOVNa5a6HMGyHKs&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_ELF_Arch_X86-5F64.cpp-3Frev-3D353437-26r1-3D353436-26r2-3D353437-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=SsIV4bxzRk5xcqIODXUWMAKgrjALt2jgK-8molEY6ik&s=1z6MXm9dyJ34rii6Pnpfo2Z6p1hjqOVNa5a6HMGyHKs&e=</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Arch/X86_64.cpp (original)<br>
+++ lld/trunk/ELF/Arch/X86_64.cpp Thu Feb 7 10:12:57 2019<br>
@@ -324,15 +324,21 @@ template <class ELFT><br>
void X86_64<ELFT>::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {<br>
switch (Type) {<br>
case R_X86_64_8:<br>
- case R_X86_64_PC8:<br>
checkUInt(Loc, Val, 8, Type);<br>
*Loc = Val;<br>
break;<br>
+ case R_X86_64_PC8:<br>
+ checkInt(Loc, Val, 8, Type);<br>
+ *Loc = Val;<br>
+ break;<br>
case R_X86_64_16:<br>
- case R_X86_64_PC16:<br>
checkUInt(Loc, Val, 16, Type);<br>
write16le(Loc, Val);<br>
break;<br>
+ case R_X86_64_PC16:<br>
+ checkInt(Loc, Val, 16, Type);<br>
+ write16le(Loc, Val);<br>
+ break;<br>
case R_X86_64_32:<br>
checkUInt(Loc, Val, 32, Type);<br>
write32le(Loc, Val);<br>
<br>
Added: lld/trunk/test/ELF/Inputs/x86-64-pcrel.s<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_test_ELF_Inputs_x86-2D64-2Dpcrel.s-3Frev-3D353437-26view-3Dauto&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=SsIV4bxzRk5xcqIODXUWMAKgrjALt2jgK-8molEY6ik&s=SSJnKLh-SoIbbcSN6izHhnGL8HVY9OQ0-DjTN8xdCaM&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_test_ELF_Inputs_x86-2D64-2Dpcrel.s-3Frev-3D353437-26view-3Dauto&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=SsIV4bxzRk5xcqIODXUWMAKgrjALt2jgK-8molEY6ik&s=SSJnKLh-SoIbbcSN6izHhnGL8HVY9OQ0-DjTN8xdCaM&e=</a><br>
==============================================================================<br>
--- lld/trunk/test/ELF/Inputs/x86-64-pcrel.s (added)<br>
+++ lld/trunk/test/ELF/Inputs/x86-64-pcrel.s Thu Feb 7 10:12:57 2019<br>
@@ -0,0 +1,8 @@<br>
+.globl foo<br>
+foo:<br>
+<br>
+.word _start - foo<br>
+.fill 14,1,0xcc<br>
+<br>
+.byte _start - foo<br>
+.fill 15,1,0xcc<br>
<br>
Modified: lld/trunk/test/ELF/x86-64-pcrel.s<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_test_ELF_x86-2D64-2Dpcrel.s-3Frev-3D353437-26r1-3D353436-26r2-3D353437-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=SsIV4bxzRk5xcqIODXUWMAKgrjALt2jgK-8molEY6ik&s=KwH6YCrVh-2BtX_A9zDtFgiZ15ayv1TbU-56rwu-XO0&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_test_ELF_x86-2D64-2Dpcrel.s-3Frev-3D353437-26r1-3D353436-26r2-3D353437-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=SsIV4bxzRk5xcqIODXUWMAKgrjALt2jgK-8molEY6ik&s=KwH6YCrVh-2BtX_A9zDtFgiZ15ayv1TbU-56rwu-XO0&e=</a><br>
==============================================================================<br>
--- lld/trunk/test/ELF/x86-64-pcrel.s (original)<br>
+++ lld/trunk/test/ELF/x86-64-pcrel.s Thu Feb 7 10:12:57 2019<br>
@@ -3,13 +3,15 @@<br>
// This is a test for R_X86_64_PC8 and R_X86_64_PC16.<br>
<br>
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o<br>
-// RUN: echo '.globl foo; foo:' | llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t2.o<br>
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/x86-64-pcrel.s -o %t2.o<br>
// RUN: ld.lld -o %t.exe %t1.o %t2.o<br>
// RUN: llvm-objdump -s %t.exe | FileCheck %s<br>
<br>
-// CHECK: Contents of section .text:<br>
-// CHECK: 2000cccc cccccccc cccccccc cccccccc<br>
-// CHECK: 20cccccc cccccccc cccccccc cccccccc<br>
+// CHECK: Contents of section .text:<br>
+// CHECK-NEXT: 2000cccc cccccccc cccccccc cccccccc<br>
+// CHECK-NEXT: 20cccccc cccccccc cccccccc cccccccc<br>
+// CHECK-NEXT: e0ffcccc cccccccc cccccccc cccccccc<br>
+// CHECK-NEXT: e0cccccc cccccccc cccccccc cccccccc<br>
<br>
.globl _start<br>
_start:<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=SsIV4bxzRk5xcqIODXUWMAKgrjALt2jgK-8molEY6ik&s=OpF2iQKe74C8Ec3Yi6mvt7HLOZXJT01QzvMW95l-JUc&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=SsIV4bxzRk5xcqIODXUWMAKgrjALt2jgK-8molEY6ik&s=OpF2iQKe74C8Ec3Yi6mvt7HLOZXJT01QzvMW95l-JUc&e=</a><br>
<br>
<br>
</blockquote></div>