[PATCH] D29490: [ELF] - Use SignExtend when reading R_386_PC8, R_386_PC16 addends.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 7 02:10:00 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294289: [ELF] - Use SignExtend when reading R_386_PC8, R_386_PC16 addends. (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D29490?vs=87238&id=87380#toc
Repository:
rL LLVM
https://reviews.llvm.org/D29490
Files:
lld/trunk/ELF/Target.cpp
lld/trunk/test/ELF/i386-pc8-pc16-addend.s
Index: lld/trunk/test/ELF/i386-pc8-pc16-addend.s
===================================================================
--- lld/trunk/test/ELF/i386-pc8-pc16-addend.s
+++ lld/trunk/test/ELF/i386-pc8-pc16-addend.s
@@ -0,0 +1,17 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=i386-pc-linux-gnu %s -o %t1.o
+
+# RUN: ld.lld %t1.o -o %t.out
+# RUN: llvm-objdump -s -t %t.out | FileCheck %s
+# CHECK: Contents of section .text:
+# CHECK-NEXT: 11000 020000
+## 0x11003 - 0x11000 + addend(-1) = 0x02
+## 0x11003 - 0x11001 + addend(-2) = 0x0000
+# CHECK: SYMBOL TABLE:
+# CHECK: 00011003 .und
+
+.byte und-.-1
+.short und-.-2
+
+.section .und, "ax"
+und:
Index: lld/trunk/ELF/Target.cpp
===================================================================
--- lld/trunk/ELF/Target.cpp
+++ lld/trunk/ELF/Target.cpp
@@ -491,11 +491,13 @@
default:
return 0;
case R_386_8:
- case R_386_PC8:
return *Buf;
+ case R_386_PC8:
+ return SignExtend64<8>(*Buf);
case R_386_16:
- case R_386_PC16:
return read16le(Buf);
+ case R_386_PC16:
+ return SignExtend64<16>(read16le(Buf));
case R_386_32:
case R_386_GOT32:
case R_386_GOT32X:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29490.87380.patch
Type: text/x-patch
Size: 1168 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170207/976054bd/attachment.bin>
More information about the llvm-commits
mailing list