Note that there are some explanatory texts on larger screens.

plurals
  1. POHello world kernel module for android & unknown relocation: 27 when insmod
    primarykey
    data
    text
    <p>I am trying to create a simple kernel module. I am trying to print messages to dmesg but i keep getting</p> <p>insmod: init_module 'hello.ko' failed (Exec format error) in android</p> <p>after : dmesg: unknown relocation: 27</p> <pre><code>#include &lt;linux/module.h&gt; #include &lt;linux/kdb.h&gt; int init_module(void) { printk(KERN_ALERT "Hello world!\n"); return 1; } void cleanup_module(void) { printk(KERN_INFO "Goodbye world 1.\n"); } MODULE_AUTHOR("Robert P. J. Day"); MODULE_LICENSE("Dual BSD/GPL"); MODULE_VERSION("2:1.0") ; MODULE_DESCRIPTION("You have to start somewhere."); </code></pre> <p>The make file</p> <pre><code> obj-m +=hello.o KERNELDIR ?= ~/android/kernel/common #KERNELDIR ?= /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) CROSS_COMPILE=~/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi- ARCH=arm default: $(MAKE) -C $(KERNELDIR) M=$(PWD) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) modules clean: $(MAKE) -C $(KERNELDIR) M=$(PWD) clean rm *.symvers </code></pre> <p>does anyone know why? And how to get it working?</p> <p>I found after doing a readelf that when it is compiled the relocation section is pointing to the wrong directions.</p> <pre><code>Offset Info Type Sym.Value Sym. Name 00000008 0000171b R_ARM_PLT32 00000000 printk </code></pre> <p>When in fact it should be:</p> <pre><code>Offset Info Type Sym.Value Sym. Name 00000008 0000171c R_ARM_CALL 00000000 printk </code></pre> <p>Can someone guess/know how this might be? Thanks @Chris Stratton for helping me this far.</p> <hr> <p>I found after doing a readelf that when it is compiled the relocation section is pointing to the wrong directions.</p> <pre><code>Offset Info Type Sym.Value Sym. Name 00000008 0000171b R_ARM_PLT32 00000000 printk </code></pre> <p>When in fact it should be:</p> <pre><code>Offset Info Type Sym.Value Sym. Name 00000008 0000171c R_ARM_CALL 00000000 printk </code></pre> <p>Can someone guess/know how this might be? Thanks @Chris Stratton for helping me this far.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload