mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-06-12 17:14:46 +02:00
Get rid of compiler check (core vs modules) and clean the modversion check too
This commit is contained in:
+8
-40
@@ -21,48 +21,16 @@
|
|||||||
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
/* What all this is for? Well, it's simple...
|
/* At UnrealIRCd we don't have a stable module ABI.
|
||||||
* Example: When someone compiles a module with ssl support, but the
|
* We check for version nowadays, but actually there are many more
|
||||||
* core was not compiled with ssl support, then the module will read
|
* ways to cause binary interface screwups, like using the git
|
||||||
* things incorrect in the struct because the module sees an extra
|
* version and then have a different include/struct.h on your
|
||||||
* field half-way the struct but in the core that field does not exist,
|
* running unrealircd compared to your modules, with members shifted
|
||||||
* hence all data is shifted 4 bytes causing all kinds of odd crashes,
|
* or reordered and the like. Fun!
|
||||||
* memory corruption, and weird problems.
|
|
||||||
* This is an attempt to prevent this a bit, but there are a lot more
|
|
||||||
* options that cause binary incompatability (eg: changing nicklen),
|
|
||||||
* we just take the most common ones...
|
|
||||||
*
|
|
||||||
* NOTE: On win32 we allow ssl inconsistencies because we
|
|
||||||
* explicitly use "padding" in the structs: we add a useless
|
|
||||||
* placeholder so everything is still aligned correctly.
|
|
||||||
* In the process of doing so, we waste several bytes per-user,
|
|
||||||
* but this prevents (most) binary incompatability problems
|
|
||||||
* making it easier for module coders to ship dll's.
|
|
||||||
*/
|
*/
|
||||||
#ifndef _WIN32
|
|
||||||
#define MYTOKEN_SSL "/SSL"
|
|
||||||
#else
|
|
||||||
#define MYTOKEN_SSL ""
|
|
||||||
#endif
|
|
||||||
#define MYTOKEN_NEWCHF "/NOCHF"
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#if defined(__GNUC_PATCHLEVEL__)
|
|
||||||
#define GCCVER ((__GNUC__ << 16) + (__GNUC_MINOR__ << 8) + __GNUC_PATCHLEVEL__)
|
|
||||||
#else
|
|
||||||
#define GCCVER ((__GNUC__ << 16) + (__GNUC_MINOR__ << 8))
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define GCCVER 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef UNREALCORE
|
#ifdef UNREALCORE
|
||||||
char our_mod_version[] = BASE_VERSION "-" PATCH1 PATCH2 PATCH3 PATCH4 PATCH6 PATCH7 PATCH8 PATCH9 \
|
char our_mod_version[] = BASE_VERSION "-" PATCH1 PATCH2 PATCH3 PATCH4 PATCH6 PATCH7 PATCH8 PATCH9;
|
||||||
MYTOKEN_SSL MYTOKEN_NEWCHF;
|
|
||||||
unsigned int our_compiler_version = GCCVER;
|
|
||||||
#else
|
#else
|
||||||
DLLFUNC char Mod_Version[] = BASE_VERSION "-" PATCH1 PATCH2 PATCH3 PATCH4 PATCH6 PATCH7 PATCH8 PATCH9 \
|
DLLFUNC char Mod_Version[] = BASE_VERSION "-" PATCH1 PATCH2 PATCH3 PATCH4 PATCH6 PATCH7 PATCH8 PATCH9;
|
||||||
MYTOKEN_SSL MYTOKEN_NEWCHF;
|
|
||||||
DLLFUNC unsigned int compiler_version = GCCVER;
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -290,7 +290,6 @@ const char *Module_Create(const char *path_)
|
|||||||
int (*Mod_Load)();
|
int (*Mod_Load)();
|
||||||
int (*Mod_Unload)();
|
int (*Mod_Unload)();
|
||||||
char *Mod_Version;
|
char *Mod_Version;
|
||||||
unsigned int *compiler_version;
|
|
||||||
static char errorbuf[1024];
|
static char errorbuf[1024];
|
||||||
const char *path, *relpath, *tmppath;
|
const char *path, *relpath, *tmppath;
|
||||||
ModuleHeader *mod_header = NULL;
|
ModuleHeader *mod_header = NULL;
|
||||||
@@ -298,7 +297,6 @@ const char *Module_Create(const char *path_)
|
|||||||
const char *reterr;
|
const char *reterr;
|
||||||
Module *mod = NULL, **Mod_Handle = NULL;
|
Module *mod = NULL, **Mod_Handle = NULL;
|
||||||
char *expectedmodversion = our_mod_version;
|
char *expectedmodversion = our_mod_version;
|
||||||
unsigned int expectedcompilerversion = our_compiler_version;
|
|
||||||
long modsys_ver = 0;
|
long modsys_ver = 0;
|
||||||
|
|
||||||
path = Module_TransformPath(path_);
|
path = Module_TransformPath(path_);
|
||||||
@@ -356,19 +354,6 @@ const char *Module_Create(const char *path_)
|
|||||||
deletetmp(tmppath);
|
deletetmp(tmppath);
|
||||||
return errorbuf;
|
return errorbuf;
|
||||||
}
|
}
|
||||||
irc_dlsym(Mod, "compiler_version", compiler_version);
|
|
||||||
if (compiler_version && ( ((*compiler_version) & 0xffff00) != (expectedcompilerversion & 0xffff00) ) )
|
|
||||||
{
|
|
||||||
char theyhad[64], wehave[64];
|
|
||||||
make_compiler_string(theyhad, sizeof(theyhad), *compiler_version);
|
|
||||||
make_compiler_string(wehave, sizeof(wehave), expectedcompilerversion);
|
|
||||||
snprintf(errorbuf, sizeof(errorbuf),
|
|
||||||
"Module was compiled with GCC %s, core was compiled with GCC %s. SOLUTION: Recompile your UnrealIRCd and all its modules by doing a 'make clean; ./Config -quick && make'.",
|
|
||||||
theyhad, wehave);
|
|
||||||
irc_dlclose(Mod);
|
|
||||||
deletetmp(tmppath);
|
|
||||||
return errorbuf;
|
|
||||||
}
|
|
||||||
irc_dlsym(Mod, "Mod_Header", mod_header);
|
irc_dlsym(Mod, "Mod_Header", mod_header);
|
||||||
if (!mod_header)
|
if (!mod_header)
|
||||||
{
|
{
|
||||||
@@ -405,7 +390,6 @@ const char *Module_Create(const char *path_)
|
|||||||
mod = (Module *)Module_make(mod_header, Mod);
|
mod = (Module *)Module_make(mod_header, Mod);
|
||||||
safe_strdup(mod->tmp_file, tmppath);
|
safe_strdup(mod->tmp_file, tmppath);
|
||||||
mod->mod_sys_version = modsys_ver;
|
mod->mod_sys_version = modsys_ver;
|
||||||
mod->compiler_version = compiler_version ? *compiler_version : 0;
|
|
||||||
safe_strdup(mod->relpath, relpath);
|
safe_strdup(mod->relpath, relpath);
|
||||||
|
|
||||||
irc_dlsym(Mod, "Mod_Init", Mod_Init);
|
irc_dlsym(Mod, "Mod_Init", Mod_Init);
|
||||||
|
|||||||
Reference in New Issue
Block a user