Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to IDA 7.0 #7

Open
matrix1001 opened this issue Mar 27, 2018 · 9 comments
Open

Add support to IDA 7.0 #7

matrix1001 opened this issue Mar 27, 2018 · 9 comments

Comments

@matrix1001
Copy link

Add support to IDA 7.0 and this tool will be much better.

@ALSchwalm
Copy link
Owner

Agreed, unfortunately, I no longer have access to IDA Pro, so this would have to be a community contribution.

@microtronics
Copy link

Any chance you can give info on how to build in windows? I'd like to try compiling against IDA 7 under Windows.

@ALSchwalm
Copy link
Owner

There is actually a windows branch that has a Makefile for windows. The setup is essentially to compile and statically link libdwarf under mingw, and then statically link that in when compiling dwarfexport.

@nihilus
Copy link

nihilus commented Dec 20, 2018

@matrix1001 @matrix1001 I've ported it to 7.0 and created a pull request.

@mephi42
Copy link
Contributor

mephi42 commented Oct 18, 2019

In my case IDA 7 SDK did not contain MinGW-specific libraries (and linking with MSVC ones predictably led to crashes), so I had to take @nihilus's PR and add MSVC Makefiles on top. If you are interested, I can clean them up and send a PR.

@ALSchwalm
Copy link
Owner

@mephi42 I'd be ok with that. The previous PR just fell off my radar

@mewmew
Copy link

mewmew commented Nov 29, 2019

@mephi42 I'd be ok with that. The previous PR just fell off my radar

Hi @ALSchwalm,

I just found out about the dwarfexport plugin today, and wow, I must say. It is really impressive what you've managed to implement, and definitely very useful!

I was wondering if the dwarfexport plugin may receive some well deserved love. I would indeed be a shame if a plugin this useful fell into the forgotten by not being synced with newer versions of IDA.

Wish you all the best and happy reversing!

Cheers,
Robin

@mephi42
Copy link
Contributor

mephi42 commented Nov 29, 2019

@mewmew, I'm currently using @nihilus's #8 with IDA 7.0, and I can confirm that it's working great.

@ALSchwalm, what do you think needs to be done in order to integrate that pull request?

@mewmew
Copy link

mewmew commented Nov 29, 2019

@mewmew, I'm currently using @nihilus's #8 with IDA 7.0, and I can confirm that it's working great.

Hi @mephi42,

Thanks for the quick reply and feedback!

I tried #8 yesterday, but didn't get it working. I'm running on Linux and the latest version of both GCC and Clang was complaining about both error: a reinterpret_cast is not a constant expression, ‘struct idainfo’ has no member named ‘is_be’ and inf.is_64bit(). Perhaps there is something simple I've overlooked?

g++ -static-libgcc -static-libstdc++ src/platform.cpp src/dwarfexport.cpp src/dwarfgen.cpp -m32 -fPIC -shared -std=c++11 -Wno-overflow -Wno-deprecated-declarations -Wno-return-type \
-L. \
-L/home/u/idapro-7.3 \
-I/home/u/idasdk73/include -I/home/u/idapro-7.3/plugins/hexrays_sdk/include -I/usr/include/libdwarf \
-D__LINUX__ -D__X64__ -lida lib/libelf32.a lib/libdwarf32.a -o bin/dwarfexport.plx
In file included from /home/u/idasdk73/include/idp.hpp:17,
                 from /home/u/idasdk73/include/frame.hpp:10,
                 from src/platform.cpp:3:
/home/u/idasdk73/include/config.hpp: In constructor ‘constexpr cfgopt_t::cfgopt_t(const char*, const char* (*)(lexer_t*, const token_t&, const token_t&))’:
/home/u/idasdk73/include/config.hpp:242:76: error: a reinterpret_cast is not a constant expression
  242 |   constexpr cfgopt_t(const char *_n, cfgopt_handler_t *_p) : name(_n), ptr((void *) _p), flags(IDPOPT_CST), buf_size(0) {}
      |                                                                            ^~~~~~~~~~~
/home/u/idasdk73/include/config.hpp: In constructor ‘constexpr cfgopt_t::cfgopt_t(const char*, const char* (*)(lexer_t*, const token_t&, const token_t&, int64, int64), int64, int64)’:
/home/u/idasdk73/include/config.hpp:245:21: error: a reinterpret_cast is not a constant expression
  245 |     : name(_n), ptr((void *) _p), flags(IDPOPT_CST | IDPOPT_CST_PARAMS), params(_p1, _p2) {}
      |                     ^~~~~~~~~~~
In file included from /home/u/idasdk73/include/fpro.h:11,
                 from /home/u/idasdk73/include/idp.hpp:11,
                 from /home/u/idasdk73/include/frame.hpp:10,
                 from src/platform.cpp:3:
/home/u/idasdk73/include/idp.hpp: At global scope:
/home/u/idasdk73/include/idp.hpp:328:23: error: static assertion failed: sizeof(asm_t) == 408
  328 | CASSERT(sizeof(asm_t) == 408);
/home/u/idasdk73/include/pro.h:647:37: note: in definition of macro ‘CASSERT’
  647 | #define CASSERT(cnd) static_assert((cnd), QSTRINGIZE(cnd))
      |                                     ^~~
/home/u/idasdk73/include/idp.hpp:1736:29: error: static assertion failed: sizeof(processor_t) == 144
 1736 | CASSERT(sizeof(processor_t) == 144);
/home/u/idasdk73/include/pro.h:647:37: note: in definition of macro ‘CASSERT’
  647 | #define CASSERT(cnd) static_assert((cnd), QSTRINGIZE(cnd))
      |                                     ^~~
/home/u/idasdk73/include/loader.hpp:612:28: error: static assertion failed: sizeof(plugin_t) == 64
  612 |   CASSERT(sizeof(plugin_t) == 64);
/home/u/idasdk73/include/pro.h:647:37: note: in definition of macro ‘CASSERT’
  647 | #define CASSERT(cnd) static_assert((cnd), QSTRINGIZE(cnd))
      |                                     ^~~
src/platform.cpp: In function ‘int translate_register_num(int)’:
src/platform.cpp:247:17: error: ‘struct idainfo’ has no member named ‘is_64bit’
  247 |     return (inf.is_64bit()) ? translate_amd64(reg_num)
      |                 ^~~~~~~~
src/platform.cpp:250:17: error: ‘struct idainfo’ has no member named ‘is_64bit’
  250 |     return (inf.is_64bit()) ? -1 : translate_arm(reg_num);
      |                 ^~~~~~~~
src/platform.cpp: In function ‘bool decompiler_lvar_reg_and_offset(cfuncptr_t, const lvar_t&, int*, int*)’:
src/platform.cpp:264:13: error: ‘struct idainfo’ has no member named ‘is_64bit’
  264 |     if (inf.is_64bit()) {
      |             ^~~~~~~~
src/platform.cpp:283:13: error: ‘struct idainfo’ has no member named ‘is_64bit’
  283 |     if (inf.is_64bit()) {
      |             ^~~~~~~~
src/platform.cpp: In function ‘bool disassembler_lvar_reg_and_offset(func_t*, member_t*, int*, int*)’:
src/platform.cpp:319:13: error: ‘struct idainfo’ has no member named ‘is_64bit’
  319 |     if (inf.is_64bit()) {
      |             ^~~~~~~~
src/platform.cpp:342:13: error: ‘struct idainfo’ has no member named ‘is_64bit’
  342 |     if (inf.is_64bit()) {
      |             ^~~~~~~~
In file included from /home/u/idasdk73/include/idp.hpp:17,
                 from /home/u/idasdk73/include/frame.hpp:10,
                 from src/dwarfexport.cpp:3:
/home/u/idasdk73/include/config.hpp: In constructor ‘constexpr cfgopt_t::cfgopt_t(const char*, const char* (*)(lexer_t*, const token_t&, const token_t&))’:
/home/u/idasdk73/include/config.hpp:242:76: error: a reinterpret_cast is not a constant expression
  242 |   constexpr cfgopt_t(const char *_n, cfgopt_handler_t *_p) : name(_n), ptr((void *) _p), flags(IDPOPT_CST), buf_size(0) {}
      |                                                                            ^~~~~~~~~~~
/home/u/idasdk73/include/config.hpp: In constructor ‘constexpr cfgopt_t::cfgopt_t(const char*, const char* (*)(lexer_t*, const token_t&, const token_t&, int64, int64), int64, int64)’:
/home/u/idasdk73/include/config.hpp:245:21: error: a reinterpret_cast is not a constant expression
  245 |     : name(_n), ptr((void *) _p), flags(IDPOPT_CST | IDPOPT_CST_PARAMS), params(_p1, _p2) {}
      |                     ^~~~~~~~~~~
In file included from /home/u/idasdk73/include/fpro.h:11,
                 from /home/u/idasdk73/include/idp.hpp:11,
                 from /home/u/idasdk73/include/frame.hpp:10,
                 from src/dwarfexport.cpp:3:
/home/u/idasdk73/include/idp.hpp: At global scope:
/home/u/idasdk73/include/idp.hpp:328:23: error: static assertion failed: sizeof(asm_t) == 408
  328 | CASSERT(sizeof(asm_t) == 408);
/home/u/idasdk73/include/pro.h:647:37: note: in definition of macro ‘CASSERT’
  647 | #define CASSERT(cnd) static_assert((cnd), QSTRINGIZE(cnd))
      |                                     ^~~
/home/u/idasdk73/include/idp.hpp:1736:29: error: static assertion failed: sizeof(processor_t) == 144
 1736 | CASSERT(sizeof(processor_t) == 144);
/home/u/idasdk73/include/pro.h:647:37: note: in definition of macro ‘CASSERT’
  647 | #define CASSERT(cnd) static_assert((cnd), QSTRINGIZE(cnd))
      |                                     ^~~
/home/u/idasdk73/include/loader.hpp:612:28: error: static assertion failed: sizeof(plugin_t) == 64
  612 |   CASSERT(sizeof(plugin_t) == 64);
/home/u/idasdk73/include/pro.h:647:37: note: in definition of macro ‘CASSERT’
  647 | #define CASSERT(cnd) static_assert((cnd), QSTRINGIZE(cnd))
      |                                     ^~~
In file included from /home/u/idasdk73/include/idp.hpp:17,
                 from /home/u/idapro-7.3/plugins/hexrays_sdk/include/hexrays.hpp:87,
                 from src/dwarfexport.h:6,
                 from src/dwarfgen.cpp:13:
/home/u/idasdk73/include/config.hpp: In constructor ‘constexpr cfgopt_t::cfgopt_t(const char*, const char* (*)(lexer_t*, const token_t&, const token_t&))’:
/home/u/idasdk73/include/config.hpp:242:76: error: a reinterpret_cast is not a constant expression
  242 |   constexpr cfgopt_t(const char *_n, cfgopt_handler_t *_p) : name(_n), ptr((void *) _p), flags(IDPOPT_CST), buf_size(0) {}
      |                                                                            ^~~~~~~~~~~
/home/u/idasdk73/include/config.hpp: In constructor ‘constexpr cfgopt_t::cfgopt_t(const char*, const char* (*)(lexer_t*, const token_t&, const token_t&, int64, int64), int64, int64)’:
/home/u/idasdk73/include/config.hpp:245:21: error: a reinterpret_cast is not a constant expression
  245 |     : name(_n), ptr((void *) _p), flags(IDPOPT_CST | IDPOPT_CST_PARAMS), params(_p1, _p2) {}
      |                     ^~~~~~~~~~~
In file included from /home/u/idapro-7.3/plugins/hexrays_sdk/include/hexrays.hpp:84,
                 from src/dwarfexport.h:6,
                 from src/dwarfgen.cpp:13:
/home/u/idasdk73/include/idp.hpp: At global scope:
/home/u/idasdk73/include/idp.hpp:328:23: error: static assertion failed: sizeof(asm_t) == 408
  328 | CASSERT(sizeof(asm_t) == 408);
/home/u/idasdk73/include/pro.h:647:37: note: in definition of macro ‘CASSERT’
  647 | #define CASSERT(cnd) static_assert((cnd), QSTRINGIZE(cnd))
      |                                     ^~~
/home/u/idasdk73/include/idp.hpp:1736:29: error: static assertion failed: sizeof(processor_t) == 144
 1736 | CASSERT(sizeof(processor_t) == 144);
/home/u/idasdk73/include/pro.h:647:37: note: in definition of macro ‘CASSERT’
  647 | #define CASSERT(cnd) static_assert((cnd), QSTRINGIZE(cnd))
      |                                     ^~~
/home/u/idasdk73/include/loader.hpp:612:28: error: static assertion failed: sizeof(plugin_t) == 64
  612 |   CASSERT(sizeof(plugin_t) == 64);
/home/u/idasdk73/include/pro.h:647:37: note: in definition of macro ‘CASSERT’
  647 | #define CASSERT(cnd) static_assert((cnd), QSTRINGIZE(cnd))
      |                                     ^~~
src/dwarfgen.cpp: In function ‘std::shared_ptr<DwarfGenInfo> generate_dwarf_object(const Options&)’:
src/dwarfgen.cpp:121:21: error: ‘struct idainfo’ has no member named ‘is_be’
  121 |   int endian = (inf.is_be()) ? DW_DLC_TARGET_BIGENDIAN : DW_DLC_TARGET_LITTLEENDIAN;
      |                     ^~~~~
make: *** [Makefile:12: bin/dwarfexport.plx] Error 1

I also got this include error, but the fix was easy, just add -I/usr/include/libdwarf

In file included from src/dwarfgen.cpp:13:
src/dwarfexport.h:8:10: fatal error: libdwarf.h: No such file or directory
    8 | #include <libdwarf.h>
      |          ^~~~~~~~~~~~

Cheers,
Robin

Edit: These are the versions of GCC and Clang I've installed:

$ gcc --version
gcc (GCC) 9.2.0

$ clang --version
clang version 9.0.0 (tags/RELEASE_900/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants