On Thu, Feb 10, 2022, Alexandru Elisei wrote: > When compiling kvm-unit-tests configured with --target-efi I get the following > error: > > [..] > gcc -mno-red-zone -mno-sse -mno-sse2 -fcf-protection=full -m64 -O1 -g -MMD -MF x86/.debug.d -fno-strict-aliasing -fno-common -Wall -Wwrite-strings -Wempty-body -Wuninitialized -Wignored-qualifiers -Werror -Wno-missing-braces -fno-omit-frame-pointer -fno-stack-protector -Wno-frame-address -DTARGET_EFI -maccumulate-outgoing-args -fshort-wchar -fPIC -Wclobbered -Wunused-but-set-parameter -Wmissing-parameter-type -Wold-style-declaration -Woverride-init -Wmissing-prototypes -Wstrict-prototypes -std=gnu99 -ffreestanding -I /path/to/kvm-unit-tests/lib -I /path/to/kvm-unit-tests/lib/x86 -I lib -c -o x86/debug.o x86/debug.c > ld -T /path/to/kvm-unit-tests/x86/efi/elf_x86_64_efi.lds -Bsymbolic -shared -nostdlib -o x86/debug.so \ > x86/debug.o x86/efi/efistart64.o lib/libcflat.a > ld: x86/debug.o: relocation R_X86_64_32S against `.text' can not be used when making a shared object; recompile with -fPIC > make: *** [/path/to/kvm-unit-tests/x86/Makefile.common:51: x86/debug.so] Error 1 > rm x86/emulator.o x86/tsc.o x86/msr.o x86/tsc_adjust.o x86/idt_test.o x86/sieve.o x86/s3.o x86/asyncpf.o x86/rmap_chain.o x86/init.o x86/xsave.o x86/debug.o x86/pmu.o x86/kvmclock_test.o x86/pcid.o x86/umip.o x86/setjmp.o x86/eventinj.o x86/hyperv_connections.o x86/apic.o x86/dummy.o x86/hypercall.o x86/vmexit.o x86/tsx-ctrl.o x86/hyperv_synic.o x86/smap.o x86/hyperv_stimer.o x86/efi/efistart64.o x86/smptest.o > > The error does not happen if the test is not configured with --target-efi. > > I bisected the error to commit 9734b4236294 ("x86/debug: Add framework for > single-step #DB tests"). Changing the Makefile to build x86/debug.o when > !TARGET_EFI has fixed the issue for me (it might be that the inline assembly > added by the commit contains absolute addresses, but my knowledge of x86 > assembly is sketchy at best): Fix posted: https://lore.kernel.org/all/20220210092044.18808-1-zhenzhong.duan@xxxxxxxxx