Index: lld/trunk/ELF/Writer.cpp =================================================================== --- lld/trunk/ELF/Writer.cpp +++ lld/trunk/ELF/Writer.cpp @@ -435,12 +435,11 @@ In::Iplt = make>(0); Add(In::Iplt); - if (Config->EhFrameHdr) { - In::EhFrameHdr = make>(); - Add(In::EhFrameHdr); - } - if (!Config->Relocatable) { + if (Config->EhFrameHdr) { + In::EhFrameHdr = make>(); + Add(In::EhFrameHdr); + } In::EhFrame = make>(); Add(In::EhFrame); } Index: lld/trunk/test/ELF/relocatable-eh-frame-hdr.s =================================================================== --- lld/trunk/test/ELF/relocatable-eh-frame-hdr.s +++ lld/trunk/test/ELF/relocatable-eh-frame-hdr.s @@ -0,0 +1,11 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld --eh-frame-hdr -r %t.o -o %t +# RUN: llvm-readobj -s %t | FileCheck %s + +# CHECK: Sections [ +# CHECK-NOT: Name: .eh_frame_hdr + +.section .foo,"ax",@progbits +.cfi_startproc +.cfi_endproc