From 7a4d23b8af6d5b517dd2646b83a70e4e1bceb136 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen Date: Thu, 26 Feb 2015 18:49:10 +0200 Subject: [PATCH] Mark all functions and symbols that LTO must not break --- dix/dixfonts.c | 18 +++++++++--------- dix/globals.c | 4 ++-- include/dix.h | 8 ++++---- include/dixfont.h | 2 +- include/os.h | 17 +++++++++++++---- 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/dix/dixfonts.c b/dix/dixfonts.c index b3ed865..7157833 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -1864,14 +1864,14 @@ InitFonts() } } -_X_EXPORT +_X_EXPORT XFONT_LTO int GetDefaultPointSize() { return 120; } -_X_EXPORT +_X_EXPORT XFONT_LTO FontResolutionPtr GetClientResolutions(int *num) { @@ -1911,7 +1911,7 @@ GetClientResolutions(int *num) * should be called (only once!) by each type of fpe when initialized */ -_X_EXPORT +_X_EXPORT XFONT_LTO int RegisterFPEFunctions(NameCheckFunc name_func, InitFpeFunc init_func, @@ -1981,28 +1981,28 @@ find_old_font(XID id) SecurityUnknownAccess); } -_X_EXPORT +_X_EXPORT XFONT_LTO Font GetNewFontClientID() { return FakeClientID(0); } -_X_EXPORT +_X_EXPORT XFONT_LTO int StoreFontClientFont(FontPtr pfont, Font id) { return AddResource(id, RT_NONE, (pointer) pfont); } -_X_EXPORT +_X_EXPORT XFONT_LTO void DeleteFontClientID(Font id) { FreeResource(id, RT_NONE); } -_X_EXPORT +_X_EXPORT XFONT_LTO int client_auth_generation(ClientPtr client) { @@ -2013,7 +2013,7 @@ static int fs_handlers_installed = 0; static unsigned int last_server_gen; -_X_EXPORT +_X_EXPORT XFONT_LTO int init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) { @@ -2034,7 +2034,7 @@ init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) return Successful; } -_X_EXPORT +_X_EXPORT XFONT_LTO void remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bool all) diff --git a/dix/globals.c b/dix/globals.c index 6b17073..82bd71b 100644 --- a/dix/globals.c +++ b/dix/globals.c @@ -80,7 +80,7 @@ PtrCtrl defaultPointerControl = { }; _X_EXPORT ClientPtr clients[MAXCLIENTS]; -_X_EXPORT ClientPtr serverClient; +_X_EXPORT XFONT_LTO_VAR ClientPtr serverClient; _X_EXPORT int currentMaxClients; /* current size of clients array */ _X_EXPORT long maxBigRequestSize = MAX_BIG_REQUEST_SIZE; @@ -89,7 +89,7 @@ _X_EXPORT WindowPtr WindowTable[MAXSCREENS]; _X_EXPORT unsigned long globalSerialNumber = 0; -_X_EXPORT unsigned long serverGeneration = 0; +_X_EXPORT XFONT_LTO_VAR unsigned long serverGeneration = 0; /* these next four are initialized in main.c */ _X_EXPORT CARD32 ScreenSaverTime; diff --git a/include/dix.h b/include/dix.h index f31a9e6..26ee9e6 100644 --- a/include/dix.h +++ b/include/dix.h @@ -401,7 +401,7 @@ Bool ClientSleep( #ifndef ___CLIENTSIGNAL_DEFINED___ #define ___CLIENTSIGNAL_DEFINED___ -Bool ClientSignal( +Bool XFONT_LTO ClientSignal( ClientPtr /*client*/); #endif /* ___CLIENTSIGNAL_DEFINED___ */ @@ -413,15 +413,15 @@ Bool ClientIsAsleep( /* atom.c */ -Atom MakeAtom( +XFONT_LTO Atom MakeAtom( char * /*string*/, unsigned /*len*/, Bool /*makeit*/); -Bool ValidAtom( +XFONT_LTO Bool ValidAtom( Atom /*atom*/); -char *NameForAtom( +XFONT_LTO char *NameForAtom( Atom /*atom*/); void AtomError(void); diff --git a/include/dixfont.h b/include/dixfont.h index 4b5694e..2ce672f 100644 --- a/include/dixfont.h +++ b/include/dixfont.h @@ -122,7 +122,7 @@ void InitFonts(void); void FreeFonts(void); -FontPtr find_old_font(XID /*id*/); +FontPtr XFONT_LTO find_old_font(XID /*id*/); void GetGlyphs(FontPtr /*font*/, unsigned long /*count*/, diff --git a/include/os.h b/include/os.h index 817699f..2b354ba 100644 --- a/include/os.h +++ b/include/os.h @@ -67,6 +67,15 @@ SOFTWARE. #define MAX_BIG_REQUEST_SIZE 4194303 #endif +// Need to mark a set of functions so LTO doesn't mangle them +#if defined(__GNUC__) && __GNUC__ >= 4 +#define XFONT_LTO __attribute__((noinline)) __attribute__((used)) +#define XFONT_LTO_VAR __attribute__((used)) +#else +#define XFONT_LTO +#define XFONT_LTO_VAR +#endif + typedef pointer FID; typedef struct _FontPathRec *FontPathPtr; typedef struct _NewClientRec *NewClientPtr; @@ -151,7 +160,7 @@ void MakeClientGrabPervious(ClientPtr /*client*/); void AvailableClientInput(ClientPtr /* client */); -CARD32 GetTimeInMillis(void); +CARD32 XFONT_LTO GetTimeInMillis(void); void AdjustWaitForDelay( pointer /*waitTime*/, @@ -192,7 +201,7 @@ void UseMsg(void); void ProcessCommandLine(int /*argc*/, char* /*argv*/[]); -int set_font_authorizations( +XFONT_LTO int set_font_authorizations( char ** /* authorizations */, int * /*authlen */, pointer /* client */); @@ -394,7 +403,7 @@ typedef enum { void AuditF(const char *f, ...) _printf_attribute(1,2); void VAuditF(const char *f, va_list args); -void FatalError(const char *f, ...) _printf_attribute(1,2) +void FatalError(const char *f, ...) _printf_attribute(1,2) XFONT_LTO #if defined(__GNUC__) && \ ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ > 4))) __attribute((noreturn)) @@ -402,6 +411,6 @@ __attribute((noreturn)) ; void VErrorF(const char *f, va_list args); -void ErrorF(const char *f, ...) _printf_attribute(1,2); +void ErrorF(const char *f, ...) _printf_attribute(1,2) XFONT_LTO; #endif /* OS_H */