From 3ca4db23ed3bf1798e238722319633e07ed39f44 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 9 Jan 2014 04:31:18 +0000 Subject: llvm-readobj: address review comments for ARM EHABI printing Rename bytecode to opcodes to make it more clear. Change an impossible case to llvm_unreachable instead. Avoid allocation of a buffer by modifying the PrintOpcodes iteration. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198848 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-readobj/ARMEHABIPrinter.h | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'tools/llvm-readobj') diff --git a/tools/llvm-readobj/ARMEHABIPrinter.h b/tools/llvm-readobj/ARMEHABIPrinter.h index 754733f6b4..94c35b2e38 100644 --- a/tools/llvm-readobj/ARMEHABIPrinter.h +++ b/tools/llvm-readobj/ARMEHABIPrinter.h @@ -49,7 +49,7 @@ class PrinterContext { void PrintIndexTable(unsigned SectionIndex, const Elf_Shdr *IT) const; void PrintExceptionTable(const Elf_Shdr *IT, const Elf_Shdr *EHT, uint64_t TableEntryOffset) const; - void PrintByteCode(const ArrayRef ByteCode) const; + void PrintOpcodes(const uint8_t *Entry, size_t Length, off_t Offset) const; public: PrinterContext(StreamWriter &Writer, const object::ELFFile *File) @@ -148,22 +148,13 @@ void PrinterContext::PrintExceptionTable(const Elf_Shdr *IT, switch (PersonalityIndex) { case AEABI_UNWIND_CPP_PR0: - PrintByteCode(Contents->slice(TableEntryOffset + 1, 3)); + llvm_unreachable("Personality 0 should be compact inline!"); break; case AEABI_UNWIND_CPP_PR1: case AEABI_UNWIND_CPP_PR2: unsigned AdditionalWords = (Word & 0x00ff0000) >> 16; - - SmallVector ByteCode; - ByteCode.reserve(2 + 4 * AdditionalWords); - - for (unsigned WI = 1, WE = AdditionalWords; WI <= WE; ++WI) - ByteCode.append(Contents->data() + TableEntryOffset + 4 * WI, - Contents->data() + TableEntryOffset + 4 * WI + 4); - ByteCode.append(Contents->data() + TableEntryOffset, - Contents->data() + TableEntryOffset + 2); - - PrintByteCode(ArrayRef(ByteCode.begin(), ByteCode.end())); + PrintOpcodes(Contents->data() + TableEntryOffset, 2 + 4 * AdditionalWords, + 2); break; } } else { @@ -177,10 +168,11 @@ void PrinterContext::PrintExceptionTable(const Elf_Shdr *IT, } template -void PrinterContext::PrintByteCode(const ArrayRef ByteCode) const { - ListScope BC(SW, "ByteCode"); - for (unsigned BCI = 0, BCE = ByteCode.size(); BCI != BCE; ++BCI) - SW.printHex("Instruction", ByteCode[BCE - BCI - 1]); +void PrinterContext::PrintOpcodes(const uint8_t *Entry, + size_t Length, off_t Offset) const { + ListScope OCC(SW, "Opcodes"); + for (unsigned OCI = Offset; OCI < Length + Offset; OCI++) + SW.printHex("Opcode", Entry[OCI ^ 0x3]); } template @@ -234,7 +226,7 @@ void PrinterContext::PrintIndexTable(unsigned SectionIndex, unsigned PersonalityIndex = (Word1 & 0x0f000000) >> 24; SW.printNumber("PersonalityIndex", PersonalityIndex); - PrintByteCode(Contents->slice(Entry * IndexTableEntrySize + 4, 3)); + PrintOpcodes(Contents->data() + Entry * IndexTableEntrySize + 4, 3, 1); } else { const Elf_Shdr *EHT = FindExceptionTable(SectionIndex, Entry * IndexTableEntrySize + 4); -- cgit v1.2.3