Eliminate .so PLT entries for local symbols. (thanks to Arjan van de Ven)
authorKeith Packard <keithp@neko.keithp.com>
Tue, 5 Sep 2006 09:24:01 +0000 (02:24 -0700)
committerKeith Packard <keithp@neko.keithp.com>
Tue, 5 Sep 2006 09:24:01 +0000 (02:24 -0700)
Using a simple shell script that processes the public headers, two header
files are constructed that map public symbols to hidden internal aliases
avoiding the assocated PLT entry for referring to a public symbol.

A few mistakes in the FcPrivate/FcPublic annotations were also discovered
through this process

31 files changed:
.gitignore
fc-arch/Makefile.am
fc-case/Makefile.am
fc-glyphname/Makefile.am
fc-lang/Makefile.am
fc-lang/fc-lang.c
fontconfig/fontconfig.h
src/Makefile.am
src/fcatomic.c
src/fcblanks.c
src/fccache.c
src/fccfg.c
src/fccharset.c
src/fcdbg.c
src/fcdefault.c
src/fcdir.c
src/fcfreetype.c
src/fcfs.c
src/fcinit.c
src/fcint.h
src/fclang.c
src/fclist.c
src/fcmatch.c
src/fcmatrix.c
src/fcname.c
src/fcpat.c
src/fcserialize.c
src/fcstr.c
src/fcxml.c
src/ftglue.c
src/makealias [new file with mode: 0755]

index 255a1f9..66a71cf 100644 (file)
@@ -1,3 +1,5 @@
+fcalias.h
+fcaliastail.h
 tags
 *.tar.gz
 .libs
index 8db30bb..819e37a 100644 (file)
@@ -47,4 +47,11 @@ $(TARG):fc-arch${EXEEXT} $(STMPL) ${top_srcdir}/src/fcint.h ../config.h
        rm -f $(TARG)
        ./fc-arch${EXEEXT} $(ARCHITECTURE) < $(STMPL) > $(TARG)
 
-CLEANFILES=$(TARG)
+ALIAS_FILES = fcalias.h fcaliastail.h
+
+BUILT_SOURCES = $(ALIAS_FILES)
+
+$(ALIAS_FILES): 
+       touch $(ALIAS_FILES)
+
+CLEANFILES=$(TARG) $(ALIAS_FILES)
index 11da16e..e498da0 100644 (file)
@@ -52,5 +52,12 @@ $(TARG): $(STMPL) fc-case$(EXEEXT) $(SCASEFOLDING)
        rm -f $(TARG)
        ./fc-case$(EXEEXT) $(SCASEFOLDING) < $(STMPL) > $(TARG)
 
-CLEANFILES=$(TARG)
+ALIAS_FILES = fcalias.h fcaliastail.h
+
+BUILT_SOURCES = $(ALIAS_FILES)
+
+$(ALIAS_FILES): 
+       touch $(ALIAS_FILES)
+
+CLEANFILES=$(TARG) $(ALIAS_FILES)
 
index eb21101..063ba00 100644 (file)
@@ -47,5 +47,12 @@ $(TARG): $(STMPL) fc-glyphname$(EXEEXT) $(SGLYPHNAME)
        rm -f $(TARG)
        ./fc-glyphname$(EXEEXT) $(SGLYPHNAME) < $(STMPL) > $(TARG)
 
-CLEANFILES=$(TARG)
+ALIAS_FILES = fcalias.h fcaliastail.h
+
+BUILT_SOURCES = $(ALIAS_FILES)
+
+$(ALIAS_FILES): 
+       touch $(ALIAS_FILES)
+
+CLEANFILES=$(TARG) $(ALIAS_FILES)
 
index 5077810..8ca9399 100644 (file)
@@ -46,4 +46,11 @@ $(TARG):$(ORTH) fc-lang${EXEEXT} $(STMPL)
        rm -f $(TARG)
        ./fc-lang${EXEEXT} -d ${srcdir} $(ORTH) < $(STMPL) > $(TARG)
 
-CLEANFILES=$(TARG)
+ALIAS_FILES = fcalias.h fcaliastail.h
+
+BUILT_SOURCES = $(ALIAS_FILES)
+
+$(ALIAS_FILES): 
+       touch $(ALIAS_FILES)
+
+CLEANFILES = $(TARG) $(ALIAS_FILES)
index 199f16f..92a62ce 100644 (file)
@@ -22,7 +22,6 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include "fcint.h"
 #include "fccharset.c"
 #include "fcstr.c"
 #include "fcserialize.c"
index 92a6d08..523d471 100644 (file)
@@ -355,10 +355,10 @@ FcConfigGetConfigDirs (FcConfig   *config);
 FcPublic FcStrList *
 FcConfigGetConfigFiles (FcConfig    *config);
 
-FcChar8 *
+FcPublic FcChar8 *
 FcConfigGetCache (FcConfig  *config);
 
-FcBlanks *
+FcPublic FcBlanks *
 FcConfigGetBlanks (FcConfig *config);
 
 FcPublic FcStrList *
@@ -899,13 +899,13 @@ FcPublic void
 FcStrSetDestroy (FcPublic FcStrSet *set);
 
 FcPublic FcStrList *
-FcPublic FcStrListCreate (FcPublic FcStrSet *set);
+FcStrListCreate (FcPublic FcStrSet *set);
 
 FcPublic FcChar8 *
-FcPublic FcStrListNext (FcStrList *list);
+FcStrListNext (FcStrList *list);
 
 FcPublic void
-FcPublic FcStrListDone (FcStrList *list);
+FcStrListDone (FcStrList *list);
 
 /* fcxml.c */
 FcPublic FcBool
index 586594c..98e353d 100644 (file)
@@ -73,10 +73,14 @@ INCLUDES =                                          \
        -DFC_CACHEDIR='"$(FC_CACHEDIR)"'                \
        -DFONTCONFIG_PATH='"$(CONFDIR)"'
 
-EXTRA_DIST = fontconfig.def.in
+EXTRA_DIST = fontconfig.def.in makealias
 
 noinst_HEADERS=fcint.h
 
+ALIAS_FILES = fcalias.h fcaliastail.h
+
+BUILT_SOURCES = $(ALIAS_FILES)
+
 libfontconfig_la_SOURCES = \
        fcatomic.c \
        fcblanks.c \
@@ -112,3 +116,12 @@ install-data-local: install-ms-import-lib install-libtool-import-lib
 
 uninstall-local: uninstall-ms-import-lib uninstall-libtool-import-lib
 
+PUBLIC_FILES = \
+       $(top_srcdir)/fontconfig/fontconfig.h \
+       $(top_srcdir)/fontconfig/fcfreetype.h \
+       $(top_srcdir)/fontconfig/fcprivate.h
+       
+$(ALIAS_FILES): $(top_srcdir)/src/makealias $(PUBLIC_FILES)
+       sh $(top_srcdir)/src/makealias "$(top_srcdir)/src" $(PUBLIC_FILES)
+
+CLEANFILES := $(ALIAS_FILES)
index a8b30f8..9038a5f 100644 (file)
@@ -211,3 +211,6 @@ FcAtomicDestroy (FcAtomic *atomic)
 
     free (atomic);
 }
+#define __fcatomic__
+#include "fcaliastail.h"
+#undef __fcatomic__
index a78e85f..d52cca7 100644 (file)
@@ -90,3 +90,6 @@ FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4)
            return FcTrue;
     return FcFalse;
 }
+#define __fcblanks__
+#include "fcaliastail.h"
+#undef __fcblanks__
index 32c36bd..e4b04fc 100644 (file)
@@ -1085,3 +1085,6 @@ static void MD5Transform(FcChar32 buf[4], FcChar32 in[16])
     buf[2] += c;
     buf[3] += d;
 }
+#define __fccache__
+#include "fcaliastail.h"
+#undef __fccache__
index d9502f0..01d381c 100644 (file)
@@ -1964,3 +1964,6 @@ FcConfigAcceptFont (FcConfig          *config,
        return FcFalse;
     return FcTrue;
 }
+#define __fccfg__
+#include "fcaliastail.h"
+#undef __fccfg__
index 76c1530..1c2e2ea 100644 (file)
@@ -1358,3 +1358,6 @@ FcCharSetSerialize(FcSerialize *serialize, const FcCharSet *cs)
     
     return cs_serialized;
 }
+#define __fccharset__
+#include "fcaliastail.h"
+#undef __fccharset__
index 98b57e6..68f530e 100644 (file)
@@ -412,3 +412,6 @@ FcInitDebug (void)
            FcDebugVal = 0;
     }
 }
+#define __fcdbg__
+#include "fcaliastail.h"
+#undef __fcdbg__
index b69de30..ddf4237 100644 (file)
@@ -166,3 +166,6 @@ FcDefaultSubstitute (FcPattern *pattern)
        FcPatternObjectAddInteger (pattern, FC_HINT_STYLE_OBJECT, FC_HINT_FULL);
     }
 }
+#define __fcdefault__
+#include "fcaliastail.h"
+#undef __fcdefault__
index a55c5fd..bb5cfc9 100644 (file)
@@ -292,3 +292,6 @@ FcDirSave (FcFontSet *set, FcStrSet * dirs, const FcChar8 *dir)
 {
     return FcFalse; /* XXX deprecated */
 }
+#define __fcdir__
+#include "fcaliastail.h"
+#undef __fcdir__
index 3cf1686..96f70c3 100644 (file)
@@ -2952,3 +2952,7 @@ bail:
     ftglue_free(memory, gpostags);
     return complex;
 }
+
+#define __fcfreetype__
+#include "fcaliastail.h"
+#undef __fcfreetype__
index e9b2d07..7bea736 100644 (file)
@@ -130,3 +130,6 @@ FcFontSetSerialize (FcSerialize *serialize, const FcFontSet * s)
 
     return s_serialize;
 }
+#define __fcfs__
+#include "fcaliastail.h"
+#undef __fcfs__
index f64c0f0..7d2311f 100644 (file)
@@ -263,3 +263,6 @@ FcMemFree (int kind, int size)
            FcMemReport ();
     }
 }
+#define __fcinit__
+#include "fcaliastail.h"
+#undef __fcinit__
index 7dab169..c50f623 100644 (file)
@@ -48,6 +48,7 @@
 #include <fontconfig/fontconfig.h>
 #include <fontconfig/fcprivate.h>
 #include <fontconfig/fcfreetype.h>
+#include "fcalias.h"
 
 #ifndef FC_CONFIG_PATH
 #define FC_CONFIG_PATH "fonts.conf"
@@ -322,6 +323,8 @@ struct _FcCache {
     intptr_t   set;                /* offset to font set */
 };
 
+#undef FcCacheDir
+#undef FcCacheSubdir
 #define FcCacheDir(c)  FcOffsetMember(c,dir,FcChar8)
 #define FcCacheDirs(c) FcOffsetMember(c,dirs,intptr_t)
 #define FcCacheSet(c)  FcOffsetMember(c,set,FcFontSet)
@@ -513,7 +516,7 @@ FcCacheObjectDereference (void *object);
 FcPrivate void
 FcCacheFini (void);
     
-void
+FcPrivate void
 FcDirCacheReference (FcCache *cache, int nref);
 
 /* fccfg.c */
index f8f6f0b..de08622 100644 (file)
@@ -727,3 +727,6 @@ FcLangSetSerialize(FcSerialize *serialize, const FcLangSet *l)
     *l_serialize = *l;
     return l_serialize;
 }
+#define __fclang__
+#include "fcaliastail.h"
+#undef __fclang__
index c0b7fb0..3de04a0 100644 (file)
@@ -556,3 +556,6 @@ FcFontList (FcConfig        *config,
        sets[nsets++] = config->fonts[FcSetApplication];
     return FcFontSetList (config, sets, nsets, p, os);
 }
+#define __fclist__
+#include "fcaliastail.h"
+#undef __fclist__
index 96587cb..f041052 100644 (file)
@@ -835,3 +835,6 @@ FcFontSort (FcConfig        *config,
        sets[nsets++] = config->fonts[FcSetApplication];
     return FcFontSetSort (config, sets, nsets, p, trim, csp, result);
 }
+#define __fcmatch__
+#include "fcaliastail.h"
+#undef __fcmatch__
index 3c4d9fb..7f55146 100644 (file)
@@ -115,3 +115,6 @@ FcMatrixShear (FcMatrix *m, double sh, double sv)
     r.yy = 1;
     FcMatrixMultiply (m, &r, m);
 }
+#define __fcmatrix__
+#include "fcaliastail.h"
+#undef __fcmatrix__
index cfc6b31..21e6da1 100644 (file)
@@ -879,3 +879,6 @@ bail0:
     FcStrBufDestroy (&buf);
     return 0;
 }
+#define __fcname__
+#include "fcaliastail.h"
+#undef __fcname__
index a225717..bf34c2e 100644 (file)
@@ -1208,3 +1208,6 @@ FcValueListSerialize (FcSerialize *serialize, const FcValueList *vl)
     }
     return head_serialized;
 }
+#define __fcpat__
+#include "fcaliastail.h"
+#undef __fcpat__
index d0d35e3..a66d388 100644 (file)
@@ -159,3 +159,6 @@ FcStrSerialize (FcSerialize *serialize, const FcChar8 *str)
     strcpy ((char *) str_serialize, (const char *) str);
     return str_serialize;
 }
+#define __fcserialize__
+#include "fcaliastail.h"
+#undef __fcserialize__
index 5faf579..7ec2ab4 100644 (file)
@@ -1051,3 +1051,6 @@ FcStrListDone (FcStrList *list)
     free (list);
 }
 
+#define __fcstr__
+#include "fcaliastail.h"
+#undef __fcstr__
index 441e6de..4087183 100644 (file)
@@ -2493,3 +2493,6 @@ bail0:
     }
     return FcTrue;
 }
+#define __fcxml__
+#include "fcaliastail.h"
+#undef __fcxml__
index 413a933..9caad7c 100644 (file)
@@ -307,3 +307,6 @@ Exit:
 }                        
 
 #undef QALLOC
+#define __ftglue__
+#include "fcaliastail.h"
+#undef __ftglue__
diff --git a/src/makealias b/src/makealias
new file mode 100755 (executable)
index 0000000..db76a45
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+SRCDIR=$1
+shift
+HEAD=fcalias.h
+TAIL=fcaliastail.h
+rm -f $HEAD $TAIL
+sed -n -e '/^FcPublic /,+1p' "$@" | sed -e '/^FcPublic /d' -e 's/ *(.*$//' |
+while read name; do
+       case $name in
+       FcCacheDir|FcCacheSubdir)
+               ;;
+       *)
+               alias="IA__$name"
+               hattr='__attribute((visibility("hidden")))'
+               echo "extern __typeof ($name) $alias $hattr;" >> $HEAD
+               echo "#define $name $alias" >> $HEAD
+               grep -l -w '^'$name "$SRCDIR"/*.c | sed -e 's/^.*\/\([^.]*\)\.c/#ifdef __\1__/' >> $TAIL
+               echo "#undef $name" >> $TAIL
+               cattr='__attribute((alias("'$alias'"), visibility("default")))'
+               echo "extern __typeof ($name) $name $cattr;" >> $TAIL
+               echo "#endif" >> $TAIL
+               ;;
+       esac
+done