summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2020-03-24 23:21:25 -0700
committerMatt Turner <mattst88@gmail.com>2020-03-24 23:21:25 -0700
commitd4c6267e4f8b28df6c98e1c6c5cb90021ce3665d (patch)
tree7fe85ff26f1d9f713c726d1f9ce208ddaed85669
parent5380624471e4ac22edd397cd91289844650ef5e5 (diff)
Always build with -fPIC
The dladdr(3) explains that dladdr often doesn't do what you expect because the function pointer will point to the PLT entry in the original object and not the actual function itself.
-rw-r--r--Makefile3
1 files changed, 2 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 22ee038..c551882 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,7 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
+CFLAGS += -fPIC
LDLIBS = -ldl
LDFLAGS = -Wl,--build-id=sha1
GREP_SHA1 = egrep -o '\b[0-9a-f]{40}\b'
@@ -35,7 +36,7 @@ dlopen-build-id: dlopen-test.o
$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS)
shared-build-id.o: build-id.c
- $(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -c $^ -o $@
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c $^ -o $@
libbuild-id.so: shared-build-id.o
$(CC) $(LDFLAGS) -shared $^ -o $@ $(LDLIBS)