* [Buildroot] [PATCH 0/2] LTP compilation fixes for buildroot toolchains
@ 2022-06-06 18:43 Petr Vorel
2022-06-06 18:43 ` [Buildroot] [PATCH 1/2] kvm: Fix compilation on x86 Petr Vorel
2022-06-06 18:43 ` [Buildroot] [PATCH 2/2] kvm: Fix undefined reference to __stack_chk_fail() Petr Vorel
0 siblings, 2 replies; 5+ messages in thread
From: Petr Vorel @ 2022-06-06 18:43 UTC (permalink / raw)
To: ltp
Cc: Cyril Hrubis, Yann E. MORIN, Li Wang, Thomas Petazzoni,
Buildroot Mailing List, Fabrice Fontaine, Martin Doucha
Hi all,
this fixes 2 compilation failures of KVM tests reported some time ago [1].
Kind regards,
Petr
[1] https://lore.kernel.org/buildroot/YofzKdQAUOnR2gSW@pevik/
Petr Vorel (2):
kvm: Fix compilation on x86
kvm: Fix undefined reference to __stack_chk_fail()
testcases/kernel/kvm/Makefile | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
--
2.36.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Buildroot] [PATCH 1/2] kvm: Fix compilation on x86
2022-06-06 18:43 [Buildroot] [PATCH 0/2] LTP compilation fixes for buildroot toolchains Petr Vorel
@ 2022-06-06 18:43 ` Petr Vorel
2022-06-06 18:43 ` [Buildroot] [PATCH 2/2] kvm: Fix undefined reference to __stack_chk_fail() Petr Vorel
1 sibling, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2022-06-06 18:43 UTC (permalink / raw)
To: ltp
Cc: Cyril Hrubis, Yann E. MORIN, Li Wang, Thomas Petazzoni,
Buildroot Mailing List, Fabrice Fontaine, Martin Doucha
Buildroot supports i386 pentium toolchains (br-i386-pentium-mmx-musl,
br-i386-pentium4-full) which fail to compile because as is run without --32.
Suggested-by: Martin Doucha <mdoucha@suse.cz>
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
testcases/kernel/kvm/Makefile | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/kvm/Makefile b/testcases/kernel/kvm/Makefile
index adab56952..8d5193d8e 100644
--- a/testcases/kernel/kvm/Makefile
+++ b/testcases/kernel/kvm/Makefile
@@ -17,11 +17,14 @@ FILTER_OUT_MAKE_TARGETS := lib_guest lib_host lib_x86
ifeq ($(HOST_CPU),x86_64)
ifneq (,$(findstring m32,$(CFLAGS)))
HOST_CPU = x86
- GUEST_CFLAGS += -m32
- ASFLAGS += --32
endif
endif
+ifeq ($(HOST_CPU),x86)
+ GUEST_CFLAGS += -m32
+ ASFLAGS += --32
+endif
+
# Some distros enable -pie by default. That breaks KVM payload linking.
ifdef LTP_CFLAGS_NOPIE
GUEST_CFLAGS += -fno-pie
--
2.36.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Buildroot] [PATCH 2/2] kvm: Fix undefined reference to __stack_chk_fail()
2022-06-06 18:43 [Buildroot] [PATCH 0/2] LTP compilation fixes for buildroot toolchains Petr Vorel
2022-06-06 18:43 ` [Buildroot] [PATCH 1/2] kvm: Fix compilation on x86 Petr Vorel
@ 2022-06-06 18:43 ` Petr Vorel
[not found] ` <5d4a4e2b-4d1d-88d6-4905-67083c154775@suse.cz>
1 sibling, 1 reply; 5+ messages in thread
From: Petr Vorel @ 2022-06-06 18:43 UTC (permalink / raw)
To: ltp
Cc: Cyril Hrubis, Yann E. MORIN, Li Wang, Thomas Petazzoni,
Buildroot Mailing List, Fabrice Fontaine, Martin Doucha
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
GUEST_LDLIBS =
FILTER_OUT_MAKE_TARGETS := lib_guest lib_host lib_x86
--
2.36.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Buildroot] [PATCH 2/2] kvm: Fix undefined reference to __stack_chk_fail()
[not found] ` <5d4a4e2b-4d1d-88d6-4905-67083c154775@suse.cz>
@ 2022-06-09 12:26 ` Thomas Petazzoni via buildroot
[not found] ` <024cf3d9-f9c1-80a4-8b06-799309912c7f@jv-coder.de>
1 sibling, 0 replies; 5+ messages in thread
From: Thomas Petazzoni via buildroot @ 2022-06-09 12:26 UTC (permalink / raw)
To: Martin Doucha
Cc: Yann E. MORIN, Li Wang, Cyril Hrubis, Buildroot Mailing List,
Fabrice Fontaine, ltp
On Thu, 9 Jun 2022 10:26:55 +0200
Martin Doucha <mdoucha@suse.cz> wrote:
> > 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.
I agree. Assuming -nostdlib means you're building freestanding code,
then indeed, -fno-stack-protector is most likely what you want.
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Buildroot] [LTP] [PATCH 2/2] kvm: Fix undefined reference to __stack_chk_fail()
[not found] ` <024cf3d9-f9c1-80a4-8b06-799309912c7f@jv-coder.de>
@ 2022-06-13 21:31 ` Petr Vorel
0 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2022-06-13 21:31 UTC (permalink / raw)
To: Joerg Vehlow
Cc: Yann E. MORIN, Martin Doucha, Thomas Petazzoni,
Buildroot Mailing List, Fabrice Fontaine, ltp
Hi all,
> Hi,
> Am 6/9/2022 um 10:26 AM schrieb Martin Doucha:
> > 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.
> I can confirm, that adding -fno-stack-protector to GUEST_LDFLAGS fixes
> the linker error.
Thanks a lot for your input. Martin, thanks a lot for testing.
I also verified that -fno-stack-protector fix compilation, thus patchset merged.
Kind regards,
Petr
> >> GUEST_LDLIBS =
> >> FILTER_OUT_MAKE_TARGETS := lib_guest lib_host lib_x86
> Joerg
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-06-13 21:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-06 18:43 [Buildroot] [PATCH 0/2] LTP compilation fixes for buildroot toolchains Petr Vorel
2022-06-06 18:43 ` [Buildroot] [PATCH 1/2] kvm: Fix compilation on x86 Petr Vorel
2022-06-06 18:43 ` [Buildroot] [PATCH 2/2] kvm: Fix undefined reference to __stack_chk_fail() Petr Vorel
[not found] ` <5d4a4e2b-4d1d-88d6-4905-67083c154775@suse.cz>
2022-06-09 12:26 ` Thomas Petazzoni via buildroot
[not found] ` <024cf3d9-f9c1-80a4-8b06-799309912c7f@jv-coder.de>
2022-06-13 21:31 ` [Buildroot] [LTP] " Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox