From 82a623f5b709eaa5af7e045581966d39fd3f913f Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Thu, 26 May 2016 23:19:32 +0100 Subject: [PATCH] Add helper function for building the LD_PRELOAD list for Steam's runtime Signed-off-by: Ikey Doherty --- configure.ac | 12 ++++++++++++ src/shim/lsi.c | 6 ++++++ src/shim/lsi.h | 6 ++++++ src/shim/shim.c | 1 + 4 files changed, 25 insertions(+) diff --git a/configure.ac b/configure.ac index 537c432..f930b6c 100644 --- a/configure.ac +++ b/configure.ac @@ -10,6 +10,16 @@ AM_SILENT_RULES([yes]) LT_INIT([disable-static]) AC_CONFIG_MACRO_DIR([m4]) +# emul32 directory. On Solus this is /usr/lib32. multiarch systems are likely +# using /usr/lib/i386-linux-gnu/ +AC_ARG_WITH([emul32-libdir], AS_HELP_STRING([--with-emul32-libdir], + [the path in which 32-bit libraries are stored]), [emul32dir=${withval}], + [emul32dir="/usr/lib32"]) + +AC_SUBST(emul32dir) +AC_DEFINE_UNQUOTED(EMUL32LIBDIR, "$emul32dir", + [The location of 32-bit libraries in the OS configuration]) + AC_CONFIG_FILES([Makefile]) @@ -26,6 +36,8 @@ AC_MSG_RESULT([ bindir: ${bindir} datarootdir: ${datarootdir} + emul32-libdir: ${emul32dir} + compiler: ${CC} cflags: ${CFLAGS} ldflags: ${LDFLAGS} diff --git a/src/shim/lsi.c b/src/shim/lsi.c index 9114137..353c730 100644 --- a/src/shim/lsi.c +++ b/src/shim/lsi.c @@ -12,6 +12,7 @@ #include #include +#include "config.h" #include "lsi.h" bool lsi_config_load(__lsi_unused__ LsiConfig *config) @@ -36,6 +37,11 @@ void lsi_config_load_defaults(LsiConfig *config) config->use_native_runtime = true; } +const char *lsi_preload_list() +{ + return EMUL32LIBDIR "/libx11.so.6:" EMUL32LIBDIR "/libstdc++.so.6"; +} + /* * Editor modelines - https://www.wireshark.org/tools/modelines.html * diff --git a/src/shim/lsi.h b/src/shim/lsi.h index fc8043b..23c2347 100644 --- a/src/shim/lsi.h +++ b/src/shim/lsi.h @@ -59,6 +59,12 @@ __lsi_inline__ static inline bool lsi_system_is_64bit(void) return false; } +/** + * Return the required preload list for running Steam via their runtime + * This is static .text - do not free + */ +const char *lsi_preload_list(void); + /* * Editor modelines - https://www.wireshark.org/tools/modelines.html * diff --git a/src/shim/shim.c b/src/shim/shim.c index 32d5d44..45f0a11 100644 --- a/src/shim/shim.c +++ b/src/shim/shim.c @@ -29,6 +29,7 @@ int main(__lsi_unused__ int argc, __lsi_unused__ char **argv) fprintf(stderr, "emul32? %s\n", config.force_32 ? "yes" : "no"); fprintf(stderr, "native-runtime? %s\n", config.use_native_runtime ? "yes" : "no"); fprintf(stderr, "x86-64? %s\n", is_x86_64 ? "yes" : "no"); + fprintf(stderr, "LD_PRELOAD=\"%s\"\n", lsi_preload_list()); return EXIT_FAILURE; }