[lttng-dev] [PATCH] Remove -pie flag for shared library

Francis Giraldeau francis.giraldeau at gmail.com
Tue May 14 16:15:32 EDT 2013


Some build environment with hardening enabled adds -pie flags to LDFLAGS. While
it's required for ELF binaries, it doesn't make sens for shared libraries. For
this case, filter-out the erroneous option.

Signed-off-by: Francis Giraldeau <francis.giraldeau at gmail.com>
---
 doc/examples/demo/Makefile     | 6 ++++--
 doc/examples/easy-ust/Makefile | 4 +++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/doc/examples/demo/Makefile b/doc/examples/demo/Makefile
index bbc8ccb..3145146 100644
--- a/doc/examples/demo/Makefile
+++ b/doc/examples/demo/Makefile
@@ -34,6 +34,8 @@ EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \
 $(EMPTY_AUTOMAKE_TARGETS):
 endif
 
+CLEAN_LDFLAGS = $(filter-out -pie,$(LDFLAGS))
+
 all: demo lttng-ust-provider-ust-tests-demo.so lttng-ust-provider-ust-tests-demo3.so
 
 tp.o: tp.c ust_tests_demo.h
@@ -43,13 +45,13 @@ tp2.o: tp2.c ust_tests_demo2.h
 	$(CC) $(CPPFLAGS) $(CFLAGS) -fpic -c -o $@ $<
 
 lttng-ust-provider-ust-tests-demo.so: tp.o tp2.o
-	$(CC) -shared -o $@ $(LDFLAGS) -llttng-ust $^
+	$(CC) -shared -o $@ $(CLEAN_LDFLAGS) -llttng-ust $^
 
 tp3.o: tp3.c ust_tests_demo3.h
 	$(CC) $(CPPFLAGS) $(CFLAGS) -fpic -c -o $@ $<
 
 lttng-ust-provider-ust-tests-demo3.so: tp3.o
-	$(CC) -shared -o $@ $(LDFLAGS) -llttng-ust $^
+	$(CC) -shared -o $@ $(CLEAN_LDFLAGS) -llttng-ust $^
 
 demo.o: demo.c
 	$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
diff --git a/doc/examples/easy-ust/Makefile b/doc/examples/easy-ust/Makefile
index e20e53a..e95a2c5 100644
--- a/doc/examples/easy-ust/Makefile
+++ b/doc/examples/easy-ust/Makefile
@@ -36,10 +36,12 @@ EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall \
 $(EMPTY_AUTOMAKE_TARGETS):
 endif
 
+CLEAN_LDFLAGS = $(filter-out -pie,$(LDFLAGS))
+
 all: sample
 
 sample: sample.o tp.o
-	$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
+	$(CC) -o $@ $^ $(CLEAN_LDFLAGS) $(LIBS)
 
 sample.o: sample.c sample_component_provider.h
 	$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
-- 
1.8.1.2




More information about the lttng-dev mailing list