From f3a3b93f5453e4e07d449c1ed733c9ac8cfb4b58 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 17 May 2019 14:11:03 +0000 Subject: [ELF] -r: fix R_*_NONE to section symbols on Elf*_Rel targets On Elf*_Rel targets, for a relocation to a section symbol, an R_ABS is added which will be used by relocateOne() to compute the implicit addend. Addends of R_*_NONE should be ignored, so don't emit an R_ABS. This fixes crashes on X86 and ARM because their relocateOne() do not handle R_*_NONE. Reviewed By: peter.smith Differential Revision: https://reviews.llvm.org/D62052 llvm-svn: 361036 --- lld/ELF/InputSection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lld/ELF/InputSection.cpp') diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 6bb68bbf672..1bf67e2a338 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -470,7 +470,7 @@ void InputSection::copyRelocations(uint8_t *Buf, ArrayRef Rels) { if (RelTy::IsRela) P->r_addend = Sym.getVA(Addend) - Section->getOutputSection()->Addr; - else if (Config->Relocatable) + else if (Config->Relocatable && Type != Target->NoneRel) Sec->Relocations.push_back({R_ABS, Type, Rel.r_offset, Addend, &Sym}); } } -- cgit v1.2.3