mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-23 01:30:19 +00:00
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
This commit is contained in:
parent
fe097bffa7
commit
3ca4db23ed
@ -91,10 +91,10 @@ function2:
|
|||||||
@ CHECK: FunctionName: __personality
|
@ CHECK: FunctionName: __personality
|
||||||
@ CHECK: Model: Compact (Inline)
|
@ CHECK: Model: Compact (Inline)
|
||||||
@ CHECK: PersonalityIndex: 0
|
@ CHECK: PersonalityIndex: 0
|
||||||
@ CHECK: ByteCode [
|
@ CHECK: Opcodes [
|
||||||
@ CHECK: Instruction: 0xB0
|
@ CHECK: Opcode: 0xB0
|
||||||
@ CHECK: Instruction: 0xB0
|
@ CHECK: Opcode: 0xB0
|
||||||
@ CHECK: Instruction: 0xB0
|
@ CHECK: Opcode: 0xB0
|
||||||
@ CHECK: ]
|
@ CHECK: ]
|
||||||
@ CHECK: }
|
@ CHECK: }
|
||||||
@ CHECK: ]
|
@ CHECK: ]
|
||||||
@ -107,10 +107,10 @@ function2:
|
|||||||
@ CHECK: FunctionName: personality0
|
@ CHECK: FunctionName: personality0
|
||||||
@ CHECK: Model: Compact (Inline)
|
@ CHECK: Model: Compact (Inline)
|
||||||
@ CHECK: PersonalityIndex: 0
|
@ CHECK: PersonalityIndex: 0
|
||||||
@ CHECK: ByteCode [
|
@ CHECK: Opcodes [
|
||||||
@ CHECK: Instruction: 0xB0
|
@ CHECK: Opcode: 0xB0
|
||||||
@ CHECK: Instruction: 0xB0
|
@ CHECK: Opcode: 0xB0
|
||||||
@ CHECK: Instruction: 0xB0
|
@ CHECK: Opcode: 0xB0
|
||||||
@ CHECK: ]
|
@ CHECK: ]
|
||||||
@ CHECK: }
|
@ CHECK: }
|
||||||
@ CHECK: ]
|
@ CHECK: ]
|
||||||
@ -125,13 +125,13 @@ function2:
|
|||||||
@ CHECK: TableEntryOffset: 0x0
|
@ CHECK: TableEntryOffset: 0x0
|
||||||
@ CHECK: Model: Compact
|
@ CHECK: Model: Compact
|
||||||
@ CHECK: PersonalityIndex: 1
|
@ CHECK: PersonalityIndex: 1
|
||||||
@ CHECK: ByteCode [
|
@ CHECK: Opcodes [
|
||||||
@ CHECK: Instruction: 0xB1
|
@ CHECK: Opcode: 0xB1
|
||||||
@ CHECK: Instruction: 0xF
|
@ CHECK: Opcode: 0xF
|
||||||
@ CHECK: Instruction: 0xA7
|
@ CHECK: Opcode: 0xA7
|
||||||
@ CHECK: Instruction: 0x3F
|
@ CHECK: Opcode: 0x3F
|
||||||
@ CHECK: Instruction: 0xB0
|
@ CHECK: Opcode: 0xB0
|
||||||
@ CHECK: Instruction: 0xB0
|
@ CHECK: Opcode: 0xB0
|
||||||
@ CHECK: ]
|
@ CHECK: ]
|
||||||
@ CHECK: }
|
@ CHECK: }
|
||||||
@ CHECK: ]
|
@ CHECK: ]
|
||||||
@ -157,10 +157,10 @@ function2:
|
|||||||
@ CHECK: FunctionName: opcodes
|
@ CHECK: FunctionName: opcodes
|
||||||
@ CHECK: Model: Compact (Inline)
|
@ CHECK: Model: Compact (Inline)
|
||||||
@ CHECK: PersonalityIndex: 0
|
@ CHECK: PersonalityIndex: 0
|
||||||
@ CHECK: ByteCode [
|
@ CHECK: Opcodes [
|
||||||
@ CHECK: Instruction: 0xC9
|
@ CHECK: Opcode: 0xC9
|
||||||
@ CHECK: Instruction: 0x84
|
@ CHECK: Opcode: 0x84
|
||||||
@ CHECK: Instruction: 0xB0
|
@ CHECK: Opcode: 0xB0
|
||||||
@ CHECK: ]
|
@ CHECK: ]
|
||||||
@ CHECK: }
|
@ CHECK: }
|
||||||
@ CHECK: ]
|
@ CHECK: ]
|
||||||
@ -173,10 +173,10 @@ function2:
|
|||||||
@ CHECK: FunctionName: function0
|
@ CHECK: FunctionName: function0
|
||||||
@ CHECK: Model: Compact (Inline)
|
@ CHECK: Model: Compact (Inline)
|
||||||
@ CHECK: PersonalityIndex: 0
|
@ CHECK: PersonalityIndex: 0
|
||||||
@ CHECK: ByteCode [
|
@ CHECK: Opcodes [
|
||||||
@ CHECK: Instruction: 0xB0
|
@ CHECK: Opcode: 0xB0
|
||||||
@ CHECK: Instruction: 0xB0
|
@ CHECK: Opcode: 0xB0
|
||||||
@ CHECK: Instruction: 0xB0
|
@ CHECK: Opcode: 0xB0
|
||||||
@ CHECK: ]
|
@ CHECK: ]
|
||||||
@ CHECK: }
|
@ CHECK: }
|
||||||
@ CHECK: Entry {
|
@ CHECK: Entry {
|
||||||
@ -191,10 +191,10 @@ function2:
|
|||||||
@ CHECK: FunctionName: function2
|
@ CHECK: FunctionName: function2
|
||||||
@ CHECK: Model: Compact (Inline)
|
@ CHECK: Model: Compact (Inline)
|
||||||
@ CHECK: PersonalityIndex: 0
|
@ CHECK: PersonalityIndex: 0
|
||||||
@ CHECK: ByteCode [
|
@ CHECK: Opcodes [
|
||||||
@ CHECK: Instruction: 0xB0
|
@ CHECK: Opcode: 0xB0
|
||||||
@ CHECK: Instruction: 0xB0
|
@ CHECK: Opcode: 0xB0
|
||||||
@ CHECK: Instruction: 0xB0
|
@ CHECK: Opcode: 0xB0
|
||||||
@ CHECK: ]
|
@ CHECK: ]
|
||||||
@ CHECK: }
|
@ CHECK: }
|
||||||
@ CHECK: ]
|
@ CHECK: ]
|
||||||
|
@ -49,7 +49,7 @@ class PrinterContext {
|
|||||||
void PrintIndexTable(unsigned SectionIndex, const Elf_Shdr *IT) const;
|
void PrintIndexTable(unsigned SectionIndex, const Elf_Shdr *IT) const;
|
||||||
void PrintExceptionTable(const Elf_Shdr *IT, const Elf_Shdr *EHT,
|
void PrintExceptionTable(const Elf_Shdr *IT, const Elf_Shdr *EHT,
|
||||||
uint64_t TableEntryOffset) const;
|
uint64_t TableEntryOffset) const;
|
||||||
void PrintByteCode(const ArrayRef<uint8_t> ByteCode) const;
|
void PrintOpcodes(const uint8_t *Entry, size_t Length, off_t Offset) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PrinterContext(StreamWriter &Writer, const object::ELFFile<ET> *File)
|
PrinterContext(StreamWriter &Writer, const object::ELFFile<ET> *File)
|
||||||
@ -148,22 +148,13 @@ void PrinterContext<ET>::PrintExceptionTable(const Elf_Shdr *IT,
|
|||||||
|
|
||||||
switch (PersonalityIndex) {
|
switch (PersonalityIndex) {
|
||||||
case AEABI_UNWIND_CPP_PR0:
|
case AEABI_UNWIND_CPP_PR0:
|
||||||
PrintByteCode(Contents->slice(TableEntryOffset + 1, 3));
|
llvm_unreachable("Personality 0 should be compact inline!");
|
||||||
break;
|
break;
|
||||||
case AEABI_UNWIND_CPP_PR1:
|
case AEABI_UNWIND_CPP_PR1:
|
||||||
case AEABI_UNWIND_CPP_PR2:
|
case AEABI_UNWIND_CPP_PR2:
|
||||||
unsigned AdditionalWords = (Word & 0x00ff0000) >> 16;
|
unsigned AdditionalWords = (Word & 0x00ff0000) >> 16;
|
||||||
|
PrintOpcodes(Contents->data() + TableEntryOffset, 2 + 4 * AdditionalWords,
|
||||||
SmallVector<uint8_t, 10> ByteCode;
|
2);
|
||||||
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<uint8_t>(ByteCode.begin(), ByteCode.end()));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -177,10 +168,11 @@ void PrinterContext<ET>::PrintExceptionTable(const Elf_Shdr *IT,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename ET>
|
template <typename ET>
|
||||||
void PrinterContext<ET>::PrintByteCode(const ArrayRef<uint8_t> ByteCode) const {
|
void PrinterContext<ET>::PrintOpcodes(const uint8_t *Entry,
|
||||||
ListScope BC(SW, "ByteCode");
|
size_t Length, off_t Offset) const {
|
||||||
for (unsigned BCI = 0, BCE = ByteCode.size(); BCI != BCE; ++BCI)
|
ListScope OCC(SW, "Opcodes");
|
||||||
SW.printHex("Instruction", ByteCode[BCE - BCI - 1]);
|
for (unsigned OCI = Offset; OCI < Length + Offset; OCI++)
|
||||||
|
SW.printHex("Opcode", Entry[OCI ^ 0x3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ET>
|
template <typename ET>
|
||||||
@ -234,7 +226,7 @@ void PrinterContext<ET>::PrintIndexTable(unsigned SectionIndex,
|
|||||||
unsigned PersonalityIndex = (Word1 & 0x0f000000) >> 24;
|
unsigned PersonalityIndex = (Word1 & 0x0f000000) >> 24;
|
||||||
SW.printNumber("PersonalityIndex", PersonalityIndex);
|
SW.printNumber("PersonalityIndex", PersonalityIndex);
|
||||||
|
|
||||||
PrintByteCode(Contents->slice(Entry * IndexTableEntrySize + 4, 3));
|
PrintOpcodes(Contents->data() + Entry * IndexTableEntrySize + 4, 3, 1);
|
||||||
} else {
|
} else {
|
||||||
const Elf_Shdr *EHT =
|
const Elf_Shdr *EHT =
|
||||||
FindExceptionTable(SectionIndex, Entry * IndexTableEntrySize + 4);
|
FindExceptionTable(SectionIndex, Entry * IndexTableEntrySize + 4);
|
||||||
|
Loading…
Reference in New Issue
Block a user