diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index 8a68e49477f..7effce6ab6c 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -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; } } diff --git a/include/llvm/Support/ARMAttributeParser.h b/include/llvm/Support/ARMAttributeParser.h index f6c39abb4f2..df7417f7a38 100644 --- a/include/llvm/Support/ARMAttributeParser.h +++ b/include/llvm/Support/ARMAttributeParser.h @@ -11,6 +11,7 @@ #include "ARMBuildAttributes.h" #include "ScopedPrinter.h" +#include "llvm/Support/Endian.h" #include @@ -124,7 +125,7 @@ public: ARMAttributeParser() : SW(nullptr) { } - void Parse(ArrayRef Section, bool isLittle); + void parse(ArrayRef Section, support::endianness E); bool hasAttribute(unsigned Tag) const { return Attributes.count(Tag); diff --git a/lib/Support/ARMAttributeParser.cpp b/lib/Support/ARMAttributeParser.cpp index 8a89f4c45fb..812b160c2e3 100644 --- a/lib/Support/ARMAttributeParser.cpp +++ b/lib/Support/ARMAttributeParser.cpp @@ -695,14 +695,14 @@ void ARMAttributeParser::ParseSubsection(const uint8_t *Data, uint32_t Length) { } } -void ARMAttributeParser::Parse(ArrayRef Section, bool isLittle) { +void ARMAttributeParser::parse(ArrayRef 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"; diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp index 794c4630699..93ec47751b6 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -2688,7 +2688,7 @@ template <> void ELFDumper::printAttributes() { if (Contents.size() == 1) continue; - ARMAttributeParser(&W).Parse(Contents, true); + ARMAttributeParser(&W).parse(Contents, support::little); } } diff --git a/unittests/Support/ARMAttributeParser.cpp b/unittests/Support/ARMAttributeParser.cpp index 6781acc59a7..adb36de8e66 100644 --- a/unittests/Support/ARMAttributeParser.cpp +++ b/unittests/Support/ARMAttributeParser.cpp @@ -34,7 +34,7 @@ bool testBuildAttr(unsigned Tag, unsigned Value, reinterpret_cast(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);