Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
3dbb0db4
Commit
3dbb0db4
authored
Feb 25, 2018
by
yonghong-song
Committed by
GitHub
Feb 25, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1599 from gmile/fix-dlinfo
Do not rely on RTLD_DI_ORIGIN
parents
f3d3c94b
6cd2a9c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
tests/cc/test_c_api.cc
tests/cc/test_c_api.cc
+5
-2
No files found.
tests/cc/test_c_api.cc
View file @
3dbb0db4
...
...
@@ -17,6 +17,7 @@
#include <dlfcn.h>
#include <stdint.h>
#include <string.h>
#include <link.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/stat.h>
...
...
@@ -137,6 +138,7 @@ static int mntns_func(void *arg) {
char
libpath
[
1024
];
ssize_t
rb
;
void
*
dlhdl
;
struct
link_map
*
lm
;
if
(
setup_tmp_mnts
()
<
0
)
{
return
-
1
;
...
...
@@ -149,16 +151,17 @@ static int mntns_func(void *arg) {
return
-
1
;
}
if
(
dlinfo
(
dlhdl
,
RTLD_DI_
ORIGIN
,
&
libpath
)
<
0
)
{
if
(
dlinfo
(
dlhdl
,
RTLD_DI_
LINKMAP
,
&
lm
)
<
0
)
{
fprintf
(
stderr
,
"Unable to find origin of libz.so.1: %s
\n
"
,
dlerror
());
return
-
1
;
}
strncpy
(
libpath
,
lm
->
l_name
,
1024
);
dlclose
(
dlhdl
);
dlhdl
=
NULL
;
// Copy a shared library from shared mntns to private /tmp
snprintf
(
buf
,
4096
,
"%s
/libz.so.1
"
,
libpath
);
snprintf
(
buf
,
4096
,
"%s"
,
libpath
);
in_fd
=
open
(
buf
,
O_RDONLY
);
if
(
in_fd
<
0
)
{
fprintf
(
stderr
,
"Unable to open %s: %s
\n
"
,
buf
,
strerror
(
errno
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment