mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[ARM] Change ARMAttributeParser::Parse to use support::endianness and simplify
This commit is contained in:
parent
3f406340ef
commit
318004ba1e
@ -380,7 +380,7 @@ protected:
|
||||
if (Contents[0] != ARMBuildAttrs::Format_Version || Contents.size() == 1)
|
||||
return Error::success();
|
||||
|
||||
Attributes.Parse(Contents, ELFT::TargetEndianness == support::little);
|
||||
Attributes.parse(Contents, ELFT::TargetEndianness);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include "ARMBuildAttributes.h"
|
||||
#include "ScopedPrinter.h"
|
||||
#include "llvm/Support/Endian.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
@ -124,7 +125,7 @@ public:
|
||||
|
||||
ARMAttributeParser() : SW(nullptr) { }
|
||||
|
||||
void Parse(ArrayRef<uint8_t> Section, bool isLittle);
|
||||
void parse(ArrayRef<uint8_t> Section, support::endianness E);
|
||||
|
||||
bool hasAttribute(unsigned Tag) const {
|
||||
return Attributes.count(Tag);
|
||||
|
@ -695,14 +695,14 @@ void ARMAttributeParser::ParseSubsection(const uint8_t *Data, uint32_t Length) {
|
||||
}
|
||||
}
|
||||
|
||||
void ARMAttributeParser::Parse(ArrayRef<uint8_t> Section, bool isLittle) {
|
||||
void ARMAttributeParser::parse(ArrayRef<uint8_t> Section,
|
||||
support::endianness E) {
|
||||
uint64_t Offset = 1;
|
||||
unsigned SectionNumber = 0;
|
||||
|
||||
while (Offset < Section.size()) {
|
||||
uint32_t SectionLength = isLittle ?
|
||||
support::endian::read32le(Section.data() + Offset) :
|
||||
support::endian::read32be(Section.data() + Offset);
|
||||
uint32_t SectionLength =
|
||||
support::endian::read32(Section.data() + Offset, E);
|
||||
|
||||
if (SW) {
|
||||
SW->startLine() << "Section " << ++SectionNumber << " {\n";
|
||||
|
@ -2688,7 +2688,7 @@ template <> void ELFDumper<ELF32LE>::printAttributes() {
|
||||
if (Contents.size() == 1)
|
||||
continue;
|
||||
|
||||
ARMAttributeParser(&W).Parse(Contents, true);
|
||||
ARMAttributeParser(&W).parse(Contents, support::little);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ bool testBuildAttr(unsigned Tag, unsigned Value,
|
||||
reinterpret_cast<const uint8_t*>(OS.str().c_str()), OS.str().size());
|
||||
|
||||
ARMAttributeParser Parser;
|
||||
Parser.Parse(Bytes, true);
|
||||
Parser.parse(Bytes, support::little);
|
||||
|
||||
return (Parser.hasAttribute(ExpectedTag) &&
|
||||
Parser.getAttributeValue(ExpectedTag) == ExpectedValue);
|
||||
|
Loading…
Reference in New Issue
Block a user