llvm.org GIT mirror llvm / 3ca4db2
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 Saleem Abdulrasool 6 years ago
2 changed file(s) with 37 addition(s) and 45 deletion(s). Raw diff Collapse all Expand all
9090 @ CHECK: FunctionName: __personality
9191 @ CHECK: Model: Compact (Inline)
9292 @ CHECK: PersonalityIndex: 0
93 @ CHECK: ByteCode [
94 @ CHECK: Instruction: 0xB0
95 @ CHECK: Instruction: 0xB0
96 @ CHECK: Instruction: 0xB0
93 @ CHECK: Opcodes [
94 @ CHECK: Opcode: 0xB0
95 @ CHECK: Opcode: 0xB0
96 @ CHECK: Opcode: 0xB0
9797 @ CHECK: ]
9898 @ CHECK: }
9999 @ CHECK: ]
106106 @ CHECK: FunctionName: personality0
107107 @ CHECK: Model: Compact (Inline)
108108 @ CHECK: PersonalityIndex: 0
109 @ CHECK: ByteCode [
110 @ CHECK: Instruction: 0xB0
111 @ CHECK: Instruction: 0xB0
112 @ CHECK: Instruction: 0xB0
109 @ CHECK: Opcodes [
110 @ CHECK: Opcode: 0xB0
111 @ CHECK: Opcode: 0xB0
112 @ CHECK: Opcode: 0xB0
113113 @ CHECK: ]
114114 @ CHECK: }
115115 @ CHECK: ]
124124 @ CHECK: TableEntryOffset: 0x0
125125 @ CHECK: Model: Compact
126126 @ CHECK: PersonalityIndex: 1
127 @ CHECK: ByteCode [
128 @ CHECK: Instruction: 0xB1
129 @ CHECK: Instruction: 0xF
130 @ CHECK: Instruction: 0xA7
131 @ CHECK: Instruction: 0x3F
132 @ CHECK: Instruction: 0xB0
133 @ CHECK: Instruction: 0xB0
127 @ CHECK: Opcodes [
128 @ CHECK: Opcode: 0xB1
129 @ CHECK: Opcode: 0xF
130 @ CHECK: Opcode: 0xA7
131 @ CHECK: Opcode: 0x3F
132 @ CHECK: Opcode: 0xB0
133 @ CHECK: Opcode: 0xB0
134134 @ CHECK: ]
135135 @ CHECK: }
136136 @ CHECK: ]
156156 @ CHECK: FunctionName: opcodes
157157 @ CHECK: Model: Compact (Inline)
158158 @ CHECK: PersonalityIndex: 0
159 @ CHECK: ByteCode [
160 @ CHECK: Instruction: 0xC9
161 @ CHECK: Instruction: 0x84
162 @ CHECK: Instruction: 0xB0
159 @ CHECK: Opcodes [
160 @ CHECK: Opcode: 0xC9
161 @ CHECK: Opcode: 0x84
162 @ CHECK: Opcode: 0xB0
163163 @ CHECK: ]
164164 @ CHECK: }
165165 @ CHECK: ]
172172 @ CHECK: FunctionName: function0
173173 @ CHECK: Model: Compact (Inline)
174174 @ CHECK: PersonalityIndex: 0
175 @ CHECK: ByteCode [
176 @ CHECK: Instruction: 0xB0
177 @ CHECK: Instruction: 0xB0
178 @ CHECK: Instruction: 0xB0
175 @ CHECK: Opcodes [
176 @ CHECK: Opcode: 0xB0
177 @ CHECK: Opcode: 0xB0
178 @ CHECK: Opcode: 0xB0
179179 @ CHECK: ]
180180 @ CHECK: }
181181 @ CHECK: Entry {
190190 @ CHECK: FunctionName: function2
191191 @ CHECK: Model: Compact (Inline)
192192 @ CHECK: PersonalityIndex: 0
193 @ CHECK: ByteCode [
194 @ CHECK: Instruction: 0xB0
195 @ CHECK: Instruction: 0xB0
196 @ CHECK: Instruction: 0xB0
193 @ CHECK: Opcodes [
194 @ CHECK: Opcode: 0xB0
195 @ CHECK: Opcode: 0xB0
196 @ CHECK: Opcode: 0xB0
197197 @ CHECK: ]
198198 @ CHECK: }
199199 @ CHECK: ]
4848 void PrintIndexTable(unsigned SectionIndex, const Elf_Shdr *IT) const;
4949 void PrintExceptionTable(const Elf_Shdr *IT, const Elf_Shdr *EHT,
5050 uint64_t TableEntryOffset) const;
51 void PrintByteCode(const ArrayRef ByteCode) const;
51 void PrintOpcodes(const uint8_t *Entry, size_t Length, off_t Offset) const;
5252
5353 public:
5454 PrinterContext(StreamWriter &Writer, const object::ELFFile *File)
147147
148148 switch (PersonalityIndex) {
149149 case AEABI_UNWIND_CPP_PR0:
150 PrintByteCode(Contents->slice(TableEntryOffset + 1, 3));
150 llvm_unreachable("Personality 0 should be compact inline!");
151151 break;
152152 case AEABI_UNWIND_CPP_PR1:
153153 case AEABI_UNWIND_CPP_PR2:
154154 unsigned AdditionalWords = (Word & 0x00ff0000) >> 16;
155
156 SmallVector ByteCode;
157 ByteCode.reserve(2 + 4 * AdditionalWords);
158
159 for (unsigned WI = 1, WE = AdditionalWords; WI <= WE; ++WI)
160 ByteCode.append(Contents->data() + TableEntryOffset + 4 * WI,
161 Contents->data() + TableEntryOffset + 4 * WI + 4);
162 ByteCode.append(Contents->data() + TableEntryOffset,
163 Contents->data() + TableEntryOffset + 2);
164
165 PrintByteCode(ArrayRef(ByteCode.begin(), ByteCode.end()));
155 PrintOpcodes(Contents->data() + TableEntryOffset, 2 + 4 * AdditionalWords,
156 2);
166157 break;
167158 }
168159 } else {
176167 }
177168
178169 template
179 void PrinterContext::PrintByteCode(const ArrayRef ByteCode) const {
180 ListScope BC(SW, "ByteCode");
181 for (unsigned BCI = 0, BCE = ByteCode.size(); BCI != BCE; ++BCI)
182 SW.printHex("Instruction", ByteCode[BCE - BCI - 1]);
170 void PrinterContext::PrintOpcodes(const uint8_t *Entry,
171 size_t Length, off_t Offset) const {
172 ListScope OCC(SW, "Opcodes");
173 for (unsigned OCI = Offset; OCI < Length + Offset; OCI++)
174 SW.printHex("Opcode", Entry[OCI ^ 0x3]);
183175 }
184176
185177 template
233225 unsigned PersonalityIndex = (Word1 & 0x0f000000) >> 24;
234226 SW.printNumber("PersonalityIndex", PersonalityIndex);
235227
236 PrintByteCode(Contents->slice(Entry * IndexTableEntrySize + 4, 3));
228 PrintOpcodes(Contents->data() + Entry * IndexTableEntrySize + 4, 3, 1);
237229 } else {
238230 const Elf_Shdr *EHT =
239231 FindExceptionTable(SectionIndex, Entry * IndexTableEntrySize + 4);