Fix: build example SO when PIE is enabled
authorMichael Jeanson <mjeanson@efficios.com>
Wed, 25 Oct 2017 18:28:04 +0000 (14:28 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 20 Feb 2018 17:13:50 +0000 (12:13 -0500)
In the example Makefiles, when building shared object libraires, make sure
we set the custom linker options after the CFLAGS/LDFLAGS so that it
overrides them. This is useful when the build system set some hardening
features like PIE in the CFLAGS.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
doc/examples/clock-override/Makefile
doc/examples/demo/Makefile
doc/examples/getcpu-override/Makefile

index 5433427c10a31d3bfbad7cdc3756e2154e0fc05e..22e5dffb807812bd5e28444cb04c2ee0dd5582fe 100644 (file)
@@ -26,8 +26,8 @@ lttng-ust-clock-override-example.o: lttng-ust-clock-override-example.c
                $(CFLAGS) -fpic -c -o $@ $<
 
 lttng-ust-clock-override-example.so: lttng-ust-clock-override-example.o
-       $(CC) -shared -Wl,--no-as-needed -o $@ $(LDFLAGS) $(AM_CFLAGS) \
-               $(AM_LDFLAGS) $(CFLAGS) lttng-ust-clock-override-example.o
+       $(CC) -Wl,--no-as-needed -o $@ $(LDFLAGS) $(AM_CFLAGS) \
+               $(AM_LDFLAGS) $(CFLAGS) -shared -fpic lttng-ust-clock-override-example.o
 
 .PHONY: clean
 clean:
index 6272a2ba1081e1e1644c82c9a120952bfc199e29..bb7fc17368202b8bfbc5c1fd022c6711a61347fe 100644 (file)
@@ -29,16 +29,16 @@ tp2.o: tp2.c ust_tests_demo2.h
                $(CFLAGS) -fpic -c -o $@ $<
 
 lttng-ust-provider-ust-tests-demo.so: tp.o tp2.o
-       $(CC) -shared -Wl,--no-as-needed -o $@ $(LDFLAGS) $(AM_CFLAGS) \
-               $(AM_LDFLAGS) $(CFLAGS) -llttng-ust tp.o tp2.o
+       $(CC) -Wl,--no-as-needed -o $@ $(LDFLAGS) $(AM_CFLAGS) \
+               $(AM_LDFLAGS) $(CFLAGS) -shared -fpic tp.o tp2.o $(LIBS) -llttng-ust
 
 tp3.o: tp3.c ust_tests_demo3.h
        $(CC) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(AM_CFLAGS) $(AM_CPPFLAGS) \
                $(CFLAGS) -fpic -c -o $@ $<
 
 lttng-ust-provider-ust-tests-demo3.so: tp3.o
-       $(CC) -shared -Wl,--no-as-needed -o $@ $(LDFLAGS) $(AM_CFLAGS) \
-               $(AM_LDFLAGS) $(CFLAGS) -llttng-ust tp3.o
+       $(CC) -Wl,--no-as-needed -o $@ $(LDFLAGS) $(AM_CFLAGS) \
+               $(AM_LDFLAGS) $(CFLAGS) -shared -fpic tp3.o $(LIBS) -llttng-ust
 
 demo.o: demo.c
        $(CC) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(AM_CFLAGS) $(AM_CPPFLAGS) \
index de295c66c927a9cc53c365a66667e06f9542955d..e1e4892c6e1142b418909fb4ed7bdcb68932598f 100644 (file)
@@ -26,8 +26,8 @@ lttng-ust-getcpu-override-example.o: lttng-ust-getcpu-override-example.c
                $(CFLAGS) -fpic -c -o $@ $<
 
 lttng-ust-getcpu-override-example.so: lttng-ust-getcpu-override-example.o
-       $(CC) -shared -Wl,--no-as-needed -o $@ $(LDFLAGS) $(AM_CFLAGS) \
-               $(AM_LDFLAGS) $(CFLAGS) lttng-ust-getcpu-override-example.o
+       $(CC) -Wl,--no-as-needed -o $@ $(LDFLAGS) $(AM_CFLAGS) \
+               $(AM_LDFLAGS) $(CFLAGS) -shared -fpic lttng-ust-getcpu-override-example.o
 
 .PHONY: clean
 clean:
This page took 0.025754 seconds and 4 git commands to generate.