[LTP] [PATCH 2/2] kvm: Fix undefined reference to __stack_chk_fail()

Martin Doucha mdoucha@suse.cz
Thu Jun 9 10:26:55 CEST 2022


On 06. 06. 22 20:43, Petr Vorel wrote:
> Some x86_64 buildroot toolchains (bootlin-x86-64-glibc,
> bootlin-x86-64-musl) try to link to __stack_chk_fail().
> -nostdlib is not enough, it requires also -fstack-protector.
> 
> x86_64-buildroot-linux-gnu/bin/ld: /tmp/ccgBXEoR.o: in function `handle_page_fault':
> kvm_pagefault01.c:(.text+0x5d): undefined reference to `__stack_chk_fail'
> collect2: error: ld returned 1 exit status
> 
> Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
> ---
>  testcases/kernel/kvm/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/testcases/kernel/kvm/Makefile b/testcases/kernel/kvm/Makefile
> index 8d5193d8e..bce1a4eb5 100644
> --- a/testcases/kernel/kvm/Makefile
> +++ b/testcases/kernel/kvm/Makefile
> @@ -9,7 +9,7 @@ ASFLAGS =
>  CPPFLAGS += -I$(abs_srcdir)/include
>  GUEST_CPPFLAGS = $(CPPFLAGS) -DCOMPILE_PAYLOAD
>  GUEST_CFLAGS = -ffreestanding -O2 -Wall -fno-asynchronous-unwind-tables -mno-mmx -mno-sse
> -GUEST_LDFLAGS = -nostdlib -Wl,--build-id=none
> +GUEST_LDFLAGS = -nostdlib -Wl,--build-id=none -fstack-protector

We should use -fno-stack-protector here instead. Your patch probably
enables linking of libssp despite -nostdlib which we don't want. The GCC
stack protector may also break tests because bootstrap initializes stack
manually instead of letting GCC handle it.

>  GUEST_LDLIBS =
>  
>  FILTER_OUT_MAKE_TARGETS := lib_guest lib_host lib_x86


-- 
Martin Doucha   mdoucha@suse.cz
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


More information about the ltp mailing list