Debian Codegraph @

debian/patches/build-Export-only-the-symbols-that-need-to-be-exported.patch

raw
1 From: Simon McVittie <[email protected]>
2 Date: Fri, 22 Aug 2025 19:21:22 +0100
3 Subject: build: Export only the symbols that need to be exported
4
5 On Windows, by default symbols are not exported from DLLs unless we
6 explicitly ask for it (via `Q_EXPORT`), and by default symbols in the
7 executable will not "interpose" in front of symbols of the same name
8 in a DLL. However, on ELF platforms such as Linux, for historical
9 reasons neither of these is true. Request more reasonable semantics.
10
11 This is good for library size and performance, because every function
12 call to an exported symbol needs to be done indirectly, in case some
13 other module is interposing it.
14
15 It is also good for correctness, because if we don't do this, a global
16 variable in native-code game modules like `qagame.so` can be
17 unexpectedly replaced with a global variable in the executable or in
18 a different library that happens to have the same name, even if it has
19 a different type (which in practice will lead to a crash).
20
21 Bug: https://github.com/ioquake/ioq3/issues/765
22 Bug-Debian: https://bugs.debian.org/1111671
23 Forwarded: not-needed, done differently upstream in OAX
24 ---
25 Makefile | 1 +
26 code/cgame/cg_main.c | 2 +-
27 code/cgame/cg_syscalls.c | 2 +-
28 code/game/g_main.c | 2 +-
29 code/q3_ui/ui_main.c | 4 ++--
30 code/ui/ui_main.c | 2 +-
31 code/ui/ui_syscalls.c | 2 +-
32 7 files changed, 8 insertions(+), 7 deletions(-)
33
34 diff --git a/Makefile b/Makefile
35 index 521ea75..df76d8c 100644
36 --- a/Makefile
37 +++ b/Makefile
38 @@ -227,6 +227,7 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu" "gnu")
39
40 BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
41 -pipe -DUSE_ICON $(SDL_CFLAGS) -DARCH_STRING=\\\"$(ARCH)\\\"
42 + BASE_CFLAGS += -fvisibility=hidden
43
44 ifeq ($(USE_OPENAL),1)
45 BASE_CFLAGS += -DUSE_OPENAL
46 diff --git a/code/cgame/cg_main.c b/code/cgame/cg_main.c
47 index a271d29..deb2545 100644
48 --- a/code/cgame/cg_main.c
49 +++ b/code/cgame/cg_main.c
50 @@ -43,7 +43,7 @@ This is the only way control passes into the module.
51 This must be the very first function compiled into the .q3vm file
52 ================
53 */
54 -intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
55 +Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
56
57 switch ( command ) {
58 case CG_INIT:
59 diff --git a/code/cgame/cg_syscalls.c b/code/cgame/cg_syscalls.c
60 index 4823d67..5e9d0e0 100644
61 --- a/code/cgame/cg_syscalls.c
62 +++ b/code/cgame/cg_syscalls.c
63 @@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
64 static intptr_t (QDECL *syscall)( intptr_t arg, ... ) = (intptr_t (QDECL *)( intptr_t, ...))-1;
65
66
67 -void dllEntry( intptr_t (QDECL *syscallptr)( intptr_t arg,... ) ) {
68 +Q_EXPORT void dllEntry( intptr_t (QDECL *syscallptr)( intptr_t arg,... ) ) {
69 syscall = syscallptr;
70 }
71
72 diff --git a/code/game/g_main.c b/code/game/g_main.c
73 index 426973e..3f3d08f 100644
74 --- a/code/game/g_main.c
75 +++ b/code/game/g_main.c
76 @@ -418,7 +418,7 @@ This is the only way control passes into the module.
77 This must be the very first function compiled into the .q3vm file
78 ================
79 */
80 -intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
81 +Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
82 switch ( command ) {
83 case GAME_INIT:
84 G_InitGame( arg0, arg1, arg2 );
85 diff --git a/code/q3_ui/ui_main.c b/code/q3_ui/ui_main.c
86 index c18bb6a..3960976 100644
87 --- a/code/q3_ui/ui_main.c
88 +++ b/code/q3_ui/ui_main.c
89 @@ -40,7 +40,7 @@ This is the only way control passes into the module.
90 This must be the very first function compiled into the .qvm file
91 ================
92 */
93 -intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
94 +Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
95 switch ( command ) {
96 case UI_GETAPIVERSION:
97 return UI_API_VERSION;
98 @@ -327,4 +327,4 @@ void UI_UpdateCvars( void ) {
99 void UI_SetDefaultCvar(const char* cvar, const char* value) {
100 if(strlen(UI_Cvar_VariableString(cvar)) == 0)
101 trap_Cvar_Set(cvar,value);
102 -}
103 \ No newline at end of file
104 +}
105 diff --git a/code/ui/ui_main.c b/code/ui/ui_main.c
106 index fd5505a..fd03fb5 100644
107 --- a/code/ui/ui_main.c
108 +++ b/code/ui/ui_main.c
109 @@ -176,7 +176,7 @@ void _UI_KeyEvent( int key, qboolean down );
110 void _UI_MouseEvent( int dx, int dy );
111 void _UI_Refresh( int realtime );
112 qboolean _UI_IsFullscreen( void );
113 -intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
114 +Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
115 switch ( command ) {
116 case UI_GETAPIVERSION:
117 return UI_API_VERSION;
118 diff --git a/code/ui/ui_syscalls.c b/code/ui/ui_syscalls.c
119 index 77c14eb..3ebd480 100644
120 --- a/code/ui/ui_syscalls.c
121 +++ b/code/ui/ui_syscalls.c
122 @@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
123
124 static intptr_t (QDECL *syscall)( intptr_t arg, ... ) = (intptr_t (QDECL *)( intptr_t, ...))-1;
125
126 -void dllEntry( intptr_t (QDECL *syscallptr)( intptr_t arg,... ) ) {
127 +Q_EXPORT void dllEntry( intptr_t (QDECL *syscallptr)( intptr_t arg,... ) ) {
128 syscall = syscallptr;
129 }
130