Blob Blame Raw
From f9e56db59fde6e6eccd4c51c5c158ce4eed3b922 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Wed, 26 Nov 2014 13:00:18 +0100
Subject: [PATCH] Build rpc.rquotad as PIE
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 Makefile.in | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 7d25930..25f1203 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -48,6 +48,9 @@ LIBOBJS += @LIBMALLOC@
  
 all: $(PROGS)
 
+svc_socket.o rquota_server.o rquota_svc.o $(filter-out rquota_xdr.o,$(LIBOBJS)): %.o: %.c
+	$(CC) $(CFLAGS) -fpie -c $<
+
 clean:
 	-rm -f core *.o .*.d
 
@@ -141,7 +144,8 @@ convertquota: convertquota.o $(LIBOBJS)
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
 
 rpc.rquotad: rquota_server.o rquota_svc.o svc_socket.o $(LIBOBJS)
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
+	$(CC) $(CFLAGS) -pie $(LDFLAGS) -o $@ $^ $(LIBS)
+	@if readelf -d $@|fgrep -q TEXTREL; then echo "*** Text relocation"; false; else true; fi
 
 ifneq ($(NETLINKLIBS),)
 quota_nld: quota_nld.o $(LIBOBJS)
@@ -157,7 +161,7 @@ rquota_xdr.c: rquota.x
 	$(RPCGEN) -c -o $@ $<
 
 rquota_xdr.o: rquota_xdr.c rquota.h
-	$(CC) $(CFLAGS) -Wno-unused -c $<
+	$(CC) $(CFLAGS) -Wno-unused -fpie -c $<
 
 rquota_clnt.c: rquota.x
 	$(RPCGEN) -l -o $@ $<
-- 
1.9.3