From 20fd073e1da32c9f8511824f0080c4dcc07a1f52 Mon Sep 17 00:00:00 2001 From: compudj Date: Wed, 13 Feb 2008 15:56:04 +0000 Subject: [PATCH] fix lib git-svn-id: http://ltt.polymtl.ca/svn@2814 04897980-b3bd-0310-b5e0-8ef037075253 --- markers-userspace/Makefile | 9 ++++++--- markers-userspace/elf_i386.xmark | 4 ++-- markers-userspace/marker-lib.c | 16 ++++++++++++---- markers-userspace/testprog.c | 3 +++ 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/markers-userspace/Makefile b/markers-userspace/Makefile index e770d737..9c5135d0 100644 --- a/markers-userspace/Makefile +++ b/markers-userspace/Makefile @@ -1,18 +1,21 @@ CC=gcc -all: testprog testprog.S +all: libtestlib.so testprog testprog.S marker-lib.o: marker-lib.c marker.h $(CC) -O2 -DCONFIG_MARKERS -c -o $@ marker-lib.c testprog: testprog.c marker.h marker-lib.o - $(CC) -Wl,-Telf_i386.xmark -O2 -DCONFIG_MARKERS -o $@ testprog.c marker-lib.o + $(CC) -Wl,-Telf_i386.xmark -O2 -DCONFIG_MARKERS -L. -ltestlib -o $@ testprog.c marker-lib.o testprog.S: testprog.c marker.h $(CC) -O2 -DCONFIG_MARKERS -S -o $@ testprog.c +libtestlib.so: testlib.c marker.h marker-lib.o + $(CC) -Wl,-Telf_i386.xmark -O2 -DCONFIG_MARKERS -shared -o $@ testlib.c marker-lib.o + .PHONY: clean clean: - rm -f testprog testprog.S marker-lib.o + rm -f testprog testprog.S marker-lib.o libtestlib.so diff --git a/markers-userspace/elf_i386.xmark b/markers-userspace/elf_i386.xmark index 9ea3ead8..c3ca3d97 100644 --- a/markers-userspace/elf_i386.xmark +++ b/markers-userspace/elf_i386.xmark @@ -135,9 +135,9 @@ SECTIONS { *(.data .data.* .gnu.linkonce.d.*) . = ALIGN(8); - PROVIDE_HIDDEN (__start___markers = .); + PROVIDE (__start___markers = .); *(__markers) - PROVIDE_HIDDEN (__stop___markers = .); + PROVIDE (__stop___markers = .); KEEP (*(.gnu.linkonce.d.*personality*)) SORT(CONSTRUCTORS) } diff --git a/markers-userspace/marker-lib.c b/markers-userspace/marker-lib.c index e5ae4fb8..2c42d4c8 100644 --- a/markers-userspace/marker-lib.c +++ b/markers-userspace/marker-lib.c @@ -3,8 +3,8 @@ #include #include -extern struct marker __start___markers[]; -extern struct marker __stop___markers[]; +__attribute__ ((visibility ("protected"))) extern struct marker __start___markers[]; +__attribute__ ((visibility ("protected"))) extern struct marker __stop___markers[]; /** * __mark_empty_function - Empty probe callback @@ -18,6 +18,7 @@ extern struct marker __stop___markers[]; * though the function pointer change and the marker enabling are two distinct * operations that modifies the execution flow of preemptible code. */ +__attribute__ ((visibility ("protected"))) void __mark_empty_function(void *probe_private, void *call_private, const char *fmt, va_list *args) { @@ -31,6 +32,7 @@ void __mark_empty_function(void *probe_private, void *call_private, * @...: Variable argument list. * */ +__attribute__ ((visibility ("protected"))) void marker_probe_cb(const struct marker *mdata, void *call_private, const char *fmt, ...) { @@ -41,14 +43,20 @@ void marker_probe_cb(const struct marker *mdata, void *call_private, //FIXME : imv_read won't work with optimized immediate values. //will need to issue one sys_marker call for each immediate value. +__attribute__ ((visibility ("protected"))) +void testip(void) +{ + printf("addr : %p\n", __builtin_return_address(0)); +} -__attribute__((constructor)) void marker_init(void) +__attribute__((constructor, visibility ("protected"))) void marker_init(void) { struct marker *iter; int ret; printf("Marker section : from %p to %p (init)\n", __start___markers, __stop___markers); + testip(); for (iter = __start___markers; iter < __stop___markers; iter++) { printf("Marker : %s\n", iter->name); ret = sys_marker(iter->name, iter->format, @@ -58,7 +66,7 @@ __attribute__((constructor)) void marker_init(void) } } -__attribute__((destructor)) void marker_fini(void) +static __attribute__((destructor, visibility ("protected"))) void marker_fini(void) { struct marker *iter; int ret; diff --git a/markers-userspace/testprog.c b/markers-userspace/testprog.c index 5f25e830..5c3010a8 100644 --- a/markers-userspace/testprog.c +++ b/markers-userspace/testprog.c @@ -2,6 +2,8 @@ #include #include "marker.h" +extern void testfct(void); + int main(int argc, char **argv) { void *ptr; @@ -9,6 +11,7 @@ int main(int argc, char **argv) while (1) { trace_mark(test_marker, "ptr %p val %lu", ptr, val); + testfct(); sleep(2); } return 0; -- 2.34.1