From: Rui Ueyama Date: Wed, 10 May 2017 16:57:50 +0000 (+0000) Subject: [ELF] Improve error message for incompatible section types X-Git-Tag: llvmorg-5.0.0-rc1~5436 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=896cbc40adbe9e6e7bff089e91de9e9a76fbeaf8;p=platform%2Fupstream%2Fllvm.git [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 >>> :(.shstrtab): SHT_STRTAB >>> output section .shstrtab: Unknown Patch by Alexander Richardson. Differential Revision: https://reviews.llvm.org/D32488 llvm-svn: 302694 --- diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 9cbbd468e8ff..b25aa0683655 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -429,8 +429,11 @@ void OutputSectionFactory::addInputSec(InputSectionBase *IS, 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 { diff --git a/lld/test/ELF/incompatible-section-types2.s b/lld/test/ELF/incompatible-section-types2.s index 2cf9b8548aa1..146e680ab271 100644 --- a/lld/test/ELF/incompatible-section-types2.s +++ b/lld/test/ELF/incompatible-section-types2.s @@ -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 :(.shstrtab) +// CHECK: error: section type mismatch for .shstrtab +// CHECK-NEXT: >>> :(.shstrtab): SHT_STRTAB +// CHECK-NEXT: >>> output section .shstrtab: Unknown -.section .shstrtab,"" +.section .shstrtab,"",@12345 .short 20