diff mbox series

[babeltrace,stable-1.5] Fix: python bindings when building with PIE hardening

Message ID 1508963431-14553-1-git-send-email-mjeanson@efficios.com
State Accepted, archived
Delegated to: Jérémie Galarneau
Headers show
Series [babeltrace,stable-1.5] Fix: python bindings when building with PIE hardening | expand

Commit Message

Michael Jeanson Oct. 25, 2017, 8:30 p.m. UTC
Work around a bug/limitation in python distutils where object files are
built with -fPIC appended after the CFLAGS but the final shared object
is linked with -shared before the LDFLAGS which can then be overriden by
hardening flags and result in an invalid build.

The work around is to append -shared to the LDFLAGS making sure it's not
overriden.

Signed-off-by: Michael Jeanson <mjeanson at efficios.com>
---
 bindings/python/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jérémie Galarneau Nov. 13, 2017, 11:43 p.m. UTC | #1
Merged, thanks!

Jérémie

On 25 October 2017 at 16:30, Michael Jeanson <mjeanson at efficios.com> wrote:
> Work around a bug/limitation in python distutils where object files are
> built with -fPIC appended after the CFLAGS but the final shared object
> is linked with -shared before the LDFLAGS which can then be overriden by
> hardening flags and result in an invalid build.
>
> The work around is to append -shared to the LDFLAGS making sure it's not
> overriden.
>
> Signed-off-by: Michael Jeanson <mjeanson at efficios.com>
> ---
>  bindings/python/Makefile.am | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am
> index 2ceab03..5e4dde8 100644
> --- a/bindings/python/Makefile.am
> +++ b/bindings/python/Makefile.am
> @@ -25,7 +25,7 @@ BINDINGS_DEPS=setup.py \
>  BUILD_FLAGS=CC="$(CC)" \
>                 CFLAGS="$(GLIB_CFLAGS) $(AM_CFLAGS) $(CFLAGS)" \
>                 CPPFLAGS="$(DEFS) $(DEFAULT_INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)" \
> -               LDFLAGS="$(AM_LDFLAGS) $(LDFLAGS) $(GLIB_LIBS) $(LIBS)"
> +               LDFLAGS="$(AM_LDFLAGS) $(LDFLAGS) $(GLIB_LIBS) -shared $(LIBS)"
>
>  build-python-bindings.stamp: $(BINDINGS_DEPS)
>         $(BUILD_FLAGS) $(PYTHON) $(builddir)/setup.py build_ext
> --
> 2.7.4
>
diff mbox series

Patch

diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am
index 2ceab03..5e4dde8 100644
--- a/bindings/python/Makefile.am
+++ b/bindings/python/Makefile.am
@@ -25,7 +25,7 @@  BINDINGS_DEPS=setup.py \
 BUILD_FLAGS=CC="$(CC)" \
 		CFLAGS="$(GLIB_CFLAGS) $(AM_CFLAGS) $(CFLAGS)" \
 		CPPFLAGS="$(DEFS) $(DEFAULT_INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)" \
-		LDFLAGS="$(AM_LDFLAGS) $(LDFLAGS) $(GLIB_LIBS) $(LIBS)"
+		LDFLAGS="$(AM_LDFLAGS) $(LDFLAGS) $(GLIB_LIBS) -shared $(LIBS)"
 
 build-python-bindings.stamp: $(BINDINGS_DEPS)
 	$(BUILD_FLAGS) $(PYTHON) $(builddir)/setup.py build_ext