Skip to contentSkip to conversation

toolchain: handle toolchains with SSP in libssp.so (branch yem/libssp)

PATCH New Yann E. MORIN 3 participants 6 messages Oct 25, 2019 – Oct 30, 2019

lore
Share & tools
lore
#0 lore raw

v2 cover toolchain: handle toolchains with SSP in libssp.so (branch yem/libssp)

Hello All!

This small series fixes a build failure of sox with external toolchains that implement SSP support in libssp.so from gcc, not the C library.

It is a respin from Yann's series, essentially with enhanced commit logs.

Regards,
Yann E. MORIN.

The following changes since commit 900024a2bbf989cdece1e2c41f579f7eac13617a

package/qemu: Add option to enable USB passthrough support on host variant (2019-10-25 10:39:25 +0200)

are available in the git repository at:

git://git.buildroot.org/~ymorin/git/buildroot.git

for you to fetch changes up to 0311678e7e917354544483e815ce7112d9fe830c

packages/sox: unconditionaly disable custom SSP detection (2019-10-25 15:32:33 +0200)

----------------------------------------------------------------
Yann Droneaud (2):
toolchain/external: copy libssp.so if SSP is enabled packages/sox: unconditionaly disable custom SSP detection

 package/sox/sox.mk                                     | 12 +++++-------
 toolchain/toolchain-external/pkg-toolchain-external.mk |  4 ++++
 2 files changed, 9 insertions(+), 7 deletions(-)
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  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.  |
'------------------------------^-------^------------------^--------------------'
#1 lore raw

PATCH v2 1/2 toolchain/external: copy libssp.so if SSP is enabled

From: Yann Droneaud <[email protected]>

In Buildroot, the internal toolchain backend uses the SSP support from the C library, not that of gcc.

Some external toolchains come with SSP suport in gcc, which is implemented in libssp.so, rather than in the C library.

When a toolchain even has both, it is up to the compiler to decide whether it will link to libssp or use the support from the C library.

However, in the latter case, a (incorrectly written) package may decide to explicitly link with libssp.so when it is available (even though the compiler may have decided otherwise if left by itself). This is the case for example with sox, which results in runtime failures, such as:

    $ sox
    sox: error while loading shared libraries: libssp.so.0: cannot open
    shared object file: No such file or directory

Even if sox is wrong in doing so, the case for libssp-only toolchains is still valid, and we must copy it as we copy other libs.

---
Changes v1 -> v2:
- enhance the commit log (Yann, the other one)

---
 toolchain/toolchain-external/pkg-toolchain-external.mk | 4 ++++
 1 file changed, 4 insertions(+)
toolchain/toolchain-external/pkg-toolchain-external.mk +4 -0
index c00211d59c..5eecd2a269 100644
@@ -114,6 +114,10 @@ endif
 
 TOOLCHAIN_EXTERNAL_LIBS += ld*.so* libgcc_s.so.* libatomic.so.*
 
+ifneq ($(BR2_SSP_NONE),y)
+TOOLCHAIN_EXTERNAL_LIBS += libssp.so.*
+endif
+
 ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GLIBC)$(BR2_TOOLCHAIN_EXTERNAL_UCLIBC),y)
 TOOLCHAIN_EXTERNAL_LIBS += libc.so.* libcrypt.so.* libdl.so.* libm.so.* libnsl.so.* libresolv.so.* librt.so.* libutil.so.*
 ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
Signature · 1 line
2.20.1
#2 lore raw

PATCH v2 1/2 toolchain/external: copy libssp.so if SSP is enabled

Quoted 24 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

From: Yann Droneaud <[email protected]>
In Buildroot, the internal toolchain backend uses the SSP support from the C library, not that of gcc.

Some external toolchains come with SSP suport in gcc, which is implemented in libssp.so, rather than in the C library.

When a toolchain even has both, it is up to the compiler to decide whether it will link to libssp or use the support from the C library.

However, in the latter case, a (incorrectly written) package may decide to explicitly link with libssp.so when it is available (even though the compiler may have decided otherwise if left by itself). This is the case for example with sox, which results in runtime failures, such as:

    $ sox
    sox: error while loading shared libraries: libssp.so.0: cannot open
    shared object file: No such file or directory

Even if sox is wrong in doing so, the case for libssp-only toolchains is still valid, and we must copy it as we copy other libs.

Quoted 6 lines

---
Changes v1 -> v2:
- enhance the commit log (Yann, the other one)

Committed to 2019.02.x and 2019.08.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH v2 2/2 packages/sox: unconditionaly disable custom SSP detection

In reply to Yann E. MORIN

From: Yann Droneaud <[email protected]>

sox implements a custom mechanism to detect whether the toolchain has SSP suport or not. In doing so, it explicitly tries to see if libssp.so is present, in which case it unconditionally links with it, even though the compiler, if left by itself, would have used the SSP support provided by the C library.

However, with Buildroot, the SSP options arfe handled in our gcc wrapper, so packages should just not bother with that.

It turns out that, when sox is configured with --disable-stack-protector, it does not disable it, but really does nothing, which is good for us.

Currently, SSP is conditionally disabled in sox, under various
conditions: that the toolchain does not have SSP, or that it is one of the know SSP-challenged (i.e. broken) toolchains. Those conditions dates back tpo before our wrapper started handling that.

Remove all those conditions, unconditionally disable SSP in sox, and let our gcc wrapper handle the SSP options.

---
Changes v1 -> v2:
- reword commit log (Yann)
- remove all conditions (Yann)

---
 package/sox/sox.mk | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
package/sox/sox.mk +5 -7
index 0b3dc136d8..013ccbbcf4 100644
@@ -8,16 +8,14 @@ SOX_VERSION = 14.4.2
 SOX_SITE = http://downloads.sourceforge.net/project/sox/sox/$(SOX_VERSION)
 SOX_SOURCE = sox-$(SOX_VERSION).tar.bz2
 SOX_DEPENDENCIES = host-pkgconf
-SOX_CONF_OPTS = --with-distro="Buildroot" --without-ffmpeg --disable-gomp \
-	$(if $(BR2_TOOLCHAIN_HAS_SSP),,--disable-stack-protector)
 SOX_LICENSE = GPL-2.0+ (sox binary), LGPL-2.1+ (libraries)
 SOX_LICENSE_FILES = LICENSE.GPL LICENSE.LGPL
 
-# MIPS Codescape toolchains don't support stack-smashing protection
-# despite of using glibc.
-ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESCAPE_IMG_MIPS)$(BR2_TOOLCHAIN_EXTERNAL_CODESCAPE_MTI_MIPS),y)
-SOX_CONF_OPTS += --disable-stack-protector
-endif
+SOX_CONF_OPTS = \
+	--with-distro="Buildroot" \
+	--without-ffmpeg \
+	--disable-gomp \
+	--disable-stack-protector
 
 ifeq ($(BR2_PACKAGE_ALSA_LIB_PCM),y)
 SOX_DEPENDENCIES += alsa-lib
Signature · 1 line
2.20.1
#4 lore raw

PATCH v2 2/2 packages/sox: unconditionaly disable custom SSP detection

Quoted 23 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

From: Yann Droneaud <[email protected]>
sox implements a custom mechanism to detect whether the toolchain has SSP suport or not. In doing so, it explicitly tries to see if libssp.so is present, in which case it unconditionally links with it, even though the compiler, if left by itself, would have used the SSP support provided by the C library.

However, with Buildroot, the SSP options arfe handled in our gcc wrapper, so packages should just not bother with that.

It turns out that, when sox is configured with --disable-stack-protector, it does not disable it, but really does nothing, which is good for us.

Currently, SSP is conditionally disabled in sox, under various
conditions: that the toolchain does not have SSP, or that it is one of the know SSP-challenged (i.e. broken) toolchains. Those conditions dates back tpo before our wrapper started handling that.

Remove all those conditions, unconditionally disable SSP in sox, and let our gcc wrapper handle the SSP options.

Quoted 7 lines

---
Changes v1 -> v2:
- reword commit log (Yann)
- remove all conditions (Yann)

Committed to 2019.02.x and 2019.08.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#5 lore raw

v2 cover toolchain: handle toolchains with SSP in libssp.so (branch yem/libssp)

In reply to Yann E. MORIN
Quoted 3 lines · On Fri, 25 Oct 2019 15:42:39 +0200 "Yann E. MORIN" <[email protected]>…

Yann Droneaud (2):
toolchain/external: copy libssp.so if SSP is enabled packages/sox: unconditionaly disable custom SSP detection

Thanks, applied!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com