[lld] r248795 - Don't apply a relocation if we create a dynamic reloc.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 06:51:43 PDT 2015


Author: rafael
Date: Tue Sep 29 08:51:43 2015
New Revision: 248795

URL: http://llvm.org/viewvc/llvm-project?rev=248795&view=rev
Log:
Don't apply a relocation if we create a dynamic reloc.

With RELA that is just wasteful, with REL the relocation gets applied
twice.

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=248795&r1=248794&r2=248795&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Tue Sep 29 08:51:43 2015
@@ -60,6 +60,8 @@ void InputSection<ELFT>::relocate(
       } else if (Target->relocPointsToGot(Type)) {
         SymVA = GotSec.getVA();
         Type = Target->getPCRelReloc();
+      } else if (isa<SharedSymbol<ELFT>>(Body)) {
+        continue;
       }
     }
 

Modified: lld/trunk/test/elf2/relocation-i686.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/relocation-i686.s?rev=248795&r1=248794&r2=248795&view=diff
==============================================================================
--- lld/trunk/test/elf2/relocation-i686.s (original)
+++ lld/trunk/test/elf2/relocation-i686.s Tue Sep 29 08:51:43 2015
@@ -57,3 +57,9 @@ R_386_GOTPC:
 // CHECK:      Disassembly of section .R_386_GOTPC:
 // CHECK-NEXT: R_386_GOTPC:
 // CHECK-NEXT:   11014:  {{.*}} movl  $16364, %eax
+
+.section .dynamic_reloc, "ax", at progbits
+        call bar+4
+// CHECK:      Disassembly of section .dynamic_reloc:
+// CHECK-NEXT: .dynamic_reloc:
+// CHECK-NEXT:   11019:  e8 00 00 00 00  calll  0




More information about the llvm-commits mailing list