Index: ELF/InputSection.cpp =================================================================== --- ELF/InputSection.cpp +++ ELF/InputSection.cpp @@ -470,7 +470,7 @@ 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}); } } Index: test/ELF/relocation-none-arm.s =================================================================== --- test/ELF/relocation-none-arm.s +++ test/ELF/relocation-none-arm.s @@ -8,6 +8,13 @@ # CHECK: .data # CHECK: There are no relocations in this file. +# RUN: ld.lld -r %t.o -o %t +# RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELOC %s + +# RELOC: Section ({{.*}}) .rel.text { +# RELOC-NEXT: 0x0 R_ARM_NONE .data 0x0 +# RELOC-NEXT: } + .globl _start _start: nop Index: test/ELF/relocation-none-i386.s =================================================================== --- test/ELF/relocation-none-i386.s +++ test/ELF/relocation-none-i386.s @@ -8,6 +8,13 @@ # CHECK: .data # CHECK: There are no relocations in this file. +# RUN: ld.lld -r %t.o -o %t +# RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELOC %s + +# RELOC: Section ({{.*}}) .rel.text { +# RELOC-NEXT: 0x0 R_386_NONE .data 0x0 +# RELOC-NEXT: } + .globl _start _start: ret