Skip to contentSkip to conversation

Fix: build example SO when PIE is enabled

PATCH Mathieu Desnoyers 1 participant 1 message Feb 20, 2018 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Mathieu Desnoyers

author Applied
#1 lore raw

Merged into lttng-ust master, thanks!

Mathieu

Quoted 73 lines · ----- On Oct 25, 2017, at 2:28 PM, Michael Jeanson [email protected] wrote:

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.

---

doc/examples/clock-override/Makefile  | 4 ++--
doc/examples/demo/Makefile            | 8 ++++----
doc/examples/getcpu-override/Makefile | 4 ++--
3 files changed, 8 insertions(+), 8 deletions(-)
doc/examples/clock-override/Makefile +0 -0
index 5433427..22e5dff 100644
@@ -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

doc/examples/clock-override/Makefile +2 -2
-	$(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:

doc/examples/demo/Makefile +0 -0
index 6272a2b..bb7fc17 100644
@@ -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

doc/examples/demo/Makefile +2 -2
-	$(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

doc/examples/demo/Makefile +2 -2
-	$(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) \
doc/examples/getcpu-override/Makefile +0 -0
index de295c6..e1e4892 100644
@@ -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

doc/examples/getcpu-override/Makefile +2 -2
-	$(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:
--
2.7.4

Signature · 7 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev