Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions llvm/test/tools/llvm-objdump/ELF/Hexagon/truncated-inst.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Test disassembling of truncated instructions.

# RUN: yaml2obj %s -o %t
# RUN: llvm-objdump --disassemble-all %t 2>&1 | FileCheck %s

# CHECK: 0000000 <.data>:
# CHECK-NEXT: 0: 55 <unknown>

--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_HEXAGON
Sections:
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
AddressAlign: 0x1
Content: 55
- Type: SectionHeaderTable
Sections:
- Name: .data
- Name: .strtab
- Name: .shstrtab
...
12 changes: 8 additions & 4 deletions llvm/tools/llvm-objdump/llvm-objdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,14 +700,18 @@ class HexagonPrettyPrinter : public PrettyPrinter {
public:
void printLead(ArrayRef<uint8_t> Bytes, uint64_t Address,
formatted_raw_ostream &OS) {
uint32_t opcode =
(Bytes[3] << 24) | (Bytes[2] << 16) | (Bytes[1] << 8) | Bytes[0];
if (LeadingAddr)
OS << format("%8" PRIx64 ":", Address);
if (ShowRawInsn) {
OS << "\t";
dumpBytes(Bytes.slice(0, 4), OS);
OS << format("\t%08" PRIx32, opcode);
if (Bytes.size() >= 4) {
dumpBytes(Bytes.slice(0, 4), OS);
uint32_t opcode =
(Bytes[3] << 24) | (Bytes[2] << 16) | (Bytes[1] << 8) | Bytes[0];
OS << format("\t%08" PRIx32, opcode);
} else {
dumpBytes(Bytes, OS);
}
}
}
void printInst(MCInstPrinter &IP, const MCInst *MI, ArrayRef<uint8_t> Bytes,
Expand Down
Loading