diff options
-rw-r--r-- | lld/COFF/InputFiles.cpp | 7 | ||||
-rw-r--r-- | lld/test/COFF/associative-comdat-empty.test | 2 | ||||
-rw-r--r-- | lld/test/COFF/associative-comdat-order.test | 4 |
3 files changed, 7 insertions, 6 deletions
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp index 4b87e02a6dd..6d4cb4e1c49 100644 --- a/lld/COFF/InputFiles.cpp +++ b/lld/COFF/InputFiles.cpp @@ -225,6 +225,7 @@ void ObjFile::readAssociativeDefinition(COFFSymbolRef Sym, 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(COFFSymbolRef Sym, 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(COFFSymbolRef Sym, // 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(); diff --git a/lld/test/COFF/associative-comdat-empty.test b/lld/test/COFF/associative-comdat-empty.test index 1499d9074c7..c4ee8b7256f 100644 --- a/lld/test/COFF/associative-comdat-empty.test +++ b/lld/test/COFF/associative-comdat-empty.test @@ -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 diff --git a/lld/test/COFF/associative-comdat-order.test b/lld/test/COFF/associative-comdat-order.test index 09b1b460215..dc58c2c1024 100644 --- a/lld/test/COFF/associative-comdat-order.test +++ b/lld/test/COFF/associative-comdat-order.test @@ -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 |