Giter Club home page Giter Club logo

idp_hexagon's Introduction

Hexagon Processor Module

This is Hexagon (aka QDSP6) processor module for IDA Pro disassembler. Features:

  • Supports all Hexagon versions: V4, V5, V55, V60, V61, V62, V65, V66, V67, V67t, V68, V69, V71, V73, V75, V77, V79
  • Supports Hexagon Vector Extensions (HVX), audio extensions
  • Supports Hexagon Matrix Extensions (HMX), V66 NN extensions
  • Supports all known instructions, including undocumented ones
  • Supports ELF relocations (both static and dynamic)
  • Supports IDA v7.0-8.3

Information on instructions was mainly gathered from LLVM, whereas missing system-level instructions were taken from Programmer's Reference Manual.

Compilation

You will need the target IDA SDK (7.0, 7.2, 7.3, 7.5, 7.6, 7.7, 8.3) (password protected).
You will also need a C++17 compiler, like Visual Studio 2015/2017/2022, or any recent GCC or Clang.

Install target IDA SDK, copy hexagon folder into $SDK/module folder, and modify $SDK/module/makefile to include hexagon in ALLDIRS.
Build SDK, the resulting binary will be in $SDK/bin/procs/hexagon.dll.

Binary download

Binaries for Windows can be found under releases.

Installation

Copy the hexagon.dll file to the procs subdirectory of your IDA installation.

Usage

Start IDA, load binary and select 'Qualcomm Hexagon DSP [QDSP6]' from the processor type. In case of ELF binary just press the "Set" button.
Otherwise IDA would still sucessfully load binary, but will complain about unknown relocations.

Issues

  • In case of mixed code and data the former may have incorrect packet boundaries.
  • Some rare relocation types are not properly recognized.
  • Does not distinguish between different Hexagon versions; will disassemble instructions not supported by a particular version.
  • IDA stores flags for two operands only, and all subsequent operands will have the same flag. For example, if the 2nd operand is an offset, then 4th will be treated as offset too.
  • Xref to a stack variable has random type (r/w).
  • Some experimental instructions are not decoded.

Other Hexagon Processor modules

Author

n-o-o-n ([email protected])

License

LGPLv3. For more information see LICENSE.

History

2020-06-29 version 1.0
2020-06-30 added support for FP-based stack vars
2020-07-01 added basic support for type information; fixed warning message in IDA 7.2 ("Bad declaration..."); symbol, string and relocation tables are now shown for .so binaries
2020-07-02 added function arguments locations
2020-07-10 trace SP modification at the end of a packet
2020-07-13 added automatic comments for function arguments
2020-07-16 added switch support; version 2.0 released
2021-02-04 added support for IDA v7.3 and v7.5
2021-02-26 added support for Hexagon v68
2021-03-02 fixed analysis order; version 3.0 released
2021-06-25 fixed crashes related to missing segment registers
2021-07-12 fixed crash related to xref to a stack variable; removed PR_ALIGN flag
2021-08-13 added support for Hexagon v69 and v71; version 4.0 released
2022-01-12 added support for IDA v7.6
2022-02-03 fixed two crashes
2022-02-07 duplex instructions decoded into two separate insn_t
2022-02-14 predicate operands stored at the end of ops array; version 5.0 released
2023-03-31 added support for IDA v7.7
2023-06-26 added support for Hexagon v73; version 5.2 released
2024-05-21 added support for Hexagon v75, v77, v79; version 5.3 released
2024-05-22 added support for IDA v8.3; version 5.4 released

idp_hexagon's People

Contributors

alexander-pick avatar n-o-o-n avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

idp_hexagon's Issues

Crash on IDA 8.3

I compiled the processor module and copied it to IDA Pro 8.3, then loaded a QSDP6 elf binary and then:

Oops, IDA has almost crashed! (signum=11)
Unloading IDP module /opt/idapro-8.3/procs/hexagon64.so...

I know this is very little information, if you can supply me with hints how to give you the details necessary to fix it I will add this here :)

LPH.flags PR_ALIGN should be cleared

Although the core doesn't support unaligned mem accesses, there are many binaries containing "packed" unaligned 32-bit values (accessed as val = ptr[0] | (ptr[1]<<8) | (ptr[2]<<16) | (ptr[3]<<24)). PR_ALIGN flag prohibits converting such values to dwords/offsets. It looks safe to remove PR_ALIGN, code alignment is enforced in ana() already.

Just a question, not a "real" issue

hi,
Recently I've been looking for info about Hexagon HMX. It looks like there is rare info for this extension. Thank you for your repo and I am wondering where did you find those HMX instructions?

IDA crash...

I have tried to use the windows pre compiled - hexagon-ida75-v3.0.7z - version.
After loading Elf or even binary file ... IDA Segment View crashes ...
Any idea ?
I am using - IDA Version 7.5.201028 Windows x64 (32-bit address size)

Resolve external symbol names?

A simple test.

[ming@PC test]$ cat test.c
extern int one();

int two() 
{
  return one() + 1;
}
[ming@PC test]$ /usr/bin/llvm-objdump -d test.o

test.o:	file format elf32-hexagon

Disassembly of section .text:

00000000 <two>:
       0:	00 c0 9d a0	a09dc000 { 	allocframe(#0) } 
       4:	00 c0 00 5a	5a00c000 { 	call 0x4 } 
       8:	20 c0 00 b0	b000c020 { 	r0 = add(r0,#1) } 
       c:	1e c0 1e 96	961ec01e { 	dealloc_return } 
[ming@PC test]$ /usr/bin/llvm-objdump -x test.o

test.o:	file format elf32-hexagon
architecture: hexagon
start address: 0x00000000

Program Header:

Dynamic Section:

Sections:
Idx Name            Size     VMA      Type
  0                 00000000 00000000 
  1 .strtab         00000052 00000000 
  2 .text           00000010 00000000 TEXT
  3 .rela.text      0000000c 00000000 
  4 .comment        00000016 00000000 
  5 .note.GNU-stack 00000000 00000000 
  6 .llvm_addrsig   00000001 00000000 
  7 .symtab         00000040 00000000 

SYMBOL TABLE:
00000000 l    df *ABS*	00000000 test.c
00000000 g     F .text	00000010 two
00000000         *UND*	00000000 one

RELOCATION RECORDS FOR [.text]:
OFFSET   TYPE                     VALUE
00000004 R_HEX_B22_PCREL          one

It is displaying "call 0x4" in IDA disassembly, how can I make it "call one".
I checked the source code but I don't know what to do.
The arm/aarch64 target is fine.

Assertion failed 'op->type == o_reg'

Hi. I compiled the module with IDA SDK 7.7, but I get an assertion error when trying to load a file. It is in ana.cpp, row 146: assert( op->type == o_reg ).
If I ignore it, It loads fine.

An idea for duplex handling

A duplex can be reported to IDA as two separate insns:

  • report the first half as an insn of size 2
  • ana() will be called at ea misaligned by 2 for the second half
  • check for such misaligns && for the aligned word being a duplex, decode the second half (from a full aligned word) and report it as another insn of size 2
    Opcode bytes display would be mixed up of course (as the duplex encoding is not split nicely as 16:16), but we'd get two separate insns, each with it's own ops etc, creating instruc_t table would be possible too (no more need to represent each possible duplex combination as a separate insn).

Compile error on linux

Ubuntu 20.04.1 LTS
gcc version 9.3.0
GNU Make 4.2.1

make[2]: Entering directory '/home/ubuntu/Workspace/idasdk72/module/hexagon' g++ -m64 --shared -Wl,--no-undefined -o ../../bin/procs/hexagon.so obj/x64_linux_gcc_32/ana.o obj/x64_linux_gcc_32/emu.o obj/x64_linux_gcc_32/ins.o obj/x64_linux_gcc_32/out.o obj/x64_linux_gcc_32/reg.o obj/x64_linux_gcc_32/loader.o -L../../lib/x64_linux_gcc_32/ -lida -Wl,--build-id -Wl,--gc-sections -Wl,--warn-shared-textrel -Wl,-O1 -Wl,-Map,obj/x64_linux_gcc_32/hexagon.so.map -Wl,--version-script=../../module/exports.def -lrt -lpthread -lc /usr/bin/ld: obj/x64_linux_gcc_32/emu.o: in function jump_pattern_t::jump_pattern_t(switch_info_t*, char const (*) [4], int)':
/home/ubuntu/Workspace/idasdk72/module/hexagon/../../include/jumptable.hpp:517: undefined reference to hex_jump_pattern_t::s_depends' collect2: error: ld returned 1 exit status make[2]: *** [../../module.mak:49: ../../bin/procs/hexagon.so] Error 1 make[2]: Leaving directory '/home/ubuntu/Workspace/idasdk72/module/hexagon' make[1]: *** [makefile:57: hexagon] Error 2 make[1]: Leaving directory '/home/ubuntu/Workspace/idasdk72/module' make: *** [makefile:26: module] Error 2

IDA Blocks loading

The processor type 'QDSP6' is not included in the installed version of IDA...

but it only recognizes the binary AFTER copy this .so over.

So IDA is actually blocking this tool?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.