2

Not sure what happened here. I'm trying to upgrade my Linux kernel from 4.9.x to 4.14.x and the below happened:

In file included from arch/x86/decode.c:26:0:
arch/x86/../../elf.h:22:18: fatal error: gelf.h: No such file or directory
 #include <gelf.h>
                  ^
compilation terminated.
mv: cannot stat ‘/usr/src/linux-4.14.51/tools/objtool/arch/x86/.decode.o.tmp’: No such file or directory
make[4]: *** [/usr/src/linux-4.14.51/tools/objtool/arch/x86/decode.o] Error 1
make[3]: *** [arch/x86] Error 2
make[2]: *** [/usr/src/linux-4.14.51/tools/objtool/objtool-in.o] Error 2
make[1]: *** [objtool] Error 2
make: *** [tools/objtool] Error 2

Any ideas what happened here (other than the obvious)? Should "gelf.h" already be on my computer? Or in the kernel tarball?

I downloaded vanilla 4.14.51 from kernel.org - I've compiled my own (unmodified) vanilla kernel successfully, repeatedly, for 14 years now, but this is new.

My PC is a Dell laptop with Core2 i5 (64-bit) with Slackware 14.1 -- I upgraded the stock 3.17.x with 4.4.x several years ago, and more recently to 4.9.x (currently 4.9.109).

I do have libelf installed:

me@mylaptop:~$ locate gelf.h
/usr/include/libelf/gelf.h

me@mylaptop:~$ ls /var/log/packages/*elf*
/var/log/packages/libelf-0.8.13-x86_64-2

ADDENDUM

When trying 4.14.55 last night, I noted that the directory in which the kernel build script expects to see "gelf.h" is in the kernel source tree, not the regular /usr/include.

That being said, the corresponding directory in my (running) 4.9.x source tree does not have any .o nor .ko files. Obviously there's a config item enabled in 4.14.x that I don't have enabled in 4.9.x.

I've tried configuring 4.14.x as close to my working 4.9.x as possible; I am aware of some new options, but generally I try to keep the configurations the same between intermediate kernel versions.

That being said, I don't know what config option it is that would want to see the header files in linux-4.14.*/tools/objtool/arch/x86/... Any ideas?

2
  • Perhaps check that the location of gelf.h is in the #include path, and that the user running make has access rights to it (and the folder)? stackoverflow.com/questions/7834152/…
    – Time4Tea
    Commented Jun 21, 2018 at 19:14
  • My copy of gelf.h is in /usr/include and it is from the (Centos 7) package elfutils-libelf-devel.
    – Chuck E
    Commented Jun 26, 2018 at 21:44

2 Answers 2

0

You need to install the following package:

libelf

It provides the gelf.h header file and others. Perhaps you just never installed it on your machine.

0

The above #include is looking for the file exactly at /usr/include/ while your file is located elsewhere, in /usr/include/libelf/. This won't work.

Please either:

  • create a symlink (preferrable), sudo ln -s libelf/gelf.h /usr/include/gelf.h
  • copy the file, e.g. sudo cp -a /usr/include/libelf/gelf.h /usr/include
  • fix the include, e.g. #include <libelf/gelf.h>

Anyways, it's a packaging issue in Slackware. This include file is installed incorrectly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .