Skip to content

Commit 6d5a8bd

Browse files
committed
Updated hexagon module for IDAPro v7.0
1 parent ead9f96 commit 6d5a8bd

File tree

7 files changed

+3697
-826
lines changed

7 files changed

+3697
-826
lines changed

Makefile.linux

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,63 +5,58 @@ all:
55
# I put some not yet published targets in this optional include
66
-include Makefile.extra
77

8-
CXX=clang++
9-
CC=clang
10-
LD=clang++
8+
#CXX=clang++-5.0
9+
#CC=clang-5.0
10+
#LD=clang++-5.0
1111

12-
TARGETS+=hexagon.ilx
12+
TARGETS+=hexagon.so
1313

1414
# where the quicinc objdump source can be found
1515
gnutools= hx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03
1616

1717
gnutoolsincludes=-I $(gnutools)/include -I $(gnutools)/bfd -I $(gnutools)/include/opcode
1818
gnutoolsincludes+=-I ./build-mac/opcodes -I ./build-mac/bfd
19-
CFLAGS=-g -D__MAC__ -D__IDP__ -I $(idasdk)/include
19+
CFLAGS=-g -D__LINUX__ -D__IDP__ -D__X64__ -I $(idasdk)/include
2020
CFLAGS+=-DUSE_STANDARD_FILE_FUNCTIONS
2121
CFLAGS+=-DUSE_DANGEROUS_FUNCTIONS
2222
CFLAGS+=-D_FORTIFY_SOURCE=0
23-
CFLAGS+=-O0 -g -fpic
23+
CFLAGS+=-fPIC
24+
CFLAGS+=-g $(if $(D),-O0,-O2)
2425

2526
# add this flag when you want verbose logging
2627
#CFLAGS+=-DTRACELOG
2728

2829
all: $(TARGETS)
2930

30-
hexagon.ilx: hexagon.o32 gt_safe-ctype.o32 gt_hexagon-dis.o32 gt_hexagon-opc.o32 gt_hexagon-isa.o32 bfd_funcs.o32 gt_cpu-hexagon.o32 dummy-scan.o32
31+
hexagon.so: hexagon.o gt_safe-ctype.o gt_hexagon-dis.o gt_hexagon-opc.o gt_hexagon-isa.o bfd_funcs.o gt_cpu-hexagon.o dummy-scan.o
32+
3133
cflags_cpu-hexagon= $(gnutoolsincludes)
3234
cflags_hexagon= $(gnutoolsincludes)
3335
cflags_bfd_funcs= $(gnutoolsincludes)
3436

35-
install: hexagon.ilx
37+
install: hexagon.so
3638
cp $^ "$(idabin)/procs"
3739

3840
clean:
39-
$(RM) $(TARGETS) $(wildcard *.o) $(wildcard *.o32)
40-
41+
$(RM) $(TARGETS) $(wildcard *.o) $(wildcard *.o)
4142

42-
%.o32: %.cpp
43-
$(CXX) -m32 -std=c++11 -c -o$@ $^ $(cflags_$(basename $(notdir $@))) $(CFLAGS)
44-
%.o32: %.c
45-
$(CC) -m32 -c -o$@ $^ $(cflags_$(basename $(notdir $@))) $(CFLAGS)
4643

47-
gt_%.o32: $(gnutools)/libiberty/%.c
48-
$(CC) -m32 -c -o$@ $^ $(cflags_$(basename $(notdir $@))) $(gnutoolsincludes) $(CFLAGS)
44+
%.o: %.cpp
45+
$(CXX) -std=c++1z -c -o$@ $^ $(cflags_$(basename $(notdir $@))) $(CFLAGS)
46+
%.o: %.c
47+
$(CC) -c -o$@ $^ $(cflags_$(basename $(notdir $@))) $(CFLAGS)
4948

50-
gt_%.o32: $(gnutools)/opcodes/%.c
51-
$(CC) -m32 -c -Wstrict-prototypes -Wmissing-prototypes -o$@ $^ $(cflags_$(basename $(notdir $@))) $(gnutoolsincludes) $(CFLAGS)
49+
gt_%.o: $(gnutools)/libiberty/%.c
50+
$(CC) -c -o$@ $^ $(cflags_$(basename $(notdir $@))) $(gnutoolsincludes) $(CFLAGS)
5251

53-
gt_%.o32: $(gnutools)/bfd/%.c
54-
$(CC) -m32 -c -Wstrict-prototypes -Wmissing-prototypes -o$@ $^ $(cflags_$(basename $(notdir $@))) $(gnutoolsincludes) $(CFLAGS)
52+
gt_%.o: $(gnutools)/opcodes/%.c
53+
$(CC) -c -Wstrict-prototypes -Wmissing-prototypes -o$@ $^ $(cflags_$(basename $(notdir $@))) $(gnutoolsincludes) $(CFLAGS)
5554

56-
%.o32: %.s
57-
$(CXX) -c -m32 -o$@ $^
55+
gt_%.o: $(gnutools)/bfd/%.c
56+
$(CC) -c -Wstrict-prototypes -Wmissing-prototypes -o$@ $^ $(cflags_$(basename $(notdir $@))) $(gnutoolsincludes) $(CFLAGS)
5857

59-
%.ilx: %.o32
60-
$(LD) -shared -m32 -o $@ $^ "$(idabin)/libida.so"
58+
%.so: %.o
59+
$(CXX) -shared -o $@ $^ -L$(idabin) -lida
6160

62-
%: %.o
63-
$(CXX) -g -o $@ $^
6461

65-
%32: %.o32
66-
$(CXX) -m32 -g -o $@ $^
6762

Makefile.osx

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,74 @@
11
include ../idacfg.mk
2+
IDAVER=7
3+
4+
ifeq ($(IDAVER),6)
5+
IMCEXT=.imc
6+
ARCHFLAGS=-m32
7+
endif
8+
9+
ifeq ($(IDAVER),7)
10+
IMCEXT=.dylib
11+
ARCHFLAGS=-m64 -D__X64__
12+
endif
13+
214

315
all:
416

517
# I put some not yet published targets in this optional include
6-
-include Makefile.extra
18+
#-include Makefile.extra
719

820
CXX=clang++
921
CC=clang
1022
LD=clang++
1123

12-
TARGETS+=hexagon.imc
24+
TARGETS+=hexagon$(IMCEXT)
1325

1426
# where the quicinc objdump source can be found
15-
gnutools= hx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03
27+
gnutools=hx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03
1628

1729
gnutoolsincludes=-I $(gnutools)/include -I $(gnutools)/bfd -I $(gnutools)/include/opcode
1830
gnutoolsincludes+=-I ./build-mac/opcodes -I ./build-mac/bfd
19-
CFLAGS=-g -D__MAC__ -D__IDP__ -I $(idasdk)/include
31+
CFLAGS=-D__MAC__ -D__IDP__ -I $(idasdk)/include
2032
CFLAGS+=-DUSE_STANDARD_FILE_FUNCTIONS
2133
CFLAGS+=-DUSE_DANGEROUS_FUNCTIONS
2234
CFLAGS+=-D_FORTIFY_SOURCE=0
23-
CFLAGS+=-O0 -g
35+
CFLAGS+=-g $(if $(D),-O0,-O2)
36+
LDFLAGS+=-g
2437

2538
# add this flag when you want verbose logging
26-
#CFLAGS+=-DTRACELOG
39+
CFLAGS+=$(if $(LOG),-DTRACELOG)
2740

2841
all: $(TARGETS)
2942

30-
hexagon.imc: hexagon.o32 gt_safe-ctype.o32 gt_hexagon-dis.o32 gt_hexagon-opc.o32 gt_hexagon-isa.o32 bfd_funcs.o32 gt_cpu-hexagon.o32 dummy-scan.o32
43+
hexagon$(IMCEXT): hexagon.obj gt_safe-ctype.obj gt_hexagon-dis.obj gt_hexagon-opc.obj gt_hexagon-isa.obj bfd_funcs.obj gt_cpu-hexagon.obj dummy-scan.obj
44+
$(LD) $(LDFLAGS) -dynamiclib $(ARCHFLAGS) -o $@ $^ "$(idabin)/libida.dylib"
45+
3146
cflags_cpu-hexagon= $(gnutoolsincludes)
3247
cflags_hexagon= $(gnutoolsincludes)
3348
cflags_bfd_funcs= $(gnutoolsincludes)
3449

35-
install: hexagon.imc
50+
install: hexagon$(IMCEXT)
3651
cp $^ "$(idabin)/procs"
3752

3853
clean:
39-
$(RM) $(TARGETS) $(wildcard *.o) $(wildcard *.o32)
40-
41-
42-
%.o32: %.cpp
43-
$(CXX) -m32 -std=c++11 -c -o$@ $^ $(cflags_$(basename $(notdir $@))) $(CFLAGS)
44-
%.o32: %.c
45-
$(CC) -m32 -c -o$@ $^ $(cflags_$(basename $(notdir $@))) $(CFLAGS)
54+
$(RM) $(TARGETS) $(wildcard *.obj)
4655

47-
gt_%.o32: $(gnutools)/libiberty/%.c
48-
$(CC) -m32 -c -o$@ $^ $(cflags_$(basename $(notdir $@))) $(gnutoolsincludes) $(CFLAGS)
4956

50-
gt_%.o32: $(gnutools)/opcodes/%.c
51-
$(CC) -m32 -c -Wstrict-prototypes -Wmissing-prototypes -o$@ $^ $(cflags_$(basename $(notdir $@))) $(gnutoolsincludes) $(CFLAGS)
57+
%.obj: %.cpp
58+
$(CXX) $(ARCHFLAGS) -std=c++1z -c -o$@ $^ $(cflags_$(basename $(notdir $@))) $(CFLAGS)
59+
%.obj: %.c
60+
$(CC) $(ARCHFLAGS) -c -o$@ $^ $(cflags_$(basename $(notdir $@))) $(CFLAGS)
5261

53-
gt_%.o32: $(gnutools)/bfd/%.c
54-
$(CC) -m32 -c -Wstrict-prototypes -Wmissing-prototypes -o$@ $^ $(cflags_$(basename $(notdir $@))) $(gnutoolsincludes) $(CFLAGS)
62+
gt_%.obj: $(gnutools)/libiberty/%.c
63+
$(CC) $(ARCHFLAGS) -c -o$@ $^ $(cflags_$(basename $(notdir $@))) $(gnutoolsincludes) $(CFLAGS)
5564

56-
%.o32: %.s
57-
$(CXX) -c -m32 -o$@ $^
65+
gt_%.obj: $(gnutools)/opcodes/%.c
66+
$(CC) $(ARCHFLAGS) -c -Wstrict-prototypes -Wmissing-prototypes -o$@ $^ $(cflags_$(basename $(notdir $@))) $(gnutoolsincludes) $(CFLAGS)
5867

59-
%.imc: %.o32
60-
$(LD) -dynamiclib -m32 -o $@ $^ "$(idabin)/libida.dylib"
68+
gt_%.obj: $(gnutools)/bfd/%.c
69+
$(CC) $(ARCHFLAGS) -c -Wstrict-prototypes -Wmissing-prototypes -o$@ $^ $(cflags_$(basename $(notdir $@))) $(gnutoolsincludes) $(CFLAGS)
6170

62-
%: %.o
63-
$(CXX) -g -o $@ $^
71+
%.obj: %.s
72+
$(CXX) -c $(ARCHFLAGS) -o$@ $^
6473

65-
%32: %.o32
66-
$(CXX) -m32 -g -o $@ $^
6774

Makefile.w32

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,22 @@ include ../idacfg.mk
22

33
all:
44

5-
#vc=c:/Program Files/Microsoft Visual Studio 8/VC
6-
#winsdk=$(vc)/platformsdk
7-
vc=c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC
8-
winsdk=C:/Program Files (x86)/Windows Kits/10
9-
CXX=$(vc)/bin/cl.exe
10-
CC=$(vc)/bin/cl.exe
11-
LD=$(vc)/bin/link.exe
5+
CXX=cl.exe
6+
CC=cl.exe
7+
LD=link.exe
128

13-
TARGETS+=hexagon.w32
9+
TARGETS+=hexagon.dll
1410

1511
# where the quicinc objdump source can be found
1612
gnutools= hx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03
1713

1814
gnutoolsincludes=-I $(gnutools)/include -I $(gnutools)/bfd -I $(gnutools)/include/opcode
1915
gnutoolsincludes+=-I build-win/opcodes -I build-win/bfd
20-
CFLAGS=-EHsc -GR -Gz -nologo -Zi -D__NT__ -D__IDP__ -I $(idasdk)/include -I $(BOOST)
21-
CFLAGS+=-I "$(vc)/include" -I "$(winsdk)/include" -D_WIN32 -DWIN32 -D_USRDLL -DMAXSTR=1024
22-
CFLAGS+=-O2
16+
CFLAGS=-EHsc -GR -Gz -nologo -Zi -D__NT__ -D__X64__ -D__IDP__ -I $(idasdk)/include
17+
CFLAGS+=-D_WIN32 -DWIN32 -D_USRDLL -DMAXSTR=1024
18+
CFLAGS+=-O2 -std:c++17
2319

24-
LDLIBS=$(idasdk)/lib/x86_win_vc_32/ida.lib
25-
LDLIBS+=-libpath:"$(vc)/lib" -libpath:"$(winsdk)/lib"
20+
LDLIBS=$(idasdk)/lib/x64_win_vc_32/ida.lib
2621
LDFLAGS=-debug -nologo -dll -export:LPH -stub:$(idasdk)/module/stub
2722

2823

@@ -31,19 +26,17 @@ LDFLAGS=-debug -nologo -dll -export:LPH -stub:$(idasdk)/module/stub
3126

3227
all: $(TARGETS)
3328

34-
hexagon.w32: hexagon.obj gt_safe-ctype.obj gt_hexagon-dis.obj gt_hexagon-opc.obj bfd_funcs.obj gt_hexagon-isa.obj gt_cpu-hexagon.obj dummy-scan.obj
29+
hexagon.dll: hexagon.obj gt_safe-ctype.obj gt_hexagon-dis.obj gt_hexagon-opc.obj bfd_funcs.obj gt_hexagon-isa.obj gt_cpu-hexagon.obj dummy-scan.obj
3530
cflags_hexagon= $(gnutoolsincludes)
3631
cflags_bfd_funcs= $(gnutoolsincludes)
3732

38-
install: hexagon.w32
33+
install: hexagon.dll
3934
cp $^ "$(idabin)/procs"
4035

4136
clean:
4237
$(RM) $(TARGETS) $(wildcard *.obj) $(GENERATEDFILES) hexagon.exp hexagon.ilk hexagon.lib hexagon.pdb vc140.pdb
4338

4439

45-
46-
4740
%.obj: %.cpp
4841
"$(CXX)" -c -Fo$@ $^ $(cflags_$(basename $(notdir $@))) $(CFLAGS) $(CXXFLAGS)
4942
%.obj: %.c
@@ -61,6 +54,6 @@ gt_%.obj: $(gnutools)/bfd/%.c
6154
%.obj: %.s
6255
"$(CXX)" -c -Fo$@ $^
6356

64-
%.w32: %.obj
57+
%.dll: %.obj
6558
"$(LD)" $(LDFLAGS) -out:$@ $^ $(LDLIBS)
6659

README.md

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ or Galaxy S5 ( SM-G900F )
1010
Several versions of the programmers reference manual can be found online:
1111
* [80-NB419-1 Rev. A Hexagon V2 Programmer’s Reference Manual](https://developer.qualcomm.com/download/80-nb419-1ahexagonv2programmersref.pdf)
1212
* 80-N2040-9 Rev. A Hexagon V4 Programmer’s Reference Manual
13-
* 80-N2040-8 Rev. A Hexagon V5/V55 Programmer’s Reference Manual
13+
* 80-N2040-8 Rev. H Hexagon V5/V55 Programmer’s Reference Manual
1414
* both the v4 and v5 refman can be found in this [zip](https://developer.qualcomm.com/download/hexagon/hexagon-sdk-programmers-reference.zip)
1515
* 80-N2040-9 Rev. F Hexagon V5x Programmer’s Reference Manual
16-
* 80-N2040-33 Rev. B Hexagon V6x Programmer’s Reference Manual
17-
* both the v5.x and v6.x refman can be found in the Hexagon LLVM Tools 7.2.x Document Bundle, which is installed as part of the [Add-On for HVX](https://developer.qualcomm.com/download/hexagon/hexagon-sdk-addon-hvx-linux.bin)
16+
* 80-N2040-33 Rev. D Hexagon V6x Programmer’s Reference Manual
17+
* both the v5.x and v6.x refman can be found in the Hexagon LLVM Tools 8.0 Document Bundle, which is installed as part of the [Hexagon SDK](https://developer.qualcomm.com/download/hexagon/)
18+
* 80-N2040-30 Rev B Hexagon V60 HVX Programmer's Reference Manual
19+
* 80-N2040-37 Rev A Hexagon V62 HVX Programmer's Reference Manual
20+
* 80-N2040-36 Rev B Hexagon V62 Programmer's Reference Manual
1821

1922
check out https://developer.qualcomm.com/hexagon-processor for updates from qualcomm.
2023

@@ -38,15 +41,16 @@ Binary download
3841
-------
3942

4043
Binaries for OSX, Linux and Windows can be found under [releases](https://github.com/gsmk/hexagon/releases):
41-
* [OS X](https://github.com/gsmk/hexagon/releases/download/v1.1/hexagon.imc)
42-
* [Linux](https://github.com/gsmk/hexagon/releases/download/v1.1/hexagon.ilx)
43-
* [Windows](https://github.com/gsmk/hexagon/releases/download/v1.1/hexagon.w32)
44+
* [OS X](https://github.com/gsmk/hexagon/releases/download/v1.2/hexagon.dylib)
45+
* [Windows](https://github.com/gsmk/hexagon/releases/download/v1.2/hexagon.dll)
46+
* [Linux](https://github.com/gsmk/hexagon/releases/download/v1.2/hexagon.so)
47+
4448

4549
Installation
4650
-------
4751

48-
Copy the hexagon.{imc,w32,ilx} file to the procs subdirectory of your IDA installation.
49-
This module can also be used with the [IDA 6.8 Evaluation](https://www.hex-rays.com/products/ida/support/download_demo.shtml) version.
52+
Copy the hexagon.{dylib,dll,so} file to the procs subdirectory of your IDA installation.
53+
This module can probably also be used with the [IDA Evaluation](https://www.hex-rays.com/products/ida/support/download_demo.shtml) version.
5054

5155

5256
Usage
@@ -64,15 +68,19 @@ Compiling
6468

6569
Separate makefiles exist for OSX (Makefile.osx), Windows (Makefile.w32) and Linux (Makefile.linux).
6670

67-
You need the [IDASDK](https://www.hex-rays.com/products/ida/support/ida/idasdk69.zip) ( Password protected ).
71+
You need the [IDASDK](https://www.hex-rays.com/products/ida/support/ida/idasdk70.zip) ( Password protected ).
6872
The sourcery hexagon gnutools, install them in a subdirectory named `hx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03`.
69-
You need a c++11 compiler, like visualstudio 2015, or any recent gcc or clang.
73+
You need a c++17 compiler, like visualstudio 2017, or any recent gcc or clang.
7074

7175
Create a `idacfg.mk` file, containing the following variables:
7276

7377
* `idasdk`, pointing to your IDASDK directory
7478
* `idabin`, pointing to your IDA binaries directory
7579

80+
On windows, first run the following command, to setup the right visualstudio environment.
81+
82+
vsdevcmd -arch=amd64
83+
7684
Bugs
7785
-------
7886

@@ -83,6 +91,16 @@ Bugs
8391
* Indirect jumps and calls are not yet marked as such
8492
* basic block ends are not correct in graph view
8593
* processor type is fixed to v5.5
94+
* module may crash when encountering some invalid instructions ( lumia 820 modem )
95+
* 'loop' instruction should have a code xref, instead of a data xref.
96+
97+
98+
Other Hexagon Processor modules
99+
===============================
100+
101+
* [nogaxeh](https://github.com/ANSSI-FR/nogaxeh)
102+
* [hexag00n](https://github.com/programa-stic/hexag00n)
103+
86104

87105
Author
88106
=======
@@ -93,6 +111,11 @@ History
93111
-------
94112
2013-06-10 version 1.0
95113
2016-02-01 version 1.1
114+
2017-12-05 version 1.2 - for idapro v7
115+
116+
* fixed incorrect code ref from `memw` instruction
117+
* fixed incorrect label for some `jump` instructions
118+
* now using changed plugin architecture for IDA7.
96119

97120
License
98121
-------

0 commit comments

Comments
 (0)