[lld] r248275 - Add support for R_386_PC32.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 06:47:46 PDT 2015


Author: rafael
Date: Tue Sep 22 08:47:45 2015
New Revision: 248275

URL: http://llvm.org/viewvc/llvm-project?rev=248275&view=rev
Log:
Add support for R_386_PC32.

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/test/elf2/relocation-i686.s

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=248275&r1=248274&r2=248275&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Tue Sep 22 08:47:45 2015
@@ -33,6 +33,9 @@ void InputSection<ELFT>::relocateOne(uin
   uint8_t *Location = Buf + Offset;
   uint32_t Addend = *(support::ulittle32_t *)Location;
   switch (Type) {
+  case R_386_PC32:
+    support::endian::write32le(Location, SymVA + Addend - (BaseAddr + Offset));
+    break;
   case R_386_32:
     support::endian::write32le(Location, SymVA + Addend);
     break;

Modified: lld/trunk/test/elf2/relocation-i686.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/relocation-i686.s?rev=248275&r1=248274&r2=248275&view=diff
==============================================================================
--- lld/trunk/test/elf2/relocation-i686.s (original)
+++ lld/trunk/test/elf2/relocation-i686.s Tue Sep 22 08:47:45 2015
@@ -11,6 +11,24 @@ _start:
 R_386_32:
   movl $R_386_32 + 1, %edx
 
+
+.section       .R_386_PC32,"ax", at progbits,unique,1
+.global R_386_PC32
+R_386_PC32:
+  call R_386_PC32_2
+
+.section       .R_386_PC32,"ax", at progbits,unique,2
+.zero 4
+R_386_PC32_2:
+  nop
+
 // CHECK: Disassembly of section .R_386_32:
 // CHECK-NEXT: R_386_32:
 // CHECK-NEXT:  11000: {{.*}} movl $69633, %edx
+
+// CHECK: Disassembly of section .R_386_PC32:
+// CHECK-NEXT: R_386_PC32:
+// CHECK-NEXT:   11005:  e8 04 00 00 00  calll 4
+
+// CHECK:      R_386_PC32_2:
+// CHECK-NEXT:   1100e:  90  nop




More information about the llvm-commits mailing list