All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 0/2] LTP compilation fixes for buildroot toolchains
@ 2022-06-06 18:43 ` Petr Vorel
  0 siblings, 0 replies; 14+ 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] 14+ messages in thread

* [LTP] [PATCH 0/2] LTP compilation fixes for buildroot toolchains
@ 2022-06-06 18:43 ` Petr Vorel
  0 siblings, 0 replies; 14+ messages in thread
From: Petr Vorel @ 2022-06-06 18:43 UTC (permalink / raw)
  To: ltp
  Cc: Yann E. MORIN, Thomas Petazzoni, Buildroot Mailing List,
	Fabrice Fontaine

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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Buildroot] [PATCH 1/2] kvm: Fix compilation on x86
  2022-06-06 18:43 ` [LTP] " Petr Vorel
@ 2022-06-06 18:43   ` Petr Vorel
  -1 siblings, 0 replies; 14+ 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] 14+ messages in thread

* [LTP] [PATCH 1/2] kvm: Fix compilation on x86
@ 2022-06-06 18:43   ` Petr Vorel
  0 siblings, 0 replies; 14+ messages in thread
From: Petr Vorel @ 2022-06-06 18:43 UTC (permalink / raw)
  To: ltp
  Cc: Yann E. MORIN, Thomas Petazzoni, Buildroot Mailing List,
	Fabrice Fontaine

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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Buildroot] [PATCH 2/2] kvm: Fix undefined reference to __stack_chk_fail()
  2022-06-06 18:43 ` [LTP] " Petr Vorel
@ 2022-06-06 18:43   ` Petr Vorel
  -1 siblings, 0 replies; 14+ 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] 14+ messages in thread

* [LTP] [PATCH 2/2] kvm: Fix undefined reference to __stack_chk_fail()
@ 2022-06-06 18:43   ` Petr Vorel
  0 siblings, 0 replies; 14+ messages in thread
From: Petr Vorel @ 2022-06-06 18:43 UTC (permalink / raw)
  To: ltp
  Cc: Yann E. MORIN, Thomas Petazzoni, Buildroot Mailing List,
	Fabrice Fontaine

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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [LTP] [PATCH 2/2] kvm: Fix undefined reference to __stack_chk_fail()
  2022-06-06 18:43   ` [LTP] " Petr Vorel
  (?)
@ 2022-06-08 14:36   ` Cyril Hrubis
  -1 siblings, 0 replies; 14+ messages in thread
From: Cyril Hrubis @ 2022-06-08 14:36 UTC (permalink / raw)
  To: Petr Vorel
  Cc: Thomas Petazzoni, Buildroot Mailing List, Fabrice Fontaine,
	Yann E. MORIN, ltp

Hi!
> 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

I'm still puzzled on why does it try to link it. Why is stack protection
turned on for the code. Does buildroot pass -fstack-protector to the
CFLAGS?

I guess that -nostdlib causes the libssp (which implements
__stack_chk_fail() not to be linked by default, but the
__stack_chk_fail() shouldn't be called unless unless the feature is
enabled in the first place.

Also does -fno-stack-protector passed in GUEST_CFLAGS make it disappear?

> 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
> 

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LTP] [PATCH 1/2] kvm: Fix compilation on x86
  2022-06-06 18:43   ` [LTP] " Petr Vorel
  (?)
@ 2022-06-08 14:39   ` Cyril Hrubis
  -1 siblings, 0 replies; 14+ messages in thread
From: Cyril Hrubis @ 2022-06-08 14:39 UTC (permalink / raw)
  To: Petr Vorel
  Cc: Thomas Petazzoni, Buildroot Mailing List, Fabrice Fontaine,
	Yann E. MORIN, ltp

Hi!
> Buildroot supports i386 pentium toolchains (br-i386-pentium-mmx-musl,
> br-i386-pentium4-full) which fail to compile because as is run without --32.

So we have a 32bit compiler but 64bit linker?

I guess that passing -m32 to 32bit compiler is harmless, so this can go
in.

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

> 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
> 

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LTP] [PATCH 2/2] kvm: Fix undefined reference to __stack_chk_fail()
  2022-06-06 18:43   ` [LTP] " Petr Vorel
  (?)
  (?)
@ 2022-06-09  8:26   ` Martin Doucha
  2022-06-09 12:26       ` [LTP] " Thomas Petazzoni via ltp
  2022-06-10  7:56     ` Joerg Vehlow
  -1 siblings, 2 replies; 14+ messages in thread
From: Martin Doucha @ 2022-06-09  8:26 UTC (permalink / raw)
  To: Petr Vorel, ltp
  Cc: Thomas Petazzoni, Yann E. MORIN, Buildroot Mailing List,
	Fabrice Fontaine

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

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Buildroot] [PATCH 2/2] kvm: Fix undefined reference to __stack_chk_fail()
  2022-06-09  8:26   ` Martin Doucha
@ 2022-06-09 12:26       ` Thomas Petazzoni via ltp
  2022-06-10  7:56     ` Joerg Vehlow
  1 sibling, 0 replies; 14+ 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] 14+ messages in thread

* Re: [LTP] [PATCH 2/2] kvm: Fix undefined reference to __stack_chk_fail()
@ 2022-06-09 12:26       ` Thomas Petazzoni via ltp
  0 siblings, 0 replies; 14+ messages in thread
From: Thomas Petazzoni via ltp @ 2022-06-09 12:26 UTC (permalink / raw)
  To: Martin Doucha
  Cc: Yann E. MORIN, 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

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LTP] [PATCH 2/2] kvm: Fix undefined reference to __stack_chk_fail()
  2022-06-09  8:26   ` Martin Doucha
  2022-06-09 12:26       ` [LTP] " Thomas Petazzoni via ltp
@ 2022-06-10  7:56     ` Joerg Vehlow
  2022-06-13 21:31         ` Petr Vorel
  1 sibling, 1 reply; 14+ messages in thread
From: Joerg Vehlow @ 2022-06-10  7:56 UTC (permalink / raw)
  To: Martin Doucha, Petr Vorel, ltp
  Cc: Fabrice Fontaine, Yann E. MORIN, Thomas Petazzoni,
	Buildroot Mailing List

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.

> 
>>  GUEST_LDLIBS =
>>  
>>  FILTER_OUT_MAKE_TARGETS := lib_guest lib_host lib_x86
> 
> 

Joerg

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Buildroot] [LTP] [PATCH 2/2] kvm: Fix undefined reference to __stack_chk_fail()
  2022-06-10  7:56     ` Joerg Vehlow
@ 2022-06-13 21:31         ` Petr Vorel
  0 siblings, 0 replies; 14+ 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] 14+ messages in thread

* Re: [LTP] [PATCH 2/2] kvm: Fix undefined reference to __stack_chk_fail()
@ 2022-06-13 21:31         ` Petr Vorel
  0 siblings, 0 replies; 14+ messages in thread
From: Petr Vorel @ 2022-06-13 21:31 UTC (permalink / raw)
  To: Joerg Vehlow
  Cc: Yann E. MORIN, 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

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-06-13 21:31 UTC | newest]

Thread overview: 14+ 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 ` [LTP] " Petr Vorel
2022-06-06 18:43 ` [Buildroot] [PATCH 1/2] kvm: Fix compilation on x86 Petr Vorel
2022-06-06 18:43   ` [LTP] " Petr Vorel
2022-06-08 14:39   ` Cyril Hrubis
2022-06-06 18:43 ` [Buildroot] [PATCH 2/2] kvm: Fix undefined reference to __stack_chk_fail() Petr Vorel
2022-06-06 18:43   ` [LTP] " Petr Vorel
2022-06-08 14:36   ` Cyril Hrubis
2022-06-09  8:26   ` Martin Doucha
2022-06-09 12:26     ` [Buildroot] " Thomas Petazzoni via buildroot
2022-06-09 12:26       ` [LTP] " Thomas Petazzoni via ltp
2022-06-10  7:56     ` Joerg Vehlow
2022-06-13 21:31       ` [Buildroot] " Petr Vorel
2022-06-13 21:31         ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.