Index: ELF/OutputSections.cpp =================================================================== --- ELF/OutputSections.cpp +++ ELF/OutputSections.cpp @@ -404,9 +404,13 @@ 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 has flags incompatible with others with the same name:" + "\n>>> section flags 0x" + utohexstr(IS->Flags) + " defined in " + + toString(IS) + + "\n>>> are incompatible with 0x" + utohexstr(Sec->Flags) + " for " + + Sec->Name); 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,13 @@ // 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 has flags incompatible with others with the same name: +// CHECK-NEXT: >>> section flags 0x3 defined in {{.*}}incompatible-section-flags.s.tmp.o:(.foo) +// CHECK-NEXT: >>> are incompatible with 0x403 for .foo +// CHECK: error: Section has flags incompatible with others with the same name: +// CHECK-NEXT: >>> section flags 0x403 defined in {{.*}}incompatible-section-flags.s.tmp.o:(.bar) +// CHECK-NEXT: >>> are incompatible with 0x3 for .bar .section .foo, "awT", @progbits, unique, 1 .quad 0