简体   繁体   中英

How to avoid 'invalid command' error when building Linux kernel on Fedora 28?

I'm building a Linux kernel on Fedora 28, but always run into the same error such as:

CC      init/main.o  
init/main.o: warning: objtool: elf_begin: invalid command  
make[1]: *** [scripts/Makefile.build:277: init/main.o] Error 1  
make[1]: *** Deleting file 'init/main.o'  
make: *** [Makefile:1067: init] Error 2  
make: *** Waiting for unfinished jobs....

I tried "linux-5.0.16.tar.gz" and "linux-5.0.21.tar.gz" downloaded from kernel.org

, and also tried to follow the instruction on Fedora wiki

But there is no way to avoid this 'invalid command' error. "elfutils-libelf-devel" and "elfutils-libelf" are installed. In the fedora way, 'fedpkg cone -a kernel' was successful, so all dependences are installed. Does anyone know what is missing?

Further progress: The same procedure works on a different machine installed with Fedora 30. However, after upgrading the original machine to Fedora 30, the error persists.

The machine with the 'invalid command' problem had an old version of libelf.so installed under /user/local. After removing the old libelf, objtool is linked to the current libelf library, and is able to run during compilation of the linux kernel.

A comment is found in the linux source code /tools/perf/util/symbols.h:

/*
* libelf 0.8.x and earlier do not support ELF_C_READ_MMAP;
* for newer versions we can use mmap to reduce memory usage:
*/

This comment led me to look for an out-dated version of libelf.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM