[lld] [LLD] [COFF] Fix handling of comdat .drectve sections (PR #68116)
Alexandre Ganea via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 3 10:41:26 PDT 2023
================
@@ -660,10 +660,15 @@ std::optional<Symbol *> ObjFile::createDefined(
if (prevailing) {
SectionChunk *c = readSection(sectionNumber, def, getName());
- sparseChunks[sectionNumber] = c;
- c->sym = cast<DefinedRegular>(leader);
- c->selection = selection;
- cast<DefinedRegular>(leader)->data = &c->repl;
+ if (c) {
+ sparseChunks[sectionNumber] = c;
+ c->sym = cast<DefinedRegular>(leader);
+ c->selection = selection;
+ cast<DefinedRegular>(leader)->data = &c->repl;
+ } else {
+ sparseChunks[sectionNumber] = nullptr;
+ return nullptr;
+ }
} else {
sparseChunks[sectionNumber] = nullptr;
----------------
aganea wrote:
I debugged this code too, a while bit ago for https://reviews.llvm.org/D157136 and let's say, the way data flows isn't simple (even if the input data format is simple). Lots of interactions until things converge into place. I always wondered if instead of imperative code for a linker, if a data graph would be easier to follow.
https://github.com/llvm/llvm-project/pull/68116
More information about the llvm-commits
mailing list