vmt / udis86

Disassembler Library for x86 and x86-64
http://udis86.sourceforge.net
BSD 2-Clause "Simplified" License
1.02k stars 299 forks source link

Using udis86 inside a kernel module #62

Open alexandernst opened 11 years ago

alexandernst commented 11 years ago

I'm having some problems using this library because of https://github.com/vmt/udis86/blob/master/libudis86/types.h#L48 which isn't found when compiling the problem for using it from inside a linux kernel module.

I found that just commenting this line will make everything compile and work fine. Any ideas is that's the proper fix to my problem? Or maybe my problem isn't because of this line but because of something else?

jamieiles commented 10 years ago

UD_STANDALONE should be defined as kernel source is built with KERNEL defined, are you building this as a regular module?

alexandernst commented 10 years ago

@jamieiles Yes indeed, I'm using udis86 inside my kernel module.

jamieiles commented 10 years ago

and KERNEL isn't defined? Can you try building your module with VERBOSE=1 given to the kernel build system?

alexandernst commented 10 years ago

@jamieiles No, KERNEL is defined. The problem is that # include <inttypes.h> doesn't exist, which get's included if I compile from my module and use __UD_STANDALONE__. See here: https://github.com/alexandernst/procmon/blob/master/udis86/libudis86/types.h#L48

vmt commented 10 years ago

I've simplified types.h. See 7e397e4. Let me know if that works.

vegard commented 10 years ago

There's a problem when compiling udis86.c because udint.h doesn't get UD_STANDALONE from anywhere (it doesn't include types.h) and so assumes non-standalone mode. I'll submit a fix if nobody else beats me to it :-)

alexandernst commented 10 years ago

How is this going? :) Should I try it with my kernel module?

vegard commented 10 years ago

I sent a pull request for this: https://github.com/vmt/udis86/pull/69