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,16 @@ // 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: The 0x70000001 condition allows SHT_X86_64_UNWIND .eh_frame (clang +// since rL252300) to be merged into SHT_PROGBITS .eh_frame (GNU as .cfi_). +// While SHT_ARM_EXIDX = SHT_X86_64_UNWIND = SHT_IA_64_UNWIND, some +// architectures may define 0x70000001 for other purposes. The loose condition +// just drops a diagnostic in an edge case. 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 == 0x70000001; } // 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