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

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.

Related

Problems building driver on Linux kernel 5.8.x

I'm working with a Linux driver that is building on v5.7.x kernels but not on the latest v5.8.x releases.
To summarise, most of the driver is pre-built and the kernel interface is built on the target. This involves a make -f Kbuild command.
Having checked all of the relevant kernel interface files for any changes that would affect us, normally the driver would just build as usual on a new kernel. However, this time we get the following error:
make[2]: *** [scripts/Makefile.modpost:111: /path/to/source/Module.symvers] Error 1
make[1]: *** [Makefile:1669: modules] Error 2
make[1]: Leaving directory '/usr/src/kernels/5.8.0-1.el8.elrepo.x86_64'
make: *** [Kbuild:26: default] Error 2
This is from CentOS 8.1, but the same error has been seen on Ubuntu 20.04.
I am no expert on this so interpreting these errors is a bit difficult. I have tried building with the KBUILD_VERBOSE flag and it doesn't really provide any useful information, other than the build succeeding until this point.
On previous kernels the Module.symvers file would be created but empty. On 5.8 this file is not created at all presumably due to this error. As a result, the .ko file is not created.
Finally, if we drop in the source files rather than the pre-built .o files the build does succeed. These .o files are built with a very old version of GCC (4.4.7) but we have also tried building with a much newer version (8.3.1), the same version as the target machine.
I would appreciate suggestions for things to check. Let me know if any other details would help.
Edit:
I ran make on Makefile.modpost manually and got the following output:
sudo make -f ./scripts/Makefile.modpost
WARNING: Symbol version dump "vmlinux.symvers" is missing.
Modules may not have dependencies or modversions.
make -f /scripts/Makefile.modfinal
make[1]: Entering directory '/usr/src/linux-headers-5.8.0-050800-generic'
make[1]: /scripts/Makefile.modfinal: No such file or directory
make[1]: *** No rule to make target '/scripts/Makefile.modfinal'. Stop.
make[1]: Leaving directory '/usr/src/linux-headers-5.8.0-050800-generic'
make: *** [scripts/Makefile.modpost:117: __modpost] Error 2
I am answering my own question in case it helps anyone else with this problem. Although it has never been an issue in the past, we've always had a warning that the corresponding .o.cmd file was not present for our .o_shipped files. This appears to be important in kernel 5.8 onwards and my fix was to add a touch command to the Kbuild file (i.e. "touch .driver.o.cmd"). This does not remove the warning but it allows the driver to build as normal.

How to fix error "'recipe for target "doc/automake-1.14.1' failed" while building Xenomai

I am building Xenomai 2 on a Kernel version 3 with buildroot. Buildroot ist done. Now I am trying to compile it with the "make" command. When I try to compile with the "make" command it appears a failure: recipe for target 'doc/automake-1.14.1' failed. Any help how I can solve that problem?
Ubuntu already has automake version 1.15.1. So I don't really know why it is making the 1.14.1 version while building. Can I change that somewhere?
I have also tried to install the 1.14.1 version but that did not work because it did not find that version, although I have downloaded it...
Here is the cmd-window output:
GEN doc/automake-1.14.1
help2man: can't get `--help' info from automake-1.14
Try `--no-discard-stderr' if option outputs to stderr
Makefile:3707: recipe for target 'doc/automake-1.14.1' failed
make[1]: *** [doc/automake-1.14.1] Error 255
make[1]: Leaving directory '/home/daniel/Desktop/ccode/Daniel/buildroot-2014.08/output/build/host-automake-1.14.1'
package/pkg-generic.mk:177: recipe for target '/home/daniel/Desktop/ccode/Daniel/buildroot-2014.08/output/build/host-automake-1.14.1/.stamp_built' failed
make: *** [/home/daniel/Desktop/ccode/Daniel/buildroot-2014.08/output/build/host-automake-1.14.1/.stamp_built] Error 2
````````````````
This issue was fixed on September 11, 2014 by commit 2020ddbd0f2c32863e6be69a235852a088744c28. Please use an up-to-date version of Buildroot.

Stack-protector enabled but compiler support broken

I am doing research on 4G SDN-LTE (software define network- long term evolution) using Ubuntu. First I ran .sh file which gave me error that the kernel newer than 3.14.x is not supported. I installed kernel 3.10, 3.13.11, 3.14. It fixed the error. Currently I'm running linux kernel 3.13.11, now it gave me the error that stack-protector enabled but compiler is broken.
I am building a 4G evolved packet core (EPC). The code is available on GitHub: https://github.com/networkedsystemsIITB/SDN_LTE_EPC/find/master. They used Ubuntu 14.04 for this project. Nothing else they have mentioned.
version 4:7.3.0 ubuntu 2.1
/usr/src/linux-headers-3.13.11-031311ckt39-generic/arch/x86/Makefile:96:
stack-protector enabled but compiler support broken Makefile:604: Cannot use CONFIG_CC_STACKPROTECTOR: -fstack-protector not supported by compiler
Makefile:604: *** missing separator. Stop.
make[4]: Leaving directory '/usr/src/linux-headers-3.13.11-031311ckt39-generic'
Makefile.main:70: recipe for target 'default' failed
make[3]: *** [default] Error 2
make[3]: Leaving directory '/home/shahrukh/shfiles/openvswitch-2.3.2/datapath/linux'

Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y

I’m big enthusiast of Manjaro since 2015 but today I got a problem that I couldn’t resolve on my own. After big updates done few days ago (by update manager) I have a problem with compiling Kernel Drivers on kernel 4.15.18-1. After call make I got error:
make -C /usr/lib/modules/4.15.18-1-MANJARO/build M=/run/media/mati/common/hello_world modules
make[1]: Wejście do katalogu '/usr/lib/modules/4.15.18-1-MANJARO/build'
**Makefile:974: *** "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel". Stop.**
make[1]: Opuszczenie katalogu '/usr/lib/modules/4.15.18-1-MANJARO/build'
make: *** [Makefile:4: all] Błąd 2
The problem is that I cannot install mentioned libraries and command: pacman -Q libelf
returns
libelf 0.170-1
i have no idea what happend, I tried another kernels (I have few versions installed) but each has problems (e.g. the newest, experimental 4.17 has problem with asm goto of gcc compiler). I started learning Linux Kernel Drivers programming but now I can’t learn because of these compilation problems … anyone can help me ?
(Hope my english is understanable).
Greetings !
I got this error while setting up VirtualBox in my Fedora OS 29, I issued the following command and this issue got resolved.
sudo dnf install elfutils-libelf-devel
Are you able to install these packages on your system?
elfutils
elfutils-libelf-devel
libelf-dev
libelf-devel
May require dependencies such as: zlib-devel
For me I had to install elfutils-devel first then install eflutils and eflutils-libelf-devel. libelf-dev and libelf-devel could not be found but when I ran /sbin/vboxconfig again this time it did not error out. I ran the check, "systemctl status vboxdrv" and this time it showed Active: as Active (exited) and I was able to spin up the VM.

tcl8.5.10 make fail error, Network Simulator2 v2.35 (Cygwin v1.7.32) in Windows 8

during installation of NS2 v2.35 (Cygwin v1.7.32) in Windows 8 i keep getting this error message:
Package gcc4 is not present on your system.
Please install it using Cygwin's setup.exe
before trying to install the ns-2 distribution.
I tried downloading the gcc4 package from the setup but it does not show that it has a gcc4 package. So, i downloaded it from internet but the file was empty!!! If i ignore the warning for gcc4 and continue with the installation then i got the following error.
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/../../../../x86_64-pc-cygwin/bin/ld: final l ink failed: Invalid operation
collect2: error: ld returned 1 exit status
Makefile:569: recipe for target `tclsh.exe' failed
make: *** [tclsh.exe] Error 1
tcl8.5.10 make failed! Exiting ...
For problems with Tcl/Tk see http://www.scriptics.com
Somebody please help me!!!
Latest gcc ,i.e., 4.8 not compatible, Go for older versions of gcc like 4.7

Resources