diff options
author | Alexey Karyakin <akaryaki@quicinc.com> | 2025-05-30 12:10:11 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-30 12:10:11 -0500 |
commit | c87edaf99b18821e5278eb7b46b92cb67fc8d10c (patch) | |
tree | 3a340088bd4da59ec526b5e87d7055284fbf186b /llvm/tools/llvm-objdump | |
parent | a236dc63bf467edeae07c96a9157cf57570fb5ba (diff) | |
download | llvm-c87edaf99b18821e5278eb7b46b92cb67fc8d10c.zip llvm-c87edaf99b18821e5278eb7b46b92cb67fc8d10c.tar.gz llvm-c87edaf99b18821e5278eb7b46b92cb67fc8d10c.tar.bz2 |
[Hexagon][llvm-objdump] Fix crash at a truncated instruction (#142082)
Fixes #141740.
Co-authored-by: Alexey Karyakin <quic-akaryaki@quicinc.com>
Co-authored-by: Sudharsan Veeravalli <quic_svs@quicinc.com>
Diffstat (limited to 'llvm/tools/llvm-objdump')
-rw-r--r-- | llvm/tools/llvm-objdump/llvm-objdump.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 85c455b..5ecb333 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -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, |