All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/2] package/dmalloc: fix strndup detection
@ 2022-06-10 21:05 Fabrice Fontaine
  2022-06-10 21:05 ` [Buildroot] [PATCH 2/2] package/dmalloc: disable stack-protector Fabrice Fontaine
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Fabrice Fontaine @ 2022-06-10 21:05 UTC (permalink / raw)
  To: buildroot; +Cc: Fabrice Fontaine

Fix strndup detection as already done for strdup in commit
f9287b263f0808c2f0632aa1560d88e39fbf970b to avoid the following build
failure raised since bump to version 5.6.5 in commit
736932c71552adc4dfa95c5236d1064860900e8a:

In file included from /nvmedata/autobuild/instance-0/output-1/host/mipsel-buildroot-linux-gnu/sysroot/usr/include/string.h:630:0,
                 from append.c:34:
dmalloc.h:396:7: error: expected identifier or '(' before '__extension__'
 char *strndup(const char *string, const DMALLOC_SIZE max_len);
       ^

Fixes:
 - http://autobuild.buildroot.org/results/2164dac43e2607a3570e8f98957a70f579d06cd3

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 package/dmalloc/dmalloc.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/package/dmalloc/dmalloc.mk b/package/dmalloc/dmalloc.mk
index 93dc45c15d..81ac467277 100644
--- a/package/dmalloc/dmalloc.mk
+++ b/package/dmalloc/dmalloc.mk
@@ -49,6 +49,7 @@ DMALLOC_CONF_ENV = CFLAGS="$(DMALLOC_CFLAGS)"
 define DMALLOC_POST_PATCH
 	$(SED) 's/^ac_cv_page_size=0$$/ac_cv_page_size=12/' $(@D)/configure
 	$(SED) 's/ac_cv_strdup_macro=no$$/ac_cv_strdup_macro=yes/' $(@D)/configure
+	$(SED) 's/ac_cv_strndup_macro=no$$/ac_cv_strndup_macro=yes/' $(@D)/configure
 	$(SED) 's/(ld -/($${LD-ld} -/' $(@D)/configure
 	$(SED) 's/'\''ld -/"$${LD-ld}"'\'' -/' $(@D)/configure
 	$(SED) 's/ar cr/$$(AR) cr/' $(@D)/Makefile.in
-- 
2.35.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* [Buildroot] [PATCH 2/2] package/dmalloc: disable stack-protector
  2022-06-10 21:05 [Buildroot] [PATCH 1/2] package/dmalloc: fix strndup detection Fabrice Fontaine
@ 2022-06-10 21:05 ` Fabrice Fontaine
  2022-06-12 20:37   ` Yann E. MORIN
  2022-06-12 20:23 ` [Buildroot] [PATCH 1/2] package/dmalloc: fix strndup detection Yann E. MORIN
  2022-06-19 13:41 ` Peter Korsgaard
  2 siblings, 1 reply; 6+ messages in thread
From: Fabrice Fontaine @ 2022-06-10 21:05 UTC (permalink / raw)
  To: buildroot; +Cc: Fabrice Fontaine

Fix the following build failure with stack-protector:

/home/autobuild/autobuild/instance-1/output-1/per-package/dmalloc/host/bin/i686-buildroot-linux-gnu-ld -shared --whole-archive -soname libdmallocth.so -o libdmallocth.so.t libdmallocth.a
/home/autobuild/autobuild/instance-1/output-1/per-package/dmalloc/host/bin/i686-buildroot-linux-gnu-ld: libdmallocth.a(append.o): in function `append_long':
append.c:(.text+0x115): undefined reference to `__stack_chk_fail_local'

Fixes:
 - http://autobuild.buildroot.org/results/f808885dcbbe4322631fa57f72af23009babcb26

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 package/dmalloc/dmalloc.mk | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/package/dmalloc/dmalloc.mk b/package/dmalloc/dmalloc.mk
index 81ac467277..f0a05412c1 100644
--- a/package/dmalloc/dmalloc.mk
+++ b/package/dmalloc/dmalloc.mk
@@ -12,7 +12,11 @@ DMALLOC_LICENSE = ISC
 DMALLOC_LICENSE_FILES = LICENSE.txt
 
 DMALLOC_INSTALL_STAGING = YES
-DMALLOC_CFLAGS = $(TARGET_CFLAGS)
+# dmalloc must be compiled with no stack protection as it builds its shared
+# library from its static library through --whole-archive, so forcefully pass
+# -fno-stack-protector to override what Buildroot may have in TARGET_CFLAGS if
+# BR2_SSP_* support is enabled.
+DMALLOC_CFLAGS = $(TARGET_CFLAGS) -fno-stack-protector
 
 ifeq ($(BR2_STATIC_LIBS),y)
 DMALLOC_CONF_OPTS += --disable-shlib
-- 
2.35.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 1/2] package/dmalloc: fix strndup detection
  2022-06-10 21:05 [Buildroot] [PATCH 1/2] package/dmalloc: fix strndup detection Fabrice Fontaine
  2022-06-10 21:05 ` [Buildroot] [PATCH 2/2] package/dmalloc: disable stack-protector Fabrice Fontaine
@ 2022-06-12 20:23 ` Yann E. MORIN
  2022-06-19 13:41 ` Peter Korsgaard
  2 siblings, 0 replies; 6+ messages in thread
From: Yann E. MORIN @ 2022-06-12 20:23 UTC (permalink / raw)
  To: Fabrice Fontaine; +Cc: buildroot

Fabrice, All,

On 2022-06-10 23:05 +0200, Fabrice Fontaine spake thusly:
> Fix strndup detection as already done for strdup in commit
> f9287b263f0808c2f0632aa1560d88e39fbf970b to avoid the following build
> failure raised since bump to version 5.6.5 in commit
> 736932c71552adc4dfa95c5236d1064860900e8a:
> 
> In file included from /nvmedata/autobuild/instance-0/output-1/host/mipsel-buildroot-linux-gnu/sysroot/usr/include/string.h:630:0,
>                  from append.c:34:
> dmalloc.h:396:7: error: expected identifier or '(' before '__extension__'
>  char *strndup(const char *string, const DMALLOC_SIZE max_len);
>        ^
> 
> Fixes:
>  - http://autobuild.buildroot.org/results/2164dac43e2607a3570e8f98957a70f579d06cd3
> 
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

Applied to master, thanks.

Regards,
Yann E. MORIN.

> ---
>  package/dmalloc/dmalloc.mk | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/package/dmalloc/dmalloc.mk b/package/dmalloc/dmalloc.mk
> index 93dc45c15d..81ac467277 100644
> --- a/package/dmalloc/dmalloc.mk
> +++ b/package/dmalloc/dmalloc.mk
> @@ -49,6 +49,7 @@ DMALLOC_CONF_ENV = CFLAGS="$(DMALLOC_CFLAGS)"
>  define DMALLOC_POST_PATCH
>  	$(SED) 's/^ac_cv_page_size=0$$/ac_cv_page_size=12/' $(@D)/configure
>  	$(SED) 's/ac_cv_strdup_macro=no$$/ac_cv_strdup_macro=yes/' $(@D)/configure
> +	$(SED) 's/ac_cv_strndup_macro=no$$/ac_cv_strndup_macro=yes/' $(@D)/configure
>  	$(SED) 's/(ld -/($${LD-ld} -/' $(@D)/configure
>  	$(SED) 's/'\''ld -/"$${LD-ld}"'\'' -/' $(@D)/configure
>  	$(SED) 's/ar cr/$$(AR) cr/' $(@D)/Makefile.in
> -- 
> 2.35.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 2/2] package/dmalloc: disable stack-protector
  2022-06-10 21:05 ` [Buildroot] [PATCH 2/2] package/dmalloc: disable stack-protector Fabrice Fontaine
@ 2022-06-12 20:37   ` Yann E. MORIN
  2023-02-08 16:28     ` Yann E. MORIN
  0 siblings, 1 reply; 6+ messages in thread
From: Yann E. MORIN @ 2022-06-12 20:37 UTC (permalink / raw)
  To: Fabrice Fontaine; +Cc: buildroot

Fabrice, All,

On 2022-06-10 23:05 +0200, Fabrice Fontaine spake thusly:
> Fix the following build failure with stack-protector:
> 
> /home/autobuild/autobuild/instance-1/output-1/per-package/dmalloc/host/bin/i686-buildroot-linux-gnu-ld -shared --whole-archive -soname libdmallocth.so -o libdmallocth.so.t libdmallocth.a
> /home/autobuild/autobuild/instance-1/output-1/per-package/dmalloc/host/bin/i686-buildroot-linux-gnu-ld: libdmallocth.a(append.o): in function `append_long':
> append.c:(.text+0x115): undefined reference to `__stack_chk_fail_local'
> 
> Fixes:
>  - http://autobuild.buildroot.org/results/f808885dcbbe4322631fa57f72af23009babcb26
> 
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> ---
>  package/dmalloc/dmalloc.mk | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/package/dmalloc/dmalloc.mk b/package/dmalloc/dmalloc.mk
> index 81ac467277..f0a05412c1 100644
> --- a/package/dmalloc/dmalloc.mk
> +++ b/package/dmalloc/dmalloc.mk
> @@ -12,7 +12,11 @@ DMALLOC_LICENSE = ISC
>  DMALLOC_LICENSE_FILES = LICENSE.txt
>  
>  DMALLOC_INSTALL_STAGING = YES
> -DMALLOC_CFLAGS = $(TARGET_CFLAGS)
> +# dmalloc must be compiled with no stack protection as it builds its shared
> +# library from its static library through --whole-archive, so forcefully pass
> +# -fno-stack-protector to override what Buildroot may have in TARGET_CFLAGS if
> +# BR2_SSP_* support is enabled.
> +DMALLOC_CFLAGS = $(TARGET_CFLAGS) -fno-stack-protector

At the risk of more goofiness, but the reference build issue had me
notice that dmalloc uses ld to do the link phase, while it should really
call gcc.

Indeed, I think the issue really is that -lssp (or the like) is missing
in the link command.

We have some very old, legacy, unexpained code that been there since the
dawn of times, that tweaks dmalloc's configure to shoehorn the cross-ld:

    $(SED) 's/(ld -/($${LD-ld} -/' $(@D)/configure
    $(SED) 's/'\''ld -/"$${LD-ld}"'\'' -/' $(@D)/configure

This should be converted over to use gcc, which would then properly pull
in the libraries needed when SSP is on.

However, this is not going to be trivial -whole-archive is not known to
gcc, so it must be passed as -Wl,-whole-archive.

Furthermore, -Wl,-no-whole-archive must be pased after the static
libdmalloc.a library (as explaiend in the ld manpage).

So, thisis a bit of a bigger change, but I otherwise fdo not think that
disabling SSP is a good idea, especially for a library that deals with
allocating memory...

Regards,
Yann E. MORIN.

>  ifeq ($(BR2_STATIC_LIBS),y)
>  DMALLOC_CONF_OPTS += --disable-shlib
> -- 
> 2.35.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 1/2] package/dmalloc: fix strndup detection
  2022-06-10 21:05 [Buildroot] [PATCH 1/2] package/dmalloc: fix strndup detection Fabrice Fontaine
  2022-06-10 21:05 ` [Buildroot] [PATCH 2/2] package/dmalloc: disable stack-protector Fabrice Fontaine
  2022-06-12 20:23 ` [Buildroot] [PATCH 1/2] package/dmalloc: fix strndup detection Yann E. MORIN
@ 2022-06-19 13:41 ` Peter Korsgaard
  2 siblings, 0 replies; 6+ messages in thread
From: Peter Korsgaard @ 2022-06-19 13:41 UTC (permalink / raw)
  To: Fabrice Fontaine, buildroot

On 10/06/2022 23.05, Fabrice Fontaine wrote:
> Fix strndup detection as already done for strdup in commit
> f9287b263f0808c2f0632aa1560d88e39fbf970b to avoid the following build
> failure raised since bump to version 5.6.5 in commit
> 736932c71552adc4dfa95c5236d1064860900e8a:
> 
> In file included from /nvmedata/autobuild/instance-0/output-1/host/mipsel-buildroot-linux-gnu/sysroot/usr/include/string.h:630:0,
>                   from append.c:34:
> dmalloc.h:396:7: error: expected identifier or '(' before '__extension__'
>   char *strndup(const char *string, const DMALLOC_SIZE max_len);
>         ^
> 
> Fixes:
>   - http://autobuild.buildroot.org/results/2164dac43e2607a3570e8f98957a70f579d06cd3
> 
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

Committed to 2022.05.x and 2022.02.x, thanks.

-- 
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 2/2] package/dmalloc: disable stack-protector
  2022-06-12 20:37   ` Yann E. MORIN
@ 2023-02-08 16:28     ` Yann E. MORIN
  0 siblings, 0 replies; 6+ messages in thread
From: Yann E. MORIN @ 2023-02-08 16:28 UTC (permalink / raw)
  To: Fabrice Fontaine; +Cc: buildroot

Fabrice, All,

On 2022-06-12 22:37 +0200, Yann E. MORIN spake thusly:
> On 2022-06-10 23:05 +0200, Fabrice Fontaine spake thusly:
> > Fix the following build failure with stack-protector:
> > /home/autobuild/autobuild/instance-1/output-1/per-package/dmalloc/host/bin/i686-buildroot-linux-gnu-ld -shared --whole-archive -soname libdmallocth.so -o libdmallocth.so.t libdmallocth.a
> > /home/autobuild/autobuild/instance-1/output-1/per-package/dmalloc/host/bin/i686-buildroot-linux-gnu-ld: libdmallocth.a(append.o): in function `append_long':
> > append.c:(.text+0x115): undefined reference to `__stack_chk_fail_local'
[--SNIP--]
> > +DMALLOC_CFLAGS = $(TARGET_CFLAGS) -fno-stack-protector
> 
> At the risk of more goofiness, but the reference build issue had me
> notice that dmalloc uses ld to do the link phase, while it should really
> call gcc.
[--SNIP--]
> So, thisis a bit of a bigger change, but I otherwise fdo not think that
> disabling SSP is a good idea, especially for a library that deals with
> allocating memory...

So, I eventually took the day to look at this during the dev-days.

I've sent an updated series now:
    https://patchwork.ozlabs.org/project/buildroot/list/?series=340858

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

end of thread, other threads:[~2023-02-08 16:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-10 21:05 [Buildroot] [PATCH 1/2] package/dmalloc: fix strndup detection Fabrice Fontaine
2022-06-10 21:05 ` [Buildroot] [PATCH 2/2] package/dmalloc: disable stack-protector Fabrice Fontaine
2022-06-12 20:37   ` Yann E. MORIN
2023-02-08 16:28     ` Yann E. MORIN
2022-06-12 20:23 ` [Buildroot] [PATCH 1/2] package/dmalloc: fix strndup detection Yann E. MORIN
2022-06-19 13:41 ` Peter Korsgaard

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.