From 23816bf9acbd6cc5dd942daaba3cc084ea70d99d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 5 Sep 2006 02:24:01 -0700 Subject: [PATCH] Eliminate .so PLT entries for local symbols. (thanks to Arjan van de Ven) 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 --- .gitignore | 2 ++ fc-arch/Makefile.am | 9 ++++++++- fc-case/Makefile.am | 9 ++++++++- fc-glyphname/Makefile.am | 9 ++++++++- fc-lang/Makefile.am | 9 ++++++++- fc-lang/fc-lang.c | 1 - fontconfig/fontconfig.h | 10 +++++----- src/Makefile.am | 15 ++++++++++++++- src/fcatomic.c | 3 +++ src/fcblanks.c | 3 +++ src/fccache.c | 3 +++ src/fccfg.c | 3 +++ src/fccharset.c | 3 +++ src/fcdbg.c | 3 +++ src/fcdefault.c | 3 +++ src/fcdir.c | 3 +++ src/fcfreetype.c | 4 ++++ src/fcfs.c | 3 +++ src/fcinit.c | 3 +++ src/fcint.h | 5 ++++- src/fclang.c | 3 +++ src/fclist.c | 3 +++ src/fcmatch.c | 3 +++ src/fcmatrix.c | 3 +++ src/fcname.c | 3 +++ src/fcpat.c | 3 +++ src/fcserialize.c | 3 +++ src/fcstr.c | 3 +++ src/fcxml.c | 3 +++ src/ftglue.c | 3 +++ src/makealias | 24 ++++++++++++++++++++++++ 31 files changed, 145 insertions(+), 12 deletions(-) create mode 100755 src/makealias diff --git a/.gitignore b/.gitignore index 255a1f9..66a71cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +fcalias.h +fcaliastail.h tags *.tar.gz .libs diff --git a/fc-arch/Makefile.am b/fc-arch/Makefile.am index 8db30bb..819e37a 100644 --- a/fc-arch/Makefile.am +++ b/fc-arch/Makefile.am @@ -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) diff --git a/fc-case/Makefile.am b/fc-case/Makefile.am index 11da16e..e498da0 100644 --- a/fc-case/Makefile.am +++ b/fc-case/Makefile.am @@ -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) diff --git a/fc-glyphname/Makefile.am b/fc-glyphname/Makefile.am index eb21101..063ba00 100644 --- a/fc-glyphname/Makefile.am +++ b/fc-glyphname/Makefile.am @@ -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) diff --git a/fc-lang/Makefile.am b/fc-lang/Makefile.am index 5077810..8ca9399 100644 --- a/fc-lang/Makefile.am +++ b/fc-lang/Makefile.am @@ -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) diff --git a/fc-lang/fc-lang.c b/fc-lang/fc-lang.c index 199f16f..92a62ce 100644 --- a/fc-lang/fc-lang.c +++ b/fc-lang/fc-lang.c @@ -22,7 +22,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#include "fcint.h" #include "fccharset.c" #include "fcstr.c" #include "fcserialize.c" diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h index 92a6d08..523d471 100644 --- a/fontconfig/fontconfig.h +++ b/fontconfig/fontconfig.h @@ -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 diff --git a/src/Makefile.am b/src/Makefile.am index 586594c..98e353d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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) diff --git a/src/fcatomic.c b/src/fcatomic.c index a8b30f8..9038a5f 100644 --- a/src/fcatomic.c +++ b/src/fcatomic.c @@ -211,3 +211,6 @@ FcAtomicDestroy (FcAtomic *atomic) free (atomic); } +#define __fcatomic__ +#include "fcaliastail.h" +#undef __fcatomic__ diff --git a/src/fcblanks.c b/src/fcblanks.c index a78e85f..d52cca7 100644 --- a/src/fcblanks.c +++ b/src/fcblanks.c @@ -90,3 +90,6 @@ FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4) return FcTrue; return FcFalse; } +#define __fcblanks__ +#include "fcaliastail.h" +#undef __fcblanks__ diff --git a/src/fccache.c b/src/fccache.c index 32c36bd..e4b04fc 100644 --- a/src/fccache.c +++ b/src/fccache.c @@ -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__ diff --git a/src/fccfg.c b/src/fccfg.c index d9502f0..01d381c 100644 --- a/src/fccfg.c +++ b/src/fccfg.c @@ -1964,3 +1964,6 @@ FcConfigAcceptFont (FcConfig *config, return FcFalse; return FcTrue; } +#define __fccfg__ +#include "fcaliastail.h" +#undef __fccfg__ diff --git a/src/fccharset.c b/src/fccharset.c index 76c1530..1c2e2ea 100644 --- a/src/fccharset.c +++ b/src/fccharset.c @@ -1358,3 +1358,6 @@ FcCharSetSerialize(FcSerialize *serialize, const FcCharSet *cs) return cs_serialized; } +#define __fccharset__ +#include "fcaliastail.h" +#undef __fccharset__ diff --git a/src/fcdbg.c b/src/fcdbg.c index 98b57e6..68f530e 100644 --- a/src/fcdbg.c +++ b/src/fcdbg.c @@ -412,3 +412,6 @@ FcInitDebug (void) FcDebugVal = 0; } } +#define __fcdbg__ +#include "fcaliastail.h" +#undef __fcdbg__ diff --git a/src/fcdefault.c b/src/fcdefault.c index b69de30..ddf4237 100644 --- a/src/fcdefault.c +++ b/src/fcdefault.c @@ -166,3 +166,6 @@ FcDefaultSubstitute (FcPattern *pattern) FcPatternObjectAddInteger (pattern, FC_HINT_STYLE_OBJECT, FC_HINT_FULL); } } +#define __fcdefault__ +#include "fcaliastail.h" +#undef __fcdefault__ diff --git a/src/fcdir.c b/src/fcdir.c index a55c5fd..bb5cfc9 100644 --- a/src/fcdir.c +++ b/src/fcdir.c @@ -292,3 +292,6 @@ FcDirSave (FcFontSet *set, FcStrSet * dirs, const FcChar8 *dir) { return FcFalse; /* XXX deprecated */ } +#define __fcdir__ +#include "fcaliastail.h" +#undef __fcdir__ diff --git a/src/fcfreetype.c b/src/fcfreetype.c index 3cf1686..96f70c3 100644 --- a/src/fcfreetype.c +++ b/src/fcfreetype.c @@ -2952,3 +2952,7 @@ bail: ftglue_free(memory, gpostags); return complex; } + +#define __fcfreetype__ +#include "fcaliastail.h" +#undef __fcfreetype__ diff --git a/src/fcfs.c b/src/fcfs.c index e9b2d07..7bea736 100644 --- a/src/fcfs.c +++ b/src/fcfs.c @@ -130,3 +130,6 @@ FcFontSetSerialize (FcSerialize *serialize, const FcFontSet * s) return s_serialize; } +#define __fcfs__ +#include "fcaliastail.h" +#undef __fcfs__ diff --git a/src/fcinit.c b/src/fcinit.c index f64c0f0..7d2311f 100644 --- a/src/fcinit.c +++ b/src/fcinit.c @@ -263,3 +263,6 @@ FcMemFree (int kind, int size) FcMemReport (); } } +#define __fcinit__ +#include "fcaliastail.h" +#undef __fcinit__ diff --git a/src/fcint.h b/src/fcint.h index 7dab169..c50f623 100644 --- a/src/fcint.h +++ b/src/fcint.h @@ -48,6 +48,7 @@ #include #include #include +#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 */ diff --git a/src/fclang.c b/src/fclang.c index f8f6f0b..de08622 100644 --- a/src/fclang.c +++ b/src/fclang.c @@ -727,3 +727,6 @@ FcLangSetSerialize(FcSerialize *serialize, const FcLangSet *l) *l_serialize = *l; return l_serialize; } +#define __fclang__ +#include "fcaliastail.h" +#undef __fclang__ diff --git a/src/fclist.c b/src/fclist.c index c0b7fb0..3de04a0 100644 --- a/src/fclist.c +++ b/src/fclist.c @@ -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__ diff --git a/src/fcmatch.c b/src/fcmatch.c index 96587cb..f041052 100644 --- a/src/fcmatch.c +++ b/src/fcmatch.c @@ -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__ diff --git a/src/fcmatrix.c b/src/fcmatrix.c index 3c4d9fb..7f55146 100644 --- a/src/fcmatrix.c +++ b/src/fcmatrix.c @@ -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__ diff --git a/src/fcname.c b/src/fcname.c index cfc6b31..21e6da1 100644 --- a/src/fcname.c +++ b/src/fcname.c @@ -879,3 +879,6 @@ bail0: FcStrBufDestroy (&buf); return 0; } +#define __fcname__ +#include "fcaliastail.h" +#undef __fcname__ diff --git a/src/fcpat.c b/src/fcpat.c index a225717..bf34c2e 100644 --- a/src/fcpat.c +++ b/src/fcpat.c @@ -1208,3 +1208,6 @@ FcValueListSerialize (FcSerialize *serialize, const FcValueList *vl) } return head_serialized; } +#define __fcpat__ +#include "fcaliastail.h" +#undef __fcpat__ diff --git a/src/fcserialize.c b/src/fcserialize.c index d0d35e3..a66d388 100644 --- a/src/fcserialize.c +++ b/src/fcserialize.c @@ -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__ diff --git a/src/fcstr.c b/src/fcstr.c index 5faf579..7ec2ab4 100644 --- a/src/fcstr.c +++ b/src/fcstr.c @@ -1051,3 +1051,6 @@ FcStrListDone (FcStrList *list) free (list); } +#define __fcstr__ +#include "fcaliastail.h" +#undef __fcstr__ diff --git a/src/fcxml.c b/src/fcxml.c index 441e6de..4087183 100644 --- a/src/fcxml.c +++ b/src/fcxml.c @@ -2493,3 +2493,6 @@ bail0: } return FcTrue; } +#define __fcxml__ +#include "fcaliastail.h" +#undef __fcxml__ diff --git a/src/ftglue.c b/src/ftglue.c index 413a933..9caad7c 100644 --- a/src/ftglue.c +++ b/src/ftglue.c @@ -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 index 0000000..db76a45 --- /dev/null +++ b/src/makealias @@ -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 -- 2.39.2