mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[PDB] Simplify API for making section map, NFC
Prevents API misuse described in PR44495
This commit is contained in:
parent
37207e405d
commit
af435f4dd3
@ -57,7 +57,6 @@ public:
|
||||
void setFlags(uint16_t F);
|
||||
void setMachineType(PDB_Machine M);
|
||||
void setMachineType(COFF::MachineTypes M);
|
||||
void setSectionMap(ArrayRef<SecMapEntry> SecMap);
|
||||
|
||||
// Add given bytes as a new stream.
|
||||
Error addDbgStream(pdb::DbgHeaderType Type, ArrayRef<uint8_t> Data);
|
||||
@ -84,9 +83,8 @@ public:
|
||||
SectionContribs.emplace_back(SC);
|
||||
}
|
||||
|
||||
// A helper function to create a Section Map from a COFF section header.
|
||||
static std::vector<SecMapEntry>
|
||||
createSectionMap(ArrayRef<llvm::object::coff_section> SecHdrs);
|
||||
// Populate the Section Map from COFF section headers.
|
||||
void createSectionMap(ArrayRef<llvm::object::coff_section> SecHdrs);
|
||||
|
||||
private:
|
||||
struct DebugStream {
|
||||
@ -133,7 +131,7 @@ private:
|
||||
WritableBinaryStreamRef NamesBuffer;
|
||||
MutableBinaryByteStream FileInfoBuffer;
|
||||
std::vector<SectionContrib> SectionContribs;
|
||||
ArrayRef<SecMapEntry> SectionMap;
|
||||
std::vector<SecMapEntry> SectionMap;
|
||||
std::array<Optional<DebugStream>, (int)DbgHeaderType::Max> DbgStreams;
|
||||
};
|
||||
}
|
||||
|
@ -58,10 +58,6 @@ void DbiStreamBuilder::setMachineType(COFF::MachineTypes M) {
|
||||
MachineType = static_cast<pdb::PDB_Machine>(static_cast<unsigned>(M));
|
||||
}
|
||||
|
||||
void DbiStreamBuilder::setSectionMap(ArrayRef<SecMapEntry> SecMap) {
|
||||
SectionMap = SecMap;
|
||||
}
|
||||
|
||||
void DbiStreamBuilder::setGlobalsStreamIndex(uint32_t Index) {
|
||||
GlobalsStreamIndex = Index;
|
||||
}
|
||||
@ -348,19 +344,18 @@ static uint16_t toSecMapFlags(uint32_t Flags) {
|
||||
return Ret;
|
||||
}
|
||||
|
||||
// A utility function to create a Section Map for a given list of COFF sections.
|
||||
// Populate the Section Map from COFF section headers.
|
||||
//
|
||||
// A Section Map seem to be a copy of a COFF section list in other format.
|
||||
// I don't know why a PDB file contains both a COFF section header and
|
||||
// a Section Map, but it seems it must be present in a PDB.
|
||||
std::vector<SecMapEntry> DbiStreamBuilder::createSectionMap(
|
||||
void DbiStreamBuilder::createSectionMap(
|
||||
ArrayRef<llvm::object::coff_section> SecHdrs) {
|
||||
std::vector<SecMapEntry> Ret;
|
||||
int Idx = 0;
|
||||
|
||||
auto Add = [&]() -> SecMapEntry & {
|
||||
Ret.emplace_back();
|
||||
auto &Entry = Ret.back();
|
||||
SectionMap.emplace_back();
|
||||
auto &Entry = SectionMap.back();
|
||||
memset(&Entry, 0, sizeof(Entry));
|
||||
|
||||
Entry.Frame = Idx + 1;
|
||||
@ -384,8 +379,6 @@ std::vector<SecMapEntry> DbiStreamBuilder::createSectionMap(
|
||||
Entry.Flags = static_cast<uint16_t>(OMFSegDescFlags::AddressIs32Bit) |
|
||||
static_cast<uint16_t>(OMFSegDescFlags::IsAbsoluteAddress);
|
||||
Entry.SecByteLength = UINT32_MAX;
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
Error DbiStreamBuilder::commit(const msf::MSFLayout &Layout,
|
||||
@ -417,7 +410,7 @@ Error DbiStreamBuilder::commit(const msf::MSFLayout &Layout,
|
||||
SecMapHeader SMHeader = {Size, Size};
|
||||
if (auto EC = Writer.writeObject(SMHeader))
|
||||
return EC;
|
||||
if (auto EC = Writer.writeArray(SectionMap))
|
||||
if (auto EC = Writer.writeArray(makeArrayRef(SectionMap)))
|
||||
return EC;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user