|
3 | 3 |
|
4 | 4 | // Do not edit these defines. They use special section names that the recomp mod tool recognizes for specific modding functionality. |
5 | 5 |
|
| 6 | +#ifdef __cplusplus |
| 7 | +# define EXTERNC extern "C" |
| 8 | +#else |
| 9 | +# define EXTERNC |
| 10 | +#endif |
| 11 | + |
| 12 | +// The RECOMP_IMPORT has the following attributes: |
| 13 | +// noinline: Prevent import function definitions from being inlined, allowing the mod tool to find relocs. |
| 14 | +// weak: Allow import definitions to be in headers without triggering multiple definition errors. |
6 | 15 | #define RECOMP_IMPORT(mod, func) \ |
7 | 16 | _Pragma("GCC diagnostic push") \ |
8 | 17 | _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"") \ |
9 | 18 | _Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \ |
10 | | - __attribute__((noinline, weak, used, section(".recomp_import." mod))) func {} \ |
| 19 | + EXTERNC __attribute__((noinline, weak, used, section(".recomp_import." mod))) func {} \ |
11 | 20 | _Pragma("GCC diagnostic pop") |
12 | 21 |
|
13 | | -#define RECOMP_EXPORT __attribute__((section(".recomp_export"))) |
| 22 | +#define RECOMP_EXPORT EXTERNC __attribute__((retain, section(".recomp_export"))) |
14 | 23 |
|
15 | | -#define RECOMP_PATCH __attribute__((section(".recomp_patch"))) |
| 24 | +#define RECOMP_PATCH EXTERNC __attribute__((retain, section(".recomp_patch"))) |
16 | 25 |
|
17 | | -#define RECOMP_FORCE_PATCH __attribute__((section(".recomp_force_patch"))) |
| 26 | +#define RECOMP_FORCE_PATCH EXTERNC __attribute__((retain, section(".recomp_force_patch"))) |
18 | 27 |
|
19 | 28 | #define RECOMP_DECLARE_EVENT(func) \ |
20 | 29 | _Pragma("GCC diagnostic push") \ |
21 | 30 | _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"") \ |
22 | | - __attribute__((noinline, weak, used, section(".recomp_event"))) void func {} \ |
| 31 | + EXTERNC __attribute__((retain, noinline, weak, used, section(".recomp_event"))) void func {} \ |
23 | 32 | _Pragma("GCC diagnostic pop") |
24 | 33 |
|
25 | | -#define RECOMP_CALLBACK(mod, event) __attribute__((section(".recomp_callback." mod ":" #event))) |
| 34 | +#define RECOMP_CALLBACK(mod, event) __attribute__((retain, section(".recomp_callback." mod ":" #event))) |
26 | 35 |
|
27 | | -#define RECOMP_HOOK(func) __attribute__((section(".recomp_hook." func))) |
| 36 | +#define RECOMP_HOOK(func) __attribute__((retain, section(".recomp_hook." func))) |
28 | 37 |
|
29 | | -#define RECOMP_HOOK_RETURN(func) __attribute__((section(".recomp_hook_return." func))) |
| 38 | +#define RECOMP_HOOK_RETURN(func) __attribute__((retain, section(".recomp_hook_return." func))) |
30 | 39 |
|
31 | 40 | #endif |
0 commit comments