fix: fix section stream.
This commit is contained in:
@@ -52,6 +52,16 @@ size_t COFF::SectionIndex(uint64_t Offset) const {
|
||||
throw std::runtime_error("Offset is not in any section.");
|
||||
}
|
||||
|
||||
object::coff_section* COFF::SectionTable() {
|
||||
return reinterpret_cast<object::coff_section*>(
|
||||
OwningCOFF().section_begin()->getRawDataRefImpl().p
|
||||
);
|
||||
}
|
||||
|
||||
uint32_t COFF::NumberOfSections() const {
|
||||
return OwningCOFF().getNumberOfSections();
|
||||
}
|
||||
|
||||
object::COFFObjectFile const& COFF::OwningCOFF() const {
|
||||
return *OwningBinary.getBinary();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,10 @@ public:
|
||||
explicit COFF(std::string_view Path);
|
||||
|
||||
codeview::PDB70DebugInfo DebugInfo() const;
|
||||
size_t SectionIndex(uint64_t Offset) const;
|
||||
|
||||
size_t SectionIndex(uint64_t Offset) const;
|
||||
object::coff_section* SectionTable();
|
||||
uint32_t NumberOfSections() const;
|
||||
|
||||
object::COFFObjectFile const& OwningCOFF() const;
|
||||
|
||||
|
||||
@@ -64,6 +64,27 @@ void PDB::BuildDBI() {
|
||||
DbiBuilder.setMachineType(PDB_Machine::Amd64);
|
||||
DbiBuilder.setFlags(DbiFlags::FlagStrippedMask);
|
||||
DbiBuilder.setBuildNumber(14, 11); // LLVM is compatible with LINK 14.11
|
||||
|
||||
// Add sections.
|
||||
auto SectionTable = OwningCOFF.SectionTable();
|
||||
auto NumberOfSections = OwningCOFF.NumberOfSections();
|
||||
|
||||
auto SectionDataRef = ArrayRef<uint8_t>(
|
||||
(uint8_t*)SectionTable,
|
||||
OwningCOFF.NumberOfSections() * sizeof(object::coff_section)
|
||||
);
|
||||
|
||||
auto SectionTableRef = ArrayRef<object::coff_section>(
|
||||
(const object::coff_section*)SectionDataRef.data(),
|
||||
NumberOfSections
|
||||
);
|
||||
|
||||
DbiBuilder.createSectionMap(SectionTableRef);
|
||||
|
||||
// Add COFF section header stream.
|
||||
if (DbiBuilder.addDbgStream(DbgHeaderType::SectionHdr, SectionDataRef)) {
|
||||
throw std::runtime_error("Failed to add dbg stream.");
|
||||
}
|
||||
}
|
||||
|
||||
void PDB::BuildTPI() {
|
||||
|
||||
Reference in New Issue
Block a user