Reputation: 73
As the title suggests.. I am struggling over the last days to successfully compile LiME (Linux Memory Extractor) and load it on an Android Emulator or a physical device. To compile I am using arm-linux-androideabi-4.6 and I am currently on x64 14.04 Ubuntu. Also:
unknown@unknown-A15:~$ uname -a
Linux unknown-A15 3.13.0-39-generic #66-Ubuntu SMP Tue Oct 28 13:30:27 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
So, in order to succeed this I have followed the directions from every guide regarding that online without luck.. (This could be due to diff NDK/SDK/Unis Distro versios OR just my inexperience) The guides that I have read are those (plus 2 more guides but SO won't allow me to post more links.. I can post them in comment later on if needed):
I have mainly focused on the 1st guide but I faced my first issue when trying to Cross Compile the Kernel.
So firstly (after having downloaded the goldfish kernel source) I add this to /etc/profile to make things simpler:
export CCOMPILER=~/android-ndk-r10c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
source /etc/profile
Then I do:
make clean
make mrproper
cp path/to/exported_from_emulator_config .
mv config .config
# Add the 3 lines needed "CONFIG_MODULES=y", "CONFIG_MODULES_UNLOAD=y", "CONFIG_MODULES_FORCE_UNLOAD=y"
sudo vim .config
Now.. I have to actually make the kernel. But everything that is suggested on guides online fails. I have tried:
make ARCH=arm CROSS_COMPILE=arm-eCross-eabi- EXTRA_CFLAGS=-fno-pic modules_prepare
make CROSS_COMPILE=arm-eCross-eabi- EXTRA_CFLAGS=-fno-pic modules_prepare
make CROSS_COMPILE=arm-eCross-eabi- modules
but apparently they all fail for reasons that are being referred on the 2nd guide I posted in here. So.. I have made the change in the Makefile that those guys in the 2nd guide propose (just to avoid giving as ARCH as a make argument). And so I am able to somehow bypass all next errors and eventually compile like this:
make CROSS_COMPILE=$CCOMPILER
Note 1: One error I keep getting is this:
/home/unknown/android-source/scripts/mksysmap: line 44: ~/android-ndk-r10c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm: No such file or directory
make: *** [vmlinux] Error 1
Hence, I do believe that the 3 kernel options for MODULE LOADING are not being taken under consideration. But that's just an assumption since I've never built linux kernel before.
Note 2: I have to note also that I believe that while compiling kernel the .confif is getting overwritten. I am seeing this output quite often:
.config:120:warning: override: reassigning to symbol MODULES
I have also tried editing the configuration when running make and make prompts for it or with menuconfig. No luck however.
Luckily, I manage to bypass this error by simply putting the exact path to android eabis when invoking make like this:
make CROSS_COMPILE=~/android-ndk-r10c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
Finally I manage to have a compiled kernel:
...
SYSMAP .tmp_System.map
OBJCOPY arch/arm/boot/Image
Kernel: arch/arm/boot/Image is ready
AS arch/arm/boot/compressed/head.o
GZIP arch/arm/boot/compressed/piggy.gz
AS arch/arm/boot/compressed/piggy.o
CC arch/arm/boot/compressed/misc.o
LD arch/arm/boot/compressed/vmlinux
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
So now I should try cross compiling with LiME! I have to say that I tried compiling it and playing with the Makefile, but everytime I get the same errors. I have used every Makefile provided online by people who successfully cross compiled LiME with an android kernel (while ofcourse changing the kernel and compiler paths), but no luck. So the errors are:
make ARCH=arm CROSS_COMPILE=~/android-ndk-r10c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi- -C ~/android-source M=/home/unknown/lime-forensics/src modules
make[1]: Entering directory /home/unknown/android-source'
Building modules, stage 2.
MODPOST 1 modules
WARNING: "vfs_write" [/home/unknown/lime-forensics/src/lime.ko] undefined!
WARNING: "filp_close" [/home/unknown/lime-forensics/src/lime.ko] undefined!
WARNING: "filp_open" [/home/unknown/lime-forensics/src/lime.ko] undefined!
WARNING: "sock_sendmsg" [/home/unknown/lime-forensics/src/lime.ko] undefined!
WARNING: "memset" [/home/unknown/lime-forensics/src/lime.ko] undefined!
WARNING: "sock_setsockopt" [/home/unknown/lime-forensics/src/lime.ko] undefined!
WARNING: "sock_create_kern" [/home/unknown/lime-forensics/src/lime.ko] undefined!
WARNING: "param_get_int" [/home/unknown/lime-forensics/src/lime.ko] undefined!
WARNING: "param_set_int" [/home/unknown/lime-forensics/src/lime.ko] undefined!
WARNING: "param_get_charp" [/home/unknown/lime-forensics/src/lime.ko] undefined!
WARNING: "param_set_charp" [/home/unknown/lime-forensics/src/lime.ko] undefined!
WARNING: "iomem_resource" [/home/unknown/lime-forensics/src/lime.ko] undefined!
WARNING: "sscanf" [/home/unknown/lime-forensics/src/lime.ko] undefined!
WARNING: "strcmp" [/home/unknown/lime-forensics/src/lime.ko] undefined!
WARNING: "__memzero" [/home/unknown/lime-forensics/src/lime.ko] undefined!
CC /home/unknown/lime-forensics/src/lime.mod.o
/home/unknown/lime-forensics/src/lime.mod.c:8:1: error: variable '__this_module' has initializer but incomplete type
/home/unknown/lime-forensics/src/lime.mod.c:9:2: error: unknown field 'name' specified in initializer
/home/unknown/lime-forensics/src/lime.mod.c:9:2: warning: excess elements in struct initializer [enabled by default]
/home/unknown/lime-forensics/src/lime.mod.c:9:2: warning: (near initialization for '__this_module') [enabled by default]
/home/unknown/lime-forensics/src/lime.mod.c:10:2: error: unknown field 'init' specified in initializer
/home/unknown/lime-forensics/src/lime.mod.c:10:2: warning: excess elements in struct initializer [enabled by default]
/home/unknown/lime-forensics/src/lime.mod.c:10:2: warning: (near initialization for '__this_module') [enabled by default]
/home/unknown/lime-forensics/src/lime.mod.c:14:2: error: unknown field 'arch' specified in initializer
/home/unknown/lime-forensics/src/lime.mod.c:14:10: error: 'MODULE_ARCH_INIT' undeclared here (not in a function)
/home/unknown/lime-forensics/src/lime.mod.c:14:2: warning: excess elements in struct initializer [enabled by default]
/home/unknown/lime-forensics/src/lime.mod.c:14:2: warning: (near initialization for '__this_module') [enabled by default]
make[2]: *** [/home/unknown/lime-forensics/src/lime.mod.o] Error 1
make[1]: *** [modules] Error 2
make[1]: Leaving directory
/home/unknown/android-source'
make: *** [default] Error 2
After searching a little bit about those errors, I came up to the conclusion that the kernel is not valid or something for cross compiling it with LiME. Which makes me think that .config is not being take under consideration by make as I said before.
I do not really understand the low level things of this process so it could be anything. I am really thankful to anyone that will take their time to read my post.. I know its huge :/
Any suggestions, comments are very welcome! Please let me know if I you need more information or I need to fix something.
Thanks everyone :)
P.S. Sorry for using stupid tags but SO won't allow me to use non-existent tags which would be more appropriate like "linux-memory-extractor" etc.
Upvotes: 2
Views: 2200
Reputation: 73
Ok I figured it out after LiME's dev Joe helped me.
First of all, in order to avoid having your kernel .config overwritten when you do make you should do:
make ARCH=arm CROSS_COMPILE=path/to/toolchains/bin goldfish_defconfig
# then run menuconfig and enable all kernel module loading options and save with ESC
make ARCH=arm CROSS_COMPILE=path/to/toolchains/bin menuconfig
# then simply compile
make ARCH=arm CROSS_COMPILE=path/to/toolchains/bin
Lastly, in case you have to, you can add this:
EXTRA_CFLAGS=-fno-pic
when trying to cross compile LiME!
Hope this helps someone !
P.S: I used the eabis from android ndk-r8.
Upvotes: 3