forked from OSchip/llvm-project
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. llvm-svn: 352428
This commit is contained in:
parent
4ecdb70424
commit
38170e444f
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue