From 2694aa91c4849c393dd6d17bba260a86f696fc47 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Wed, 8 Jan 2014 05:07:37 +0100 Subject: [PATCH] add size optimization options --- Makefile | 3 ++- stress.c | 2 +- wrap.c | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index c0d1a68..a78a1ff 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ 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 @@ -8,7 +9,7 @@ wrap.o: head.h func.h 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 diff --git a/stress.c b/stress.c index 435d009..7170ed9 100644 --- a/stress.c +++ b/stress.c @@ -5,7 +5,7 @@ int main() int i, j; char * volatile p = ""; char * volatile q = ""; - for (i=0; i<10000; i++) + for (i=0; i<100000; i++) j += strcmp(p,q); return j; } diff --git a/wrap.c b/wrap.c index a4144db..a24b4a2 100644 --- a/wrap.c +++ b/wrap.c @@ -5,10 +5,13 @@ // 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; \ } @@ -16,7 +19,7 @@ #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; \ } -- 2.20.1