[complement-svn] SF.net SVN: complement: [1531] trunk/complement/explore/inquiry/shades
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2007-02-21 13:03:19
|
Revision: 1531 http://svn.sourceforge.net/complement/?rev=1531&view=rev Author: complement Date: 2007-02-21 05:03:16 -0800 (Wed, 21 Feb 2007) Log Message: ----------- juniper investigations Added Paths: ----------- trunk/complement/explore/inquiry/shades/juniper/ trunk/complement/explore/inquiry/shades/juniper/Makefile trunk/complement/explore/inquiry/shades/juniper/Makefile.inc trunk/complement/explore/inquiry/shades/juniper/str_interposer.c Property changes on: trunk/complement/explore/inquiry/shades/juniper ___________________________________________________________________ Name: svn:ignore + obj Added: trunk/complement/explore/inquiry/shades/juniper/Makefile =================================================================== --- trunk/complement/explore/inquiry/shades/juniper/Makefile (rev 0) +++ trunk/complement/explore/inquiry/shades/juniper/Makefile 2007-02-21 13:03:16 UTC (rev 1531) @@ -0,0 +1,13 @@ +# -*- Makefile -*- Time-stamp: <04/01/09 16:53:50 ptr> +# $Id: Makefile 1356 2006-11-01 13:34:19Z complement $ + +SRCROOT := ../../.. +COMPILER_NAME := gcc + +include Makefile.inc +include ${SRCROOT}/Makefiles/top.mak + +DEFS += -D_GNU_SOURCE + +LDFLAGS += -ldl + Added: trunk/complement/explore/inquiry/shades/juniper/Makefile.inc =================================================================== --- trunk/complement/explore/inquiry/shades/juniper/Makefile.inc (rev 0) +++ trunk/complement/explore/inquiry/shades/juniper/Makefile.inc 2007-02-21 13:03:16 UTC (rev 1531) @@ -0,0 +1,7 @@ +# -*- makefile -*- Time-stamp: <04/01/12 15:37:40 ptr> + +LIBNAME = test +MAJOR = 0 +MINOR = 0 +PATCH = 0 +SRC_C = str_interposer.c Added: trunk/complement/explore/inquiry/shades/juniper/str_interposer.c =================================================================== --- trunk/complement/explore/inquiry/shades/juniper/str_interposer.c (rev 0) +++ trunk/complement/explore/inquiry/shades/juniper/str_interposer.c 2007-02-21 13:03:16 UTC (rev 1531) @@ -0,0 +1,78 @@ +/* Example from: http://developers.sun.com/solaris/articles/lib_interposers_code.html + * + */ + +/* Example of a library interposer: interpose on + * malloc(). + * Build and use this interposer as following: + * cc -o malloc_interposer.so -G -Kpic malloc_interposer.c + * setenv LD_PRELOAD $cwd/malloc_interposer.so + * run the app + * unsetenv LD_PRELOAD + */ + +#include <stdio.h> +#include <dlfcn.h> + +#if 0 +void *malloc(size_t size) +{ + static void * (*func)(); + + if(!func) + func = (void *(*)()) dlsym(RTLD_NEXT, "malloc"); + printf("malloc(%d) is called\n", size); + return(func(size)); +} +#endif + +char *strcpy( char *s1, const char *s2 ) +{ + static void * (*func)(); + + if(!func) + func = (void *(*)()) dlsym(RTLD_NEXT, "strcpy"); + + printf( "strcpy: '%s'\n", s2 ); + + return func( s1, s2 ); +} + +char *strdup(const char *s1) +{ + static void * (*func)(); + + if(!func) + func = (void *(*)()) dlsym(RTLD_NEXT, "strdup"); + + printf( "strdup: '%s'\n", s1 ); + + return func( s1 ); +} + +char *strncat(char *s1, const char *s2, size_t n) +{ + static void * (*func)(); + char *r; + + if(!func) + func = (void *(*)()) dlsym(RTLD_NEXT, "strncat"); + + r = func( s1, s2, n ); + printf( "strncat: '%s'\n", r ); + + return r; +} + +char *strtok(char *s1, const char *s2) +{ + static void * (*func)(); + + if(!func) + func = (void *(*)()) dlsym(RTLD_NEXT, "strtok"); + + printf( "strtok: '%s'\n", s1 ); + + return func( s1, s2 ); +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |