Only use -fPIC when compiling the shared object.
authornorly <ny-git@enpas.org>
Wed, 26 Jun 2013 23:46:07 +0000 (00:46 +0100)
committernorly <ny-git@enpas.org>
Wed, 26 Jun 2013 23:46:07 +0000 (00:46 +0100)
We can only use position-dependent global variables (R_*_COPY) in
injected code, not the position-independent R_*_GLOB_DAT as used in
shared objects.
And being able to modify the tool itself turns out to be a cool thing to
be able to.

Makefile

index a3594f70f1afcf3c22add4d8668585faae0222ff..c027c3645a06e5b42a335297fd8f29d4524130b5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -35,7 +35,7 @@ endif
 
 
 INCLUDES := $(patsubst %, -I%, $(INCLUDEDIR) $(SRCDIR)) $(LIBELF_INCLUDES)
-CFLAGS   := -g -Wall -std=gnu99 -pedantic -fPIC $(LIBELF_CFLAGS)
+CFLAGS   := -g -Wall -std=gnu99 -pedantic $(LIBELF_CFLAGS)
 LDFLAGS  := $(LIBELF_LDFLAGS)
 
 
@@ -58,8 +58,8 @@ debug: $(EXE)
 $(EXE): $(EXEOBJS) $(STATICLIB)
        gcc -o $@ $^ $(LDFLAGS)
 
-$(SHAREDLIB): $(LIBOBJS)
-       gcc -shared -Wl,-soname,lib$(LIBNAME).so.$(SHARED_VERMAJ) -o $@ $^ $(LDFLAGS)
+$(SHAREDLIB): $(LIBSRCS)
+       gcc $(INCLUDES) $(CFLAGS) -shared -fPIC -Wl,-soname,lib$(LIBNAME).so.$(SHARED_VERMAJ) -o $@ $^ $(LDFLAGS)
 
 $(STATICLIB): $(LIBOBJS)
        ar rcs $@ $^