From be901e2dbc9e1111e1265f00df4c084a5ceee4ef Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 29 Sep 2015 13:51:43 +0000 Subject: [PATCH] Don't apply a relocation if we create a dynamic reloc. With RELA that is just wasteful, with REL the relocation gets applied twice. llvm-svn: 248795 --- lld/ELF/InputSection.cpp | 2 ++ lld/test/elf2/relocation-i686.s | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index e7c2e7dfd9f3..8d0b6f6e443f 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -60,6 +60,8 @@ void InputSection::relocate( } else if (Target->relocPointsToGot(Type)) { SymVA = GotSec.getVA(); Type = Target->getPCRelReloc(); + } else if (isa>(Body)) { + continue; } } diff --git a/lld/test/elf2/relocation-i686.s b/lld/test/elf2/relocation-i686.s index 3e068f6f59ce..bcfc28c2d7d4 100644 --- a/lld/test/elf2/relocation-i686.s +++ b/lld/test/elf2/relocation-i686.s @@ -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",@progbits + call bar+4 +// CHECK: Disassembly of section .dynamic_reloc: +// CHECK-NEXT: .dynamic_reloc: +// CHECK-NEXT: 11019: e8 00 00 00 00 calll 0