I initially found a hello.c file from the Web and wrote the Makefile the way he did, but when I ran the command insmod, it reported an error:
insmod: init_module ‘hello.ko’ failed (Exec format error)
Period, check a lot of information is still not solved, and then to test it according to this blog, succeeded, the connection address: http://blog.csdn.net/yf210yf/article/details/9901375
Next I post his Makefie file. There is no problem with the hello.c file, but the problem is with the Makefile. Write the Makefile the way he writes it and you can dynamically insert your own compiled kernel. The following code is posted:
Obj – m: = hello – yf. O
hello – yf – objs: = hello. O
KID: = ~/android – kernel/goldfish
the PWD: = $(shell PWD)
the ARCH = arm
CROSS_COMPILE = arm eabi –
CC = $(CROSS_COMPILE) GCC
LD = $(CROSS_COMPILE) LD
all:
the make – C $(KID) ARCH = $(ARCH) CROSS_COMPILE = $(CROSS_COMPILE) M = ${PWD} modules
the clean:
rm-rf *. O. CMD *. Ko *. Mod. C. tmp_versions
however, I do not know why he writes this way right now, I am looking into it. I’ve been updating this blog since I figured it out, but this problem has been solved.
I think I understand why, but look at this code:
All:
mak-c $(KID) ARCH=$(CROSS_COMPILE) M=${PWD} modules
I think this piece of code is the key to solve this problem. First, with mak-c $(KID), the local path of the current source code is given into the compile environment. Then assign the ARCH and cross-compiled environment variables separately, so that the above problems will not occur. You should have no problem writing makefiles this way if you want to compile your own kernel.
——————————————————————————————————————————————————————————————————– ———————–
To update this, the ‘M=’ option is used to add ‘M=dir’ to the make modules command when the user needs to compile an external module based on a kernel. The program will automatically look for the module’s source code in the dir directory you specify, compile it, and generate the KO file. This allows the generated KO files to be dynamically inserted into the kernel.
Read More:
- Docker run failed with the following error in logs, standard_ init_ linux.go:211 : exec user process caused “exec format error“
- standard_init_linux.go:211: exec user process caused “exec format error”
- macbook golang zsh: exec format error
- make modules_ Install compiles the kernel driver as a module, and the location of. Ko file in the root file
- Exec format error: Java
- standard_init_linux.go:178: exec user process caused “no such file or directory”
- Solve cannot execute binary file: exec format error under Linux
- Error response from daemon: OCI runtime exec failed: exec failed: container_linux.go:345:
- Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project Hello
- The difference and usage of insmod and modprobe
- cannot assign module before Module.__init__() call
- FRP installation error:. / FRPC: cannot execute binary file: exec format error
- Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0
- Convert Tencent video QLV format to MP4 format
- invalid connection string format, a valid format is host:ip:port
- Conversion to dalvik format failed with error 1 solution
- Extract audio from ffmpeg video to mp3 format or m4a format command
- Failed: execution error, return code 1 from org.apache.hadoop . hive.ql.exec .DDLTask…
- An error is reported for the new Android project. Rejecting re init on previously failed
- OpenLDAP main: TLS init def ctx failed: -1