If /debug was not specified, readSection will return a null
pointer for debug sections. If the debug section is associative with
another section, we need to make sure that the section returned from
readSection is not a null pointer before adding it as an associative
section.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
Diff against previous patch:
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp index 0ecfbdaf7373..d0c7bcaefe06 100644 --- a/lld/COFF/InputFiles.cpp +++ b/lld/COFF/InputFiles.cpp @@ -208,7 +208,8 @@ void ObjFile::readAssociativeDefinition( int32_t SectionNumber = Sym.getSectionNumber(); if (Parent) { SparseChunks[SectionNumber] = readSection(SectionNumber, Def); - Parent->addAssociative(SparseChunks[SectionNumber]); + if (SparseChunks[SectionNumber]) + Parent->addAssociative(SparseChunks[SectionNumber]); } else { SparseChunks[SectionNumber] = nullptr; } diff --git a/lld/test/COFF/pdb-comdat.test b/lld/test/COFF/pdb-comdat.test index a3283d206ab8..655f215e0199 100644 --- a/lld/test/COFF/pdb-comdat.test +++ b/lld/test/COFF/pdb-comdat.test @@ -107,3 +107,6 @@ REORDER-LABEL: Mod 0001 | `{{.*}}pdb_comdat_main.obj`: REORDER: c:\src\llvm-project\build\pdb_comdat_main.c REORDER-NOT: c:\src\llvm-project\build\foo.h REORDER-LABEL: Mod 0002 | `* Linker *`: + +Make sure that we don't crash on non-prevailing debug sections if -debug is not enabled. +RUN: lld-link pdb_comdat_main.obj pdb_comdat_bar.obj -out:%t.exe -nodefaultlib -entry:main