mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
Add BinaryRef binary_size() method.
This avoids making assumptions about the data representation. llvm-svn: 183349
This commit is contained in:
parent
016cf70a05
commit
5d76fe26c7
@ -43,6 +43,13 @@ public:
|
||||
assert(isBinary);
|
||||
return Data;
|
||||
}
|
||||
/// \brief The number of bytes that are represented by this BinaryRef.
|
||||
/// This is the number of bytes that writeAsBinary() will write.
|
||||
ArrayRef<uint8_t>::size_type binary_size() const {
|
||||
if (!isBinary)
|
||||
return Data.size() / 2;
|
||||
return Data.size();
|
||||
}
|
||||
bool operator==(const BinaryRef &Ref) {
|
||||
// Special case for default constructed BinaryRef.
|
||||
if (Ref.Data.empty() && Data.empty())
|
||||
|
@ -129,9 +129,8 @@ static bool layoutCOFF(COFFParser &CP) {
|
||||
for (std::vector<COFFYAML::Section>::iterator i = CP.Obj.Sections.begin(),
|
||||
e = CP.Obj.Sections.end();
|
||||
i != e; ++i) {
|
||||
StringRef SecData = i->SectionData.getHex();
|
||||
if (!SecData.empty()) {
|
||||
i->Header.SizeOfRawData = SecData.size()/2;
|
||||
if (i->SectionData.binary_size() > 0) {
|
||||
i->Header.SizeOfRawData = i->SectionData.binary_size();
|
||||
i->Header.PointerToRawData = CurrentSectionDataOffset;
|
||||
CurrentSectionDataOffset += i->Header.SizeOfRawData;
|
||||
if (!i->Relocations.empty()) {
|
||||
@ -154,7 +153,7 @@ static bool layoutCOFF(COFFParser &CP) {
|
||||
for (std::vector<COFFYAML::Symbol>::iterator i = CP.Obj.Symbols.begin(),
|
||||
e = CP.Obj.Symbols.end();
|
||||
i != e; ++i) {
|
||||
unsigned AuxBytes = i->AuxiliaryData.getHex().size() / 2;
|
||||
unsigned AuxBytes = i->AuxiliaryData.binary_size();
|
||||
if (AuxBytes % COFF::SymbolSize != 0) {
|
||||
errs() << "AuxiliaryData size not a multiple of symbol size!\n";
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user