Reinstate use of FakeSection class to avoid constructing SectionChunk
from unintialised coff_section in FakeSectionChunk constructor.
Issue was caused by commit
5a58b19f9c93f3ac51bcde318508131ae78aa10c,
"[LLD] Remove global state in lld/COFF".
namespace lld::coff {
COFFLinkerContext::COFFLinkerContext()
: driver(*this), symtab(*this),
- ltoTextSectionChunk(llvm::COFF::IMAGE_SCN_MEM_EXECUTE),
- ltoDataSectionChunk(llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA),
+ ltoTextSection(llvm::COFF::IMAGE_SCN_MEM_EXECUTE),
+ ltoDataSection(llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA),
+ ltoTextSectionChunk(<oTextSection.section),
+ ltoDataSectionChunk(<oDataSection.section),
rootTimer("Total Linking Time"),
inputFileTimer("Input File Reading", rootTimer),
ltoTimer("LTO", rootTimer), gcTimer("GC", rootTimer),
}
// Fake sections for parsing bitcode files.
+ FakeSection ltoTextSection;
+ FakeSection ltoDataSection;
FakeSectionChunk ltoTextSectionChunk;
FakeSectionChunk ltoDataSectionChunk;
void applyArm64Imm(uint8_t *off, uint64_t imm, uint32_t rangeLimit);
void applyArm64Branch26(uint8_t *off, int64_t v);
+// Convenience class for initializing a coff_section with specific flags.
+class FakeSection {
+public:
+ FakeSection(int c) { section.Characteristics = c; }
+
+ coff_section section;
+};
+
// Convenience class for initializing a SectionChunk with specific flags.
class FakeSectionChunk {
public:
- FakeSectionChunk(int c) : chunk(nullptr, §ion) {
- section.Characteristics = c;
+ FakeSectionChunk(const coff_section *section) : chunk(nullptr, section) {
// Comdats from LTO files can't be fully treated as regular comdats
// at this point; we don't know what size or contents they are going to
// have, so we can't do proper checking of such aspects of them.
chunk.selection = llvm::COFF::IMAGE_COMDAT_SELECT_ANY;
}
- coff_section section;
SectionChunk chunk;
};