Browse Source

Add PIE support to ARM. From Peter Mazinger

Joakim Tjernlund 19 years ago
parent
commit
5c48e4b530
2 changed files with 14 additions and 6 deletions
  1. 2 2
      extra/Configs/Config.in
  2. 12 4
      libc/sysdeps/linux/arm/Makefile

+ 2 - 2
extra/Configs/Config.in

@@ -1110,12 +1110,12 @@ config UCLIBC_BUILD_PIE
 	bool "Build utilities as ET_DYN/PIE executables"
 	depends on UCLIBC_SECURITY
 	depends on HAVE_SHARED
-	depends on TARGET_i386 || TARGET_powerpc || TARGET_mips || TARGET_frv
+	depends on TARGET_arm || TARGET_frv || TARGET_i386 || TARGET_mips || TARGET_powerpc
 	select FORCE_SHAREABLE_TEXT_SEGMENTS if BUILD_UCLIBC_LDSO
 	default y
 	help
 	  If you answer Y here, ldd and iconv are built as ET_DYN/PIE executables.
-	  It requires gcc-3.4 and binutils-2.15 or later.
+	  It requires gcc-3.4 and binutils-2.15 (for arm 2.16) or later.
 	  More about ET_DYN/PIE binaries on <http://pax.grsecurity.net/> .
 	  WARNING: This option also enables FORCE_SHAREABLE_TEXT_SEGMENTS, so all
 		libraries have to be built with -fPIC or -fpic, and all assembler

+ 12 - 4
libc/sysdeps/linux/arm/Makefile

@@ -21,7 +21,7 @@ include $(TOPDIR)Rules.mak
 
 CRT0_SRC = crt0.S
 CRT0_OBJ = crt0.o crt1.o
-CRT0_DEPS=gmon-start.S
+SCRT0_OBJ = $(patsubst %,S%, $(CRT0_OBJ))
 CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o
 
 SSRC=__longjmp.S vfork.S clone.S setjmp.S bsd-setjmp.S \
@@ -37,15 +37,24 @@ OBJ_LIST=../../../obj.sysdeps.$(TARGET_ARCH)
 
 all: $(OBJ_LIST)
 
-$(OBJ_LIST): $(OBJS) $(CRT0_OBJ) $(CTOR_TARGETS)
+$(OBJ_LIST): $(OBJS) $(CRT0_OBJ) $(SCRT0_OBJ) $(CTOR_TARGETS)
 	echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $(OBJ_LIST)
 	$(INSTALL) -d $(TOPDIR)lib/
-	cp $(CRT0_OBJ) $(TOPDIR)lib/
+	cp $(CRT0_OBJ) $(SCRT0_OBJ) $(TOPDIR)lib/
+ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
+	$(RM) $(TOPDIR)lib/Scrt0.o
+else
+	mv $(TOPDIR)lib/Scrt0.o $(TOPDIR)lib/Scrt1.o
+endif
 
 $(CRT0_OBJ): $(CRT0_SRC)
 	$(CC) $(ASFLAGS) -DL_$* $< -c -o $*.o
 	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
+$(SCRT0_OBJ): $(CRT0_SRC)
+	$(CC) $(ASFLAGS) $(PIEFLAG) -DL_$* $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
+
 $(SOBJS): %.o : %.S
 	$(CC) $(ASFLAGS) -c $< -o $@
 	$(STRIPTOOL) -x -R .note -R .comment $*.o
@@ -83,4 +92,3 @@ headers:
 clean:
 	$(RM) *.[oa] *~ core
 	$(RM) bits/sysnum.h
-	$(RM) gmon-start.S