Add linker script and libust initializer object
authorJan Blunck <jblunck@suse.de>
Thu, 5 Nov 2009 17:13:18 +0000 (18:13 +0100)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Wed, 11 Nov 2009 21:47:59 +0000 (16:47 -0500)
This adds a libust initializer object which gets linked automagically if
you link against libust.so, which is a linker skript from now on. The
object file just ensures that the libust is initialized properly without
forcing the user of the library to care about calling MARKER_LIB and
TRACEPOINT_LIB explicitly.

Signed-off-by: Jan Blunck <jblunck@suse.de>
Makefile.am
libust-initializer.c [new file with mode: 0644]
libust.ldscript.in [new file with mode: 0644]

index 1bdedea2118f695c470d052f51b8d7bccfc76532..f881570042b5b16d1844c32902c64f8b14b35c45 100644 (file)
@@ -1,5 +1,17 @@
 ACLOCAL_AMFLAGS = -I m4
 SUBDIRS = libust tests libmallocwrap ustd ustctl libinterfork include
 
 ACLOCAL_AMFLAGS = -I m4
 SUBDIRS = libust tests libmallocwrap ustd ustctl libinterfork include
 
-EXTRA_DIST = doc
+EXTRA_DIST = doc libust.ldscript.in libust-initializer.c
 dist_bin_SCRIPTS = usttrace
 dist_bin_SCRIPTS = usttrace
+
+ldscriptsdir = $(libdir)
+ldscripts_DATA = libust.so libust-initializer.o
+
+CLEANFILES = $(ldscripts_DATA)
+
+libust_FORMAT := $(shell case $(shell uname -m) in (i*86) echo elf32-i386 ;; (x86_64) echo elf64-x86-64 ;; (ppc) echo elf32-powerpc ;; (ppc64) echo elf64-powerpc ;; (s390) echo elf32-s390 ;; (s390x) echo elf64-s390 ;; esac)
+libust.so: libust.ldscript.in
+       $(SED) -e "s@\@FORMAT\@@${libust_FORMAT}@" -e "s@\@PATH\@@${libdir}@g" < $< > $@
+
+libust-initializer.o: libust-initializer.c
+       $(CC) -c $(CFLAGS) -o $@ $<
diff --git a/libust-initializer.c b/libust-initializer.c
new file mode 100644 (file)
index 0000000..7c47465
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2009 Novell Inc.
+ *
+ * Author: Jan Blunck <jblunck@suse.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free  Software Foundation.
+ */
+
+#include <ust/marker.h>
+#include <ust/tracepoint.h>
+
+MARKER_LIB;
+TRACEPOINT_LIB;
diff --git a/libust.ldscript.in b/libust.ldscript.in
new file mode 100644 (file)
index 0000000..3babac6
--- /dev/null
@@ -0,0 +1,4 @@
+/* GNU ld script
+   Use the shared library, but the link with initializer too */
+OUTPUT_FORMAT(@FORMAT@)
+GROUP ( @PATH@/libust.so.0 @PATH@/libust-initializer.o )
This page took 0.02569 seconds and 4 git commands to generate.