mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] Kbuild: link barebox with -z noexecstack
@ 2022-11-02 12:48 Ahmad Fatoum
  2022-11-02 12:55 ` Ahmad Fatoum
  0 siblings, 1 reply; 3+ messages in thread
From: Ahmad Fatoum @ 2022-11-02 12:48 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum, Christian Melki

We don't care for permission of ELF segments, but GNU ld (BFD)
does and now with binutils 2.39+, it reports:

  ld: warning: defaultenv/defaultenv-2-menu.bbenv.o: missing
  .note.GNU-stack section implies executable stack

  ld: NOTE: This behaviour is deprecated and will be removed in a future
  version of the linker

Instead of touching all assembly objects and scripts creating them to
add the section, just set -z noexecstack at link-time. This is already
the LLVM linker (lld) default.

Reported-by: Christian Melki <christian.melki@t2data.com>
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 26a0999a2e20..e57b8a4a1364 100644
--- a/Makefile
+++ b/Makefile
@@ -450,7 +450,7 @@ KBUILD_CFLAGS_KERNEL :=
 KBUILD_AFLAGS_MODULE := -DMODULE
 KBUILD_CFLAGS_MODULE := -DMODULE
 
-LDFLAGS_barebox	:= -Map barebox.map
+LDFLAGS_barebox	:= -Map barebox.map -z noexecstack
 
 # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
 LDFLAGS_barebox += $(call ld-option, --no-dynamic-linker)
-- 
2.37.2




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

* Re: [PATCH] Kbuild: link barebox with -z noexecstack
  2022-11-02 12:48 [PATCH] Kbuild: link barebox with -z noexecstack Ahmad Fatoum
@ 2022-11-02 12:55 ` Ahmad Fatoum
  2022-11-05 12:15   ` Ahmad Fatoum
  0 siblings, 1 reply; 3+ messages in thread
From: Ahmad Fatoum @ 2022-11-02 12:55 UTC (permalink / raw)
  To: Ahmad Fatoum, barebox; +Cc: Christian Melki

On 02.11.22 13:48, Ahmad Fatoum wrote:
> We don't care for permission of ELF segments, but GNU ld (BFD)
> does and now with binutils 2.39+, it reports:
> 
>   ld: warning: defaultenv/defaultenv-2-menu.bbenv.o: missing
>   .note.GNU-stack section implies executable stack
> 
>   ld: NOTE: This behaviour is deprecated and will be removed in a future
>   version of the linker
> 
> Instead of touching all assembly objects and scripts creating them to
> add the section, just set -z noexecstack at link-time. This is already
> the LLVM linker (lld) default.
> 
> Reported-by: Christian Melki <christian.melki@t2data.com>
> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
> ---

Please dismiss. I think we should just add it to KBUILD_LDFLAGS globally.

>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 26a0999a2e20..e57b8a4a1364 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -450,7 +450,7 @@ KBUILD_CFLAGS_KERNEL :=
>  KBUILD_AFLAGS_MODULE := -DMODULE
>  KBUILD_CFLAGS_MODULE := -DMODULE
>  
> -LDFLAGS_barebox	:= -Map barebox.map
> +LDFLAGS_barebox	:= -Map barebox.map -z noexecstack
>  
>  # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
>  LDFLAGS_barebox += $(call ld-option, --no-dynamic-linker)

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




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

* Re: [PATCH] Kbuild: link barebox with -z noexecstack
  2022-11-02 12:55 ` Ahmad Fatoum
@ 2022-11-05 12:15   ` Ahmad Fatoum
  0 siblings, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2022-11-05 12:15 UTC (permalink / raw)
  To: Ahmad Fatoum, barebox; +Cc: Christian Melki

On 02.11.22 13:55, Ahmad Fatoum wrote:
> On 02.11.22 13:48, Ahmad Fatoum wrote:
>> We don't care for permission of ELF segments, but GNU ld (BFD)
>> does and now with binutils 2.39+, it reports:
>>
>>   ld: warning: defaultenv/defaultenv-2-menu.bbenv.o: missing
>>   .note.GNU-stack section implies executable stack
>>
>>   ld: NOTE: This behaviour is deprecated and will be removed in a future
>>   version of the linker
>>
>> Instead of touching all assembly objects and scripts creating them to
>> add the section, just set -z noexecstack at link-time. This is already
>> the LLVM linker (lld) default.
>>
>> Reported-by: Christian Melki <christian.melki@t2data.com>
>> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
>> ---
> 
> Please dismiss. I think we should just add it to KBUILD_LDFLAGS globally.

I'll be away for a few weeks, so noting here how Linux does it:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ffcf9c5700e49c0aee42dcba9a12ba21338e8136
https://lore.kernel.org/all/20220808192321.3490995-1-ndesaulniers@google.com/

In case someone else wants to get rid of the warning in the meantime.

Cheers,
Ahmad


> 
>>  Makefile | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/Makefile b/Makefile
>> index 26a0999a2e20..e57b8a4a1364 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -450,7 +450,7 @@ KBUILD_CFLAGS_KERNEL :=
>>  KBUILD_AFLAGS_MODULE := -DMODULE
>>  KBUILD_CFLAGS_MODULE := -DMODULE
>>  
>> -LDFLAGS_barebox	:= -Map barebox.map
>> +LDFLAGS_barebox	:= -Map barebox.map -z noexecstack
>>  
>>  # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
>>  LDFLAGS_barebox += $(call ld-option, --no-dynamic-linker)
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




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

end of thread, other threads:[~2022-11-05 12:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-02 12:48 [PATCH] Kbuild: link barebox with -z noexecstack Ahmad Fatoum
2022-11-02 12:55 ` Ahmad Fatoum
2022-11-05 12:15   ` Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox