diff --git a/configure.py b/configure.py index aee9750c..473a1f0c 100644 --- a/configure.py +++ b/configure.py @@ -39,8 +39,9 @@ parser.options.add_argument('--targets', type=str, dest='targets', default=None, help="Override the target architecture (use commas to separate multiple targets).") # AddressSanitizer Instructions: -# Recompile Metamod with RTLD_DEEPBIND removed (may break some std functionality) -# Run server with LD_PRELOAD=/usr/lib/clang/11/lib/linux/libclang_rt.asan-x86_64.so (for SteamRT3) +# Copy devtools/libasan.so.dlhook.so to the server +# Run server with LD_PRELOAD="/path/to/libasan.so.dlhook.so /usr/lib/clang/11/lib/linux/libclang_rt.asan-x86_64.so" (for SteamRT3) +# Note this may break some std functionality parser.options.add_argument('--asan', action='store_const', const='1', dest='asan', help='Build for AddressSanitizer') parser.Configure() diff --git a/devtools/dlhook/libasan.so.dlhook.so b/devtools/dlhook/libasan.so.dlhook.so new file mode 100644 index 00000000..538607c9 Binary files /dev/null and b/devtools/dlhook/libasan.so.dlhook.so differ diff --git a/devtools/dlhook/src/compile.sh b/devtools/dlhook/src/compile.sh new file mode 100644 index 00000000..0a08e5b8 --- /dev/null +++ b/devtools/dlhook/src/compile.sh @@ -0,0 +1 @@ +gcc -fPIC -rdynamic -shared dlhook.c -o libasan.so.dlhook.so \ No newline at end of file diff --git a/devtools/dlhook/src/dlhook.c b/devtools/dlhook/src/dlhook.c new file mode 100644 index 00000000..304b2519 --- /dev/null +++ b/devtools/dlhook/src/dlhook.c @@ -0,0 +1,15 @@ +#define _GNU_SOURCE +#include +#include + +void *dlopen(const char *filename, int flags) +{ + printf("CALLED DLOPEN!!\n"); + typedef void *(*dlopen_t)(const char *filename, int flags); + static dlopen_t func; + + if(!func) + func = (dlopen_t)dlsym(RTLD_NEXT, "dlopen"); + + return(func(filename, flags & ~RTLD_DEEPBIND)); +} \ No newline at end of file