Skip to content
Snippets Groups Projects
Commit 859ea86a authored by Vivek Das Mohapatra's avatar Vivek Das Mohapatra
Browse files

Use the new capsule_shim_dlsym helper to implement a dlsym wrapper

The capsule-init-project script now implements and installs a
dlsym() wrapper in generated shim project source trees.
parent 5107c747
No related branches found
No related tags found
1 merge request!311Build capsule-capture-libs from a bundled copy of libcapsule
...@@ -47,8 +47,8 @@ typedef struct _capsule_item capsule_item; ...@@ -47,8 +47,8 @@ typedef struct _capsule_item capsule_item;
struct _capsule_item struct _capsule_item
{ {
const char *name; const char *name;
capsule_addr shim;
capsule_addr real; capsule_addr real;
capsule_addr shim;
/*< private >*/ /*< private >*/
void *unused0; void *unused0;
......
...@@ -70,6 +70,22 @@ static void *_dlopen (const char *filename, int flag) ...@@ -70,6 +70,22 @@ static void *_dlopen (const char *filename, int flag)
} }
EOF EOF
cat - <<EOF > shim/$base.so.c.dlsym
// This allows symbols inside the capsule to be found by dlopen calls from
// outside the capsule iff they are in one of the exported DSOs.
//
// This is useful in libGL shims as libGL has an ‘interesting’ history
// of symbols appearing and disappearing so its users often do a
// bizarre dlopen()/dlsym() dance instead of referring to a symbol
// directly (and we may be missing those symbols from our static
// export list even if the target libGL has them)
static void *_dlsym (void *handle, const char *symbol)
{
const char **valid_sources = { "libGL.so.1", NULL };
return capsule_shim_dlsym( dso, handle, symbol, valid_sources );
}
EOF
echo Initialising configure.ac; echo Initialising configure.ac;
cat - <<EOF > configure.ac cat - <<EOF > configure.ac
......
...@@ -47,6 +47,7 @@ proxied_dso=lib${dso_base}.so.${major_version}; ...@@ -47,6 +47,7 @@ proxied_dso=lib${dso_base}.so.${major_version};
symbol_file=${proxy_src%.c}.symbols; symbol_file=${proxy_src%.c}.symbols;
map_file=${proxy_src%.c}.map; map_file=${proxy_src%.c}.map;
dlopen_file=${proxy_src}.dlopen; dlopen_file=${proxy_src}.dlopen;
dlsym_file=${proxy_src}.dlsym;
sharedir=$(pkg-config --variable=makeinc capsule) sharedir=$(pkg-config --variable=makeinc capsule)
exec >$proxy_src.tmp; exec >$proxy_src.tmp;
...@@ -120,6 +121,15 @@ then ...@@ -120,6 +121,15 @@ then
echo "// -------------------------------------------------------------"; echo "// -------------------------------------------------------------";
fi fi
if [ -f ${dlsym_file} ];
then
echo "// -------------------------------------------------------------";
echo "// start of ${proxy_src%.c} dlsym wrapper";
cat $dlsym_file;
echo "// end of ${proxy_src%.c} dlsym wrapper";
echo "// -------------------------------------------------------------";
fi
cat - <<EOF cat - <<EOF
static void __attribute__ ((constructor)) _capsule_init (void) static void __attribute__ ((constructor)) _capsule_init (void)
...@@ -134,8 +144,15 @@ EOF ...@@ -134,8 +144,15 @@ EOF
while read sym x; do echo " { \"$sym\" },"; done < $symbol_file; while read sym x; do echo " { \"$sym\" },"; done < $symbol_file;
if [ -f $dlsym_file ];
then
cat - <<EOF
{ "dlsym", (capsule_addr) _dlsym },
EOF
fi;
cat - <<EOF cat - <<EOF
{ NULL } { NULL }
}; };
// and this is an aray of functions we must override in the DSOs // and this is an aray of functions we must override in the DSOs
......
...@@ -29,7 +29,7 @@ GENSTUB_V0 = @echo " GENSTUB " $(subst $(word 1, $(basename $(filter shim/lib%, ...@@ -29,7 +29,7 @@ GENSTUB_V0 = @echo " GENSTUB " $(subst $(word 1, $(basename $(filter shim/lib%,
GENSTUB = $(GENSTUB_V$(V)) GENSTUB = $(GENSTUB_V$(V))
# regenerate if any dependencies get updated: # regenerate if any dependencies get updated:
shim/lib%.so.c: shim/lib%.so.c.excluded shim/lib%.so.c.dlopen shim/lib%.so.symbols shim/lib%.so.c: shim/lib%.so.c.excluded shim/lib%.so.c.dlopen shim/lib%.so.c.dlsym shim/lib%.so.symbols
$(GENSTUB)V=$V $(mkstub) $$(basename $@ .c) $@.excluded $@.shared $@ $(ltver) $(CAPSULE_TREE) $(GENSTUB)V=$V $(mkstub) $$(basename $@ .c) $@.excluded $@.shared $@ $(ltver) $(CAPSULE_TREE)
# regenerate the exportable symbols list # regenerate the exportable symbols list
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment