Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
steam-runtime-tools
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
steamrt
steam-runtime-tools
Commits
ce84258a
Commit
ce84258a
authored
7 years ago
by
Vivek Das Mohapatra
Browse files
Options
Downloads
Patches
Plain Diff
Rewrite the dlopen→dlmopen wrapper so it mostly works, mostly.
parent
cb4dc19d
No related branches found
No related tags found
1 merge request
!311
Build capsule-capture-libs from a bundled copy of libcapsule
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
capsule/capsule-dlmopen.c
+42
-22
42 additions, 22 deletions
capsule/capsule-dlmopen.c
capsule/capsule.h
+1
-2
1 addition, 2 deletions
capsule/capsule.h
with
43 additions
and
24 deletions
capsule/capsule-dlmopen.c
+
42
−
22
View file @
ce84258a
...
@@ -1404,8 +1404,7 @@ cleanup:
...
@@ -1404,8 +1404,7 @@ cleanup:
}
}
void
*
void
*
capsule_shim_dlopen
(
void
*
handle
,
capsule_shim_dlopen
(
Lmid_t
ns
,
Lmid_t
ns
,
const
char
*
prefix
,
const
char
*
prefix
,
const
char
**
exclude
,
const
char
**
exclude
,
const
char
*
file
,
const
char
*
file
,
...
@@ -1414,37 +1413,58 @@ capsule_shim_dlopen(void *handle,
...
@@ -1414,37 +1413,58 @@ capsule_shim_dlopen(void *handle,
void
*
res
;
void
*
res
;
int
code
=
0
;
int
code
=
0
;
char
*
errors
=
NULL
;
char
*
errors
=
NULL
;
ldlibs_t
ldlibs
=
{
0
};
debug
(
"capsule dlopen() wrapper: handle: %p; LMID: %ld; prefix: %s"
,
handle
,
ns
,
prefix
);
debug
(
">>>> capsule dlopen(%s, %x) wrapper: LMID: %ld; prefix: %s;"
,
debug
(
" target: %s; flags: %d"
,
file
,
flag
);
file
,
flag
,
ns
,
prefix
);
if
(
!
handle
)
return
NULL
;
// we have an absolute file path and a significant path prefix:
if
(
prefix
&&
strcmp
(
prefix
,
"/"
)
)
if
(
file
&&
*
file
==
'/'
&&
prefix
&&
strcmp
(
prefix
,
"/"
)
)
{
{
char
path
[
PATH_MAX
];
init_ldlibs
(
&
ldlibs
,
exclude
,
prefix
,
1
,
&
code
,
&
errors
);
const
size_t
l
=
strlen
(
prefix
);
if
(
!
load_ld_cache
(
&
ldlibs
,
"/etc/ld.so.cache"
)
)
{
int
rv
=
(
errno
==
0
)
?
EINVAL
:
errno
;
debug
(
"Loading ld.so.cache from %s (error: %d)"
,
prefix
,
rv
);
goto
cleanup
;
}
if
(
!
dso_find
(
file
,
&
ldlibs
,
0
)
)
{
int
rv
=
(
errno
==
0
)
?
EINVAL
:
errno
;
debug
(
"<<<< Not found: %s under %s (error: %d)"
,
file
,
prefix
,
rv
);
goto
cleanup
;
}
safe_strncpy
(
path
,
prefix
,
PATH_MAX
);
dso_iterate_sections
(
&
ldlibs
,
0
);
path
[
l
]
=
'/'
;
safe_strncpy
(
path
+
l
+
1
,
file
,
PATH_MAX
);
debug
(
"RE-MAPPED dlopen target '%s' to '%s'
\n
"
,
file
,
path
);
if
(
ldlibs
.
error
)
{
debug
(
"<<<< capsule dlopen error: %s"
,
ldlibs
.
error
);
goto
cleanup
;
}
res
=
res
=
load_ldlibs
(
&
ldlibs
,
&
ns
,
flag
,
&
code
,
&
errors
);
capsule_dlmopen
(
path
,
prefix
,
&
ns
,
NULL
,
0
,
exclude
,
&
code
,
&
errors
);
if
(
!
res
)
if
(
!
res
)
debug
(
"capsule_shim_dlopen failed: (%d) %s
\n
"
,
code
,
errors
);
{
debug
(
"<<<< capsule dlopen error %d: %s"
,
code
,
errors
);
goto
cleanup
;
}
}
}
else
else
// no prefix: straightforward dlmopen into our capsule namespace:
{
{
debug
(
"No prefix, opening %s in private namespace %p"
,
file
,
(
void
*
)
ns
);
res
=
dlmopen
(
ns
,
file
,
flag
);
res
=
dlmopen
(
ns
,
file
,
RTLD_NOW
);
if
(
!
res
)
debug
(
"<<<< capsule dlopen error %s: %s"
,
file
,
dlerror
()
);
}
}
return
res
;
return
res
;
cleanup:
cleanup_ldlibs
(
&
ldlibs
);
return
res
;
}
}
This diff is collapsed.
Click to expand it.
capsule/capsule.h
+
1
−
2
View file @
ce84258a
...
@@ -41,8 +41,7 @@ void *capsule_dlmopen (const char *dso,
...
@@ -41,8 +41,7 @@ void *capsule_dlmopen (const char *dso,
int
*
errcode
,
int
*
errcode
,
char
**
error
);
char
**
error
);
void
*
capsule_shim_dlopen
(
void
*
handle
,
void
*
capsule_shim_dlopen
(
Lmid_t
ns
,
Lmid_t
ns
,
const
char
*
prefix
,
const
char
*
prefix
,
const
char
**
exclude
,
const
char
**
exclude
,
const
char
*
file
,
const
char
*
file
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment