1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[ARM] Change ARMAttributeParser::Parse to use support::endianness and simplify

This commit is contained in:
Fangrui Song 2020-02-21 10:55:12 -08:00
parent 3f406340ef
commit 318004ba1e
5 changed files with 9 additions and 8 deletions

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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";

View File

@ -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);
}
}

View File

@ -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);