[lld] r302694 - [ELF] Improve error message for incompatible section types
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed May 10 09:57:50 PDT 2017
Author: ruiu
Date: Wed May 10 11:57:50 2017
New Revision: 302694
URL: http://llvm.org/viewvc/llvm-project?rev=302694&view=rev
Log:
[ELF] Improve error message for incompatible section types
Previously we were not printing out the type of the incompatible section
which made it difficult to determine what the problem was.
The error message format has been change to the following:
error: section type mismatch for .shstrtab
>>> <internal>:(.shstrtab): SHT_STRTAB
>>> output section .shstrtab: Unknown
Patch by Alexander Richardson.
Differential Revision: https://reviews.llvm.org/D32488
Modified:
lld/trunk/ELF/OutputSections.cpp
lld/trunk/test/ELF/incompatible-section-types2.s
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=302694&r1=302693&r2=302694&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Wed May 10 11:57:50 2017
@@ -429,8 +429,11 @@ void OutputSectionFactory::addInputSec(I
if (canMergeToProgbits(Sec->Type) && canMergeToProgbits(IS->Type))
Sec->Type = SHT_PROGBITS;
else
- error("Section has different type from others with the same name " +
- toString(IS));
+ error("section type mismatch for " + IS->Name +
+ "\n>>> " + toString(IS) + ": " +
+ getELFSectionTypeName(Config->EMachine, IS->Type) +
+ "\n>>> output section " + Sec->Name + ": " +
+ getELFSectionTypeName(Config->EMachine, Sec->Type));
}
Sec->Flags |= Flags;
} else {
Modified: lld/trunk/test/ELF/incompatible-section-types2.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/incompatible-section-types2.s?rev=302694&r1=302693&r2=302694&view=diff
==============================================================================
--- lld/trunk/test/ELF/incompatible-section-types2.s (original)
+++ lld/trunk/test/ELF/incompatible-section-types2.s Wed May 10 11:57:50 2017
@@ -1,7 +1,9 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
// RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck %s
-// CHECK: error: Section has different type from others with the same name <internal>:(.shstrtab)
+// CHECK: error: section type mismatch for .shstrtab
+// CHECK-NEXT: >>> <internal>:(.shstrtab): SHT_STRTAB
+// CHECK-NEXT: >>> output section .shstrtab: Unknown
-.section .shstrtab,""
+.section .shstrtab,"", at 12345
.short 20
More information about the llvm-commits
mailing list