Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
158 views
in Technique[技术] by (71.8m points)

c++ - How to build Shim from source

I'm trying to build shim from source but i'm getting the following error.

ld -o shimx64.so --hash-style=sysv -nostdlib -znocombreloc -T /home/john/git/shim/elf_x86_64_efi.lds -shared -Bsymbolic -L/usr/lib64/gnuefi -L/usr/lib64 -LCryptlib -LCryptlib/OpenSSL /usr/lib64/gnuefi/crt0-efi-x86_64.o --build-id=sha1  --no-undefined shim.o mok.o netboot.o cert.o replacements.o tpm.o version.o errlog.o Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a lib/lib.a -lefi -lgnuefi --start-group Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a --end-group /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a
ld: cannot find /usr/lib64/gnuefi/crt0-efi-x86_64.o: No such file or directory
ld: cannot find -lefi
ld: cannot find -lgnuefi
make: *** [Makefile:92: shimx64.so] Error 1

Any help would be much appreciated, thanks.

My environment

System

  • Ubuntu 20.04.1 LTS

Packages

  • build-essential
  • make
  • gnu-efi

Update

Thomas answer helped me build but when running

make EFIDIR=/boot/efi install

I get the following error

gcc -Og -g3 -Wall -Werror -Wextra -o buildid /home/john/git/shim/buildid.c -lelf
/home/john/git/shim/buildid.c:15:10: fatal error: libelf.h: No such file or directory
   15 | #include <libelf.h>
      |          ^~~~~~~~~~
compilation terminated.
make: *** [Makefile:117: buildid] Error 1

Tried adding the same variables as per Thomas answer but did not work.

question from:https://stackoverflow.com/questions/66045804/how-to-build-shim-from-source

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Looking at the file list of the gnu-efi package, I see:

/usr/lib/crt0-efi-x86_64.o (not /usr/lib64/gnuefi/crt0-efi-x86_64.o)
/usr/lib/libefi.a (not in /usr/lib64)
/usr/lib/libgnuefi.a (not in /usr/lib64)

I think you need to set LIBDIR=/usr/lib and EFI_PATH=/usr/lib during make, rather than the defaults which are /usr/lib64 (set here) and /usr/lib64/gnuefi (set here).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...