[lld] r352428 - lld/coff: Make assoc comdat diag a bit more detailed
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 28 13:16:16 PST 2019
Author: nico
Date: Mon Jan 28 13:16:15 2019
New Revision: 352428
URL: http://llvm.org/viewvc/llvm-project?rev=352428&view=rev
Log:
lld/coff: Make assoc comdat diag a bit more detailed
Many different sections can have the same name, so include the indices of the
sections mentioned in the diagnostic too.
I'm debugging something I can't repro locally, maybe this will help.
Modified:
lld/trunk/COFF/InputFiles.cpp
lld/trunk/test/COFF/associative-comdat-empty.test
lld/trunk/test/COFF/associative-comdat-order.test
Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=352428&r1=352427&r2=352428&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Mon Jan 28 13:16:15 2019
@@ -225,6 +225,7 @@ void ObjFile::readAssociativeDefinition(
const coff_aux_section_definition *Def,
uint32_t ParentIndex) {
SectionChunk *Parent = SparseChunks[ParentIndex];
+ int32_t SectionNumber = Sym.getSectionNumber();
auto Diag = [&]() {
StringRef Name, ParentName;
@@ -233,8 +234,9 @@ void ObjFile::readAssociativeDefinition(
const coff_section *ParentSec;
COFFObj->getSection(ParentIndex, ParentSec);
COFFObj->getSectionName(ParentSec, ParentName);
- error(toString(this) + ": associative comdat " + Name +
- " has invalid reference to section " + ParentName);
+ error(toString(this) + ": associative comdat " + Name + " (sec " +
+ Twine(SectionNumber) + ") has invalid reference to section " +
+ ParentName + " (sec " + Twine(ParentIndex) + ")");
};
if (Parent == PendingComdat) {
@@ -247,7 +249,6 @@ void ObjFile::readAssociativeDefinition(
// Check whether the parent is prevailing. If it is, so are we, and we read
// the section; otherwise mark it as discarded.
- int32_t SectionNumber = Sym.getSectionNumber();
if (Parent) {
if (Parent->Selection == IMAGE_COMDAT_SELECT_ASSOCIATIVE) {
Diag();
Modified: lld/trunk/test/COFF/associative-comdat-empty.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/associative-comdat-empty.test?rev=352428&r1=352427&r2=352428&view=diff
==============================================================================
--- lld/trunk/test/COFF/associative-comdat-empty.test (original)
+++ lld/trunk/test/COFF/associative-comdat-empty.test Mon Jan 28 13:16:15 2019
@@ -2,7 +2,7 @@
# RUN: not lld-link /include:symbol /dll /noentry /nodefaultlib %t.obj /out:%t.exe 2>&1 | FileCheck %s
# Tests an associative comdat being associated with an empty section errors.
-# CHECK: lld-link: error: {{.*}}: associative comdat .text$ac1 has invalid reference to section .text$nm
+# CHECK: lld-link: error: {{.*}}: associative comdat .text$ac1 (sec 1) has invalid reference to section .text$nm (sec 2)
# CHECK-NOT: lld-link: error:
--- !COFF
Modified: lld/trunk/test/COFF/associative-comdat-order.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/associative-comdat-order.test?rev=352428&r1=352427&r2=352428&view=diff
==============================================================================
--- lld/trunk/test/COFF/associative-comdat-order.test (original)
+++ lld/trunk/test/COFF/associative-comdat-order.test Mon Jan 28 13:16:15 2019
@@ -2,14 +2,14 @@
# associated comdat later in the file produces an error.
# RUN: sed -e s/ASSOC1/2/ -e s/ASSOC2/3/ %s | yaml2obj > %t.obj
# RUN: not lld-link /include:symbol /dll /noentry /nodefaultlib %t.obj /out:%t.exe 2>&1 | FileCheck --check-prefix=FORWARD %s
-# FORWARD: lld-link: error: {{.*}}: associative comdat .text$ac1 has invalid reference to section .text$ac2
+# FORWARD: lld-link: error: {{.*}}: associative comdat .text$ac1 (sec 1) has invalid reference to section .text$ac2 (sec 2)
# FORWARD-NOT: lld-link: error:
# Tests that an associative comdat being associated with another
# associated comdat earlier in the file produces an error.
# RUN: sed -e s/ASSOC1/3/ -e s/ASSOC2/1/ %s | yaml2obj > %t.obj
# RUN: not lld-link /include:symbol /dll /noentry /nodefaultlib %t.obj /out:%t.exe 2>&1 | FileCheck --check-prefix=BACKWARD %s
-# BACKWARD: lld-link: error: {{.*}}: associative comdat .text$ac2 has invalid reference to section .text$ac1
+# BACKWARD: lld-link: error: {{.*}}: associative comdat .text$ac2 (sec 2) has invalid reference to section .text$ac1 (sec 1)
# BACKWARD-NOT: lld-link: error:
--- !COFF
More information about the llvm-commits
mailing list