diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -78,10 +78,14 @@ // to be allocated for nobits sections. Other ones don't require // any special treatment on top of progbits, so there doesn't // seem to be a harm in merging them. +// +// NOTE: clang since rL252300 emits SHT_X86_64_UNWIND .eh_frame sections. Allow +// them to be merged into SHT_PROGBITS .eh_frame (GNU as .cfi_*). static bool canMergeToProgbits(unsigned type) { return type == SHT_NOBITS || type == SHT_PROGBITS || type == SHT_INIT_ARRAY || type == SHT_PREINIT_ARRAY || type == SHT_FINI_ARRAY || - type == SHT_NOTE; + type == SHT_NOTE || + (type == SHT_X86_64_UNWIND && config->emachine == EM_X86_64); } // Record that isec will be placed in the OutputSection. isec does not become diff --git a/lld/test/ELF/eh-frame-type.test b/lld/test/ELF/eh-frame-type.test --- a/lld/test/ELF/eh-frame-type.test +++ b/lld/test/ELF/eh-frame-type.test @@ -11,6 +11,9 @@ # RUN: ld.lld %t1.o %t2.o -o %tboth # RUN: llvm-readobj -S %tboth | FileCheck %s +# RUN: ld.lld -r %t1.o %t2.o -o %tboth.ro +# RUN: llvm-readobj -S %tboth.ro | FileCheck %s + # CHECK: Name: .eh_frame # CHECK-NEXT: Type: SHT_PROGBITS