Bladeren bron

Joakim Tjernlund writes:

This patch makes -fpic work for PCC and optimzes the relcation by moving the cache
flushing stuff to JMP relocs only. Actually PPCs ldso can only handle small
GOT tables(<=8192 entries)anyhow, so it makes little sense to compile PPC with -fPIC.
libuClibc shrunk from 340724 to 330780 bytes with -fpic.
Eric Andersen 21 jaren geleden
bovenliggende
commit
4efa075cf3
2 gewijzigde bestanden met toevoegingen van 13 en 5 verwijderingen
  1. 9 1
      Rules.mak
  2. 4 4
      ldso/ldso/powerpc/dl-startup.h

+ 9 - 1
Rules.mak

@@ -88,7 +88,15 @@ export RUNTIME_PREFIX DEVEL_PREFIX
 ARFLAGS:=r
 
 OPTIMIZATION:=
-PICFLAG:=-fPIC
+
+# PowerPC can hold 8192 entries in its GOT with -fpic which is more than enough. Therefore use
+# -fpic which will reduce code size and generates faster code.
+ifeq ($(strip $(TARGET_ARCH)),powerpc)
+	PICFLAG:=-fpic
+else
+	PICFLAG:=-fPIC
+endif
+
 # Some nice CPU specific optimizations
 ifeq ($(strip $(TARGET_ARCH)),i386)
 	OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,)

+ 4 - 4
ldso/ldso/powerpc/dl-startup.h

@@ -38,15 +38,15 @@ asm("" \
 	 Elf32_Addr finaladdr=(SYMBOL)+(RELP)->r_addend;\
 	if (type==R_PPC_RELATIVE) {			\
 		*REL=(Elf32_Word)(LOAD)+(RELP)->r_addend;\
+	} else if (type==R_PPC_ADDR32 || type==R_PPC_GLOB_DAT) {\
+		*REL=finaladdr;				\
 	} else if (type==R_PPC_JMP_SLOT) {		\
 		Elf32_Sword delta=finaladdr-(Elf32_Word)(REL);\
 		*REL=OPCODE_B(delta);			\
-	} else if (type==R_PPC_ADDR32) {		\
-		*REL=finaladdr;				\
+		PPC_DCBST(REL); PPC_SYNC; PPC_ICBI(REL);\
 	} else {					\
-	  _dl_exit(100+ELF32_R_TYPE((RELP)->r_info));	\
+		_dl_exit(100+ELF32_R_TYPE((RELP)->r_info));\
 	}						\
-	PPC_DCBST(REL); PPC_SYNC; PPC_ICBI(REL);	\
 	}
 /*
  * Transfer control to the user's application, once the dynamic loader