Skip to content
Snippets Groups Projects
Commit b1b6309d authored by Simon McVittie's avatar Simon McVittie
Browse files

pv_wrap_append_preload: Classify loadable modules and behave accordingly


This doesn't make any practical difference yet, but it sets us up to be
able to carry out finer-grained processing based on the loadable_flags.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent a3140c42
No related branches found
No related tags found
1 merge request!337pressure-vessel: Remap preloadable modules better
......@@ -21,6 +21,7 @@
#include "wrap-setup.h"
#include "steam-runtime-tools/glib-backports-internal.h"
#include "steam-runtime-tools/libdl-internal.h"
#include "steam-runtime-tools/utils-internal.h"
#include "libglnx/libglnx.h"
......@@ -416,14 +417,14 @@ pv_wrap_append_preload (GPtrArray *argv,
PvRuntime *runtime,
FlatpakExports *exports)
{
SrtLoadableKind kind;
SrtLoadableFlags loadable_flags;
g_return_if_fail (argv != NULL);
g_return_if_fail (option != NULL);
g_return_if_fail (preload != NULL);
g_return_if_fail (runtime == NULL || PV_IS_RUNTIME (runtime));
if (*preload == '\0')
return;
if (strstr (preload, "gtk3-nocsd") != NULL)
{
g_warning ("Disabling gtk3-nocsd %s: it is known to cause crashes.",
......@@ -438,11 +439,47 @@ pv_wrap_append_preload (GPtrArray *argv,
return;
}
append_preload_internal (argv,
option,
preload,
env,
flags,
runtime,
exports);
kind = _srt_loadable_classify (preload, &loadable_flags);
switch (kind)
{
case SRT_LOADABLE_KIND_BASENAME:
/* Basenames can't have dynamic string tokens. */
g_warn_if_fail ((loadable_flags & SRT_LOADABLE_FLAGS_DYNAMIC_TOKENS) == 0);
/* Ideally we would handle this more cleverly, but for now,
* pass preload through to the container without adjustment.
* It isn't useful to add it to the FlatpakExports, because it
* isn't an absolute filename. */
append_preload_internal (argv,
option,
preload,
env,
flags,
runtime,
NULL);
break;
case SRT_LOADABLE_KIND_PATH:
/* Ideally we would handle this more cleverly, but for now,
* assume preload is a filename: adjust the beginning if it's
* in /usr/ etc., and add it to the exports if absolute. */
append_preload_internal (argv,
option,
preload,
env,
flags,
runtime,
exports);
break;
case SRT_LOADABLE_KIND_ERROR:
default:
/* Empty string or similar syntactically invalid token:
* ignore with a warning. Since steam-runtime-tools!352 and
* steamlinuxruntime!64, the wrapper scripts don't give us
* an empty argument any more. */
g_warning ("Ignoring invalid loadable module \"%s\"", preload);
break;
}
}
......@@ -207,8 +207,8 @@ populate_ld_preload (Fixture *f,
const char *warning;
} preloads[] =
{
{ "" },
{ "" },
{ "", .warning = "Ignoring invalid loadable module \"\"" },
{ "", .warning = "Ignoring invalid loadable module \"\"" },
{ "/app/lib/libpreloadA.so" },
{ "/platform/plat-$PLATFORM/libpreloadP.so" },
{ "/opt/${LIB}/libpreloadL.so" },
......@@ -226,7 +226,7 @@ populate_ld_preload (Fixture *f,
"/usr/local/lib/libgtk3-nocsd.so.0",
.warning = "Disabling gtk3-nocsd LD_PRELOAD: it is known to cause crashes.",
},
{ "" },
{ "", .warning = "Ignoring invalid loadable module \"\"" },
};
gsize i;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment