CFLAGS=-std=c99 -Os -g
+#CFLAGS+=-fomit-frame-pointer -fno-unwind-tables -fno-asynchronous-unwind-tables
LDFLAGS=-g
CC=musl-gcc
all: wrap.so hello stress
wrap.so: wrap.o
$(CC) $(LDFLAGS) -shared -o $@ $< -ldl -lm -lrt -lcrypt
clean:
- rm -f wrap.so hello *.o
+ rm -f wrap.so hello stress *.o
test: all
LD_PRELOAD=./wrap.so ./hello
LD_PRELOAD=./wrap.so ./stress 2>&1 |wc -l
// dprintf and dlsym are not wrapped
+//static void print(const char *s) { dprintf(2, "%s\n", s); }
+#define print(s) dprintf(2, s"\n")
+
#define F(ret,name,args,args2) ret (name)args \
{ \
static ret (*p__)args; \
- dprintf(2, #name "\n"); \
+ print(#name); \
if (!p__) p__ = dlsym(RTLD_NEXT, #name); \
return p__ args2; \
}
#define V(v,name,args,args2) v (name)args \
{ \
static v (*p__)args; \
- dprintf(2, #name "\n"); \
+ print(#name); \
if (!p__) p__ = dlsym(RTLD_NEXT, #name); \
p__ args2; \
}