diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp --- a/lld/MachO/InputFiles.cpp +++ b/lld/MachO/InputFiles.cpp @@ -343,23 +343,20 @@ }; if (sectionType(sec.flags) == S_CSTRING_LITERALS) { - if (sec.nreloc && config->dedupStrings) - fatal(toString(this) + " contains relocations in " + sec.segname + "," + - sec.sectname + - ", so LLD cannot deduplicate strings. Try re-running with " - "--no-deduplicate-strings."); - - InputSection *isec = make( - section, data, align, - /*dedupLiterals=*/name == section_names::objcMethname || - config->dedupStrings); + if (sec.nreloc) + fatal(toString(this) + ": " + sec.segname + "," + sec.sectname + + " contains relocations, which is unsupported"); + bool dedupLiterals = + name == section_names::objcMethname || config->dedupStrings; + InputSection *isec = + make(section, data, align, dedupLiterals); // FIXME: parallelize this? cast(isec)->splitIntoPieces(); section.subsections.push_back({0, isec}); } else if (isWordLiteralSection(sec.flags)) { if (sec.nreloc) - fatal(toString(this) + " contains unsupported relocations in " + - sec.segname + "," + sec.sectname); + fatal(toString(this) + ": " + sec.segname + "," + sec.sectname + + " contains relocations, which is unsupported"); InputSection *isec = make(section, data, align); section.subsections.push_back({0, isec}); } else if (auto recordSize = getRecordSize(segname, name)) { diff --git a/lld/test/MachO/invalid/cstring-dedup.s b/lld/test/MachO/invalid/cstring-dedup.s --- a/lld/test/MachO/invalid/cstring-dedup.s +++ b/lld/test/MachO/invalid/cstring-dedup.s @@ -11,7 +11,7 @@ # RUN: not %lld -dylib %t/relocs.o 2>&1 | FileCheck %s --check-prefix=RELOCS # TERM: not-terminated.o:(__cstring+0x4): string is not null terminated -# RELOCS: relocs.o contains relocations in __TEXT,__cstring, so LLD cannot deduplicate strings. Try re-running with --no-deduplicate-strings. +# RELOCS: error: {{.*}}relocs.o: __TEXT,__cstring contains relocations, which is unsupported #--- not-terminated.s .cstring