Index: ELF/OutputSections.cpp =================================================================== --- ELF/OutputSections.cpp +++ ELF/OutputSections.cpp @@ -404,9 +404,12 @@ uint64_t Flags = getOutFlags(IS); OutputSection *&Sec = Map[Key]; if (Sec) { + // TODO: pretty print the section flags if (getIncompatibleFlags(Sec->Flags) != getIncompatibleFlags(IS->Flags)) - error("Section has flags incompatible with others with the same name " + - toString(IS)); + error("section " + IS->Name + " flags (0x" + utohexstr(IS->Flags) + + ") are incompatible with output section " + Sec->Name + + " flags (0x" + utohexstr(Sec->Flags) + ")\n>>> input section " + + IS->Name + " is defined in " + toString(IS->File)); if (Sec->Type != IS->Type) { if (canMergeToProgbits(Sec->Type) && canMergeToProgbits(IS->Type)) Sec->Type = SHT_PROGBITS; Index: test/ELF/incompatible-section-flags.s =================================================================== --- test/ELF/incompatible-section-flags.s +++ test/ELF/incompatible-section-flags.s @@ -1,9 +1,11 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o // RUN: not ld.lld -shared %t.o -o %t 2>&1 | FileCheck %s -// CHECK: error: Section has flags incompatible with others with the same name {{.*}}incompatible-section-flags.s.tmp.o:(.foo) -// CHECK: error: Section has flags incompatible with others with the same name {{.*}}incompatible-section-flags.s.tmp.o:(.bar) +// CHECK: error: section .foo flags (0x3) are incompatible with output section .foo flags (0x403) +// CHECK-NEXT: >>> input section .foo is defined in {{.*}}incompatible-section-flags.s.tmp.o +// CHECK: error: section .bar flags (0x403) are incompatible with output section .bar flags (0x3) +// CHECK-NEXT: >>> input section .bar is defined in {{.*}}incompatible-section-flags.s.tmp.o .section .foo, "awT", @progbits, unique, 1 .quad 0