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
This commit is contained in:
Keith Packard 2006-09-05 02:24:01 -07:00
parent 323ecd0cd3
commit 23816bf9ac
31 changed files with 145 additions and 12 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
fcalias.h
fcaliastail.h
tags tags
*.tar.gz *.tar.gz
.libs .libs

View File

@ -47,4 +47,11 @@ $(TARG):fc-arch${EXEEXT} $(STMPL) ${top_srcdir}/src/fcint.h ../config.h
rm -f $(TARG) rm -f $(TARG)
./fc-arch${EXEEXT} $(ARCHITECTURE) < $(STMPL) > $(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)

View File

@ -52,5 +52,12 @@ $(TARG): $(STMPL) fc-case$(EXEEXT) $(SCASEFOLDING)
rm -f $(TARG) rm -f $(TARG)
./fc-case$(EXEEXT) $(SCASEFOLDING) < $(STMPL) > $(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)

View File

@ -47,5 +47,12 @@ $(TARG): $(STMPL) fc-glyphname$(EXEEXT) $(SGLYPHNAME)
rm -f $(TARG) rm -f $(TARG)
./fc-glyphname$(EXEEXT) $(SGLYPHNAME) < $(STMPL) > $(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)

View File

@ -46,4 +46,11 @@ $(TARG):$(ORTH) fc-lang${EXEEXT} $(STMPL)
rm -f $(TARG) rm -f $(TARG)
./fc-lang${EXEEXT} -d ${srcdir} $(ORTH) < $(STMPL) > $(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)

View File

@ -22,7 +22,6 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "fcint.h"
#include "fccharset.c" #include "fccharset.c"
#include "fcstr.c" #include "fcstr.c"
#include "fcserialize.c" #include "fcserialize.c"

View File

@ -355,10 +355,10 @@ FcConfigGetConfigDirs (FcConfig *config);
FcPublic FcStrList * FcPublic FcStrList *
FcConfigGetConfigFiles (FcConfig *config); FcConfigGetConfigFiles (FcConfig *config);
FcChar8 * FcPublic FcChar8 *
FcConfigGetCache (FcConfig *config); FcConfigGetCache (FcConfig *config);
FcBlanks * FcPublic FcBlanks *
FcConfigGetBlanks (FcConfig *config); FcConfigGetBlanks (FcConfig *config);
FcPublic FcStrList * FcPublic FcStrList *
@ -899,13 +899,13 @@ FcPublic void
FcStrSetDestroy (FcPublic FcStrSet *set); FcStrSetDestroy (FcPublic FcStrSet *set);
FcPublic FcStrList * FcPublic FcStrList *
FcPublic FcStrListCreate (FcPublic FcStrSet *set); FcStrListCreate (FcPublic FcStrSet *set);
FcPublic FcChar8 * FcPublic FcChar8 *
FcPublic FcStrListNext (FcStrList *list); FcStrListNext (FcStrList *list);
FcPublic void FcPublic void
FcPublic FcStrListDone (FcStrList *list); FcStrListDone (FcStrList *list);
/* fcxml.c */ /* fcxml.c */
FcPublic FcBool FcPublic FcBool

View File

@ -73,10 +73,14 @@ INCLUDES = \
-DFC_CACHEDIR='"$(FC_CACHEDIR)"' \ -DFC_CACHEDIR='"$(FC_CACHEDIR)"' \
-DFONTCONFIG_PATH='"$(CONFDIR)"' -DFONTCONFIG_PATH='"$(CONFDIR)"'
EXTRA_DIST = fontconfig.def.in EXTRA_DIST = fontconfig.def.in makealias
noinst_HEADERS=fcint.h noinst_HEADERS=fcint.h
ALIAS_FILES = fcalias.h fcaliastail.h
BUILT_SOURCES = $(ALIAS_FILES)
libfontconfig_la_SOURCES = \ libfontconfig_la_SOURCES = \
fcatomic.c \ fcatomic.c \
fcblanks.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 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)

View File

@ -211,3 +211,6 @@ FcAtomicDestroy (FcAtomic *atomic)
free (atomic); free (atomic);
} }
#define __fcatomic__
#include "fcaliastail.h"
#undef __fcatomic__

View File

@ -90,3 +90,6 @@ FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4)
return FcTrue; return FcTrue;
return FcFalse; return FcFalse;
} }
#define __fcblanks__
#include "fcaliastail.h"
#undef __fcblanks__

View File

@ -1085,3 +1085,6 @@ static void MD5Transform(FcChar32 buf[4], FcChar32 in[16])
buf[2] += c; buf[2] += c;
buf[3] += d; buf[3] += d;
} }
#define __fccache__
#include "fcaliastail.h"
#undef __fccache__

View File

@ -1964,3 +1964,6 @@ FcConfigAcceptFont (FcConfig *config,
return FcFalse; return FcFalse;
return FcTrue; return FcTrue;
} }
#define __fccfg__
#include "fcaliastail.h"
#undef __fccfg__

View File

@ -1358,3 +1358,6 @@ FcCharSetSerialize(FcSerialize *serialize, const FcCharSet *cs)
return cs_serialized; return cs_serialized;
} }
#define __fccharset__
#include "fcaliastail.h"
#undef __fccharset__

View File

@ -412,3 +412,6 @@ FcInitDebug (void)
FcDebugVal = 0; FcDebugVal = 0;
} }
} }
#define __fcdbg__
#include "fcaliastail.h"
#undef __fcdbg__

View File

@ -166,3 +166,6 @@ FcDefaultSubstitute (FcPattern *pattern)
FcPatternObjectAddInteger (pattern, FC_HINT_STYLE_OBJECT, FC_HINT_FULL); FcPatternObjectAddInteger (pattern, FC_HINT_STYLE_OBJECT, FC_HINT_FULL);
} }
} }
#define __fcdefault__
#include "fcaliastail.h"
#undef __fcdefault__

View File

@ -292,3 +292,6 @@ FcDirSave (FcFontSet *set, FcStrSet * dirs, const FcChar8 *dir)
{ {
return FcFalse; /* XXX deprecated */ return FcFalse; /* XXX deprecated */
} }
#define __fcdir__
#include "fcaliastail.h"
#undef __fcdir__

View File

@ -2952,3 +2952,7 @@ bail:
ftglue_free(memory, gpostags); ftglue_free(memory, gpostags);
return complex; return complex;
} }
#define __fcfreetype__
#include "fcaliastail.h"
#undef __fcfreetype__

View File

@ -130,3 +130,6 @@ FcFontSetSerialize (FcSerialize *serialize, const FcFontSet * s)
return s_serialize; return s_serialize;
} }
#define __fcfs__
#include "fcaliastail.h"
#undef __fcfs__

View File

@ -263,3 +263,6 @@ FcMemFree (int kind, int size)
FcMemReport (); FcMemReport ();
} }
} }
#define __fcinit__
#include "fcaliastail.h"
#undef __fcinit__

View File

@ -48,6 +48,7 @@
#include <fontconfig/fontconfig.h> #include <fontconfig/fontconfig.h>
#include <fontconfig/fcprivate.h> #include <fontconfig/fcprivate.h>
#include <fontconfig/fcfreetype.h> #include <fontconfig/fcfreetype.h>
#include "fcalias.h"
#ifndef FC_CONFIG_PATH #ifndef FC_CONFIG_PATH
#define FC_CONFIG_PATH "fonts.conf" #define FC_CONFIG_PATH "fonts.conf"
@ -322,6 +323,8 @@ struct _FcCache {
intptr_t set; /* offset to font set */ intptr_t set; /* offset to font set */
}; };
#undef FcCacheDir
#undef FcCacheSubdir
#define FcCacheDir(c) FcOffsetMember(c,dir,FcChar8) #define FcCacheDir(c) FcOffsetMember(c,dir,FcChar8)
#define FcCacheDirs(c) FcOffsetMember(c,dirs,intptr_t) #define FcCacheDirs(c) FcOffsetMember(c,dirs,intptr_t)
#define FcCacheSet(c) FcOffsetMember(c,set,FcFontSet) #define FcCacheSet(c) FcOffsetMember(c,set,FcFontSet)
@ -513,7 +516,7 @@ FcCacheObjectDereference (void *object);
FcPrivate void FcPrivate void
FcCacheFini (void); FcCacheFini (void);
void FcPrivate void
FcDirCacheReference (FcCache *cache, int nref); FcDirCacheReference (FcCache *cache, int nref);
/* fccfg.c */ /* fccfg.c */

View File

@ -727,3 +727,6 @@ FcLangSetSerialize(FcSerialize *serialize, const FcLangSet *l)
*l_serialize = *l; *l_serialize = *l;
return l_serialize; return l_serialize;
} }
#define __fclang__
#include "fcaliastail.h"
#undef __fclang__

View File

@ -556,3 +556,6 @@ FcFontList (FcConfig *config,
sets[nsets++] = config->fonts[FcSetApplication]; sets[nsets++] = config->fonts[FcSetApplication];
return FcFontSetList (config, sets, nsets, p, os); return FcFontSetList (config, sets, nsets, p, os);
} }
#define __fclist__
#include "fcaliastail.h"
#undef __fclist__

View File

@ -835,3 +835,6 @@ FcFontSort (FcConfig *config,
sets[nsets++] = config->fonts[FcSetApplication]; sets[nsets++] = config->fonts[FcSetApplication];
return FcFontSetSort (config, sets, nsets, p, trim, csp, result); return FcFontSetSort (config, sets, nsets, p, trim, csp, result);
} }
#define __fcmatch__
#include "fcaliastail.h"
#undef __fcmatch__

View File

@ -115,3 +115,6 @@ FcMatrixShear (FcMatrix *m, double sh, double sv)
r.yy = 1; r.yy = 1;
FcMatrixMultiply (m, &r, m); FcMatrixMultiply (m, &r, m);
} }
#define __fcmatrix__
#include "fcaliastail.h"
#undef __fcmatrix__

View File

@ -879,3 +879,6 @@ bail0:
FcStrBufDestroy (&buf); FcStrBufDestroy (&buf);
return 0; return 0;
} }
#define __fcname__
#include "fcaliastail.h"
#undef __fcname__

View File

@ -1208,3 +1208,6 @@ FcValueListSerialize (FcSerialize *serialize, const FcValueList *vl)
} }
return head_serialized; return head_serialized;
} }
#define __fcpat__
#include "fcaliastail.h"
#undef __fcpat__

View File

@ -159,3 +159,6 @@ FcStrSerialize (FcSerialize *serialize, const FcChar8 *str)
strcpy ((char *) str_serialize, (const char *) str); strcpy ((char *) str_serialize, (const char *) str);
return str_serialize; return str_serialize;
} }
#define __fcserialize__
#include "fcaliastail.h"
#undef __fcserialize__

View File

@ -1051,3 +1051,6 @@ FcStrListDone (FcStrList *list)
free (list); free (list);
} }
#define __fcstr__
#include "fcaliastail.h"
#undef __fcstr__

View File

@ -2493,3 +2493,6 @@ bail0:
} }
return FcTrue; return FcTrue;
} }
#define __fcxml__
#include "fcaliastail.h"
#undef __fcxml__

View File

@ -307,3 +307,6 @@ Exit:
} }
#undef QALLOC #undef QALLOC
#define __ftglue__
#include "fcaliastail.h"
#undef __ftglue__

24
src/makealias Executable file
View File

@ -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