Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
relibc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tornax O7
relibc
Commits
aefb4fb1
Verified
Commit
aefb4fb1
authored
6 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Improvements for dlfcn
parent
c41c20a9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/header/dlfcn/mod.rs
+30
-6
30 additions, 6 deletions
src/header/dlfcn/mod.rs
with
30 additions
and
6 deletions
src/header/dlfcn/mod.rs
+
30
−
6
View file @
aefb4fb1
//! dlfcn implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/dlfcn.h.html
use
core
::{
ptr
,
str
};
use
core
::
sync
::
atomic
::{
AtomicUsize
,
ATOMIC_USIZE_INIT
,
Ordering
};
use
c_str
::
CStr
;
use
platform
::
types
::
*
;
...
...
@@ -10,6 +11,11 @@ pub const RTLD_NOW: c_int = 0x0002;
pub
const
RTLD_GLOBAL
:
c_int
=
0x0100
;
pub
const
RTLD_LOCAL
:
c_int
=
0x0000
;
static
ERROR_NOT_SUPPORTED
:
&
'static
CStr
=
c_str!
(
"dlfcn not supported"
);
#[thread_local]
static
ERROR
:
AtomicUsize
=
ATOMIC_USIZE_INIT
;
#[repr(C)]
pub
struct
Dl_info
{
dli_fname
:
*
const
c_char
,
...
...
@@ -29,14 +35,32 @@ pub unsafe extern "C" fn dladdr(addr: *mut c_void, info: *mut Dl_info) -> c_int
#[no_mangle]
pub
unsafe
extern
"C"
fn
dlopen
(
filename
:
*
const
c_char
,
flags
:
c_int
)
->
*
mut
c_void
{
let
filename_cstr
=
CStr
::
from_ptr
(
filename
);
let
filename_str
=
str
::
from_utf8_unchecked
(
filename_cstr
.to_bytes
());
eprintln!
(
"dlopen({}, {:#>04X})"
,
filename_str
,
flags
);
ptr
::
null_mut
()
let
filename_opt
=
if
filename
.is_null
()
{
None
}
else
{
Some
(
str
::
from_utf8_unchecked
(
CStr
::
from_ptr
(
filename
)
.to_bytes
()))
};
eprintln!
(
"dlopen({:?}, {:#>04x})"
,
filename_opt
,
flags
);
if
let
Some
(
filename
)
=
filename_opt
{
ERROR
.store
(
ERROR_NOT_SUPPORTED
.as_ptr
()
as
usize
,
Ordering
::
SeqCst
);
ptr
::
null_mut
()
}
else
{
1
as
*
mut
c_void
}
}
#[no_mangle]
pub
extern
"C"
fn
dlsym
(
handle
:
*
mut
c_void
,
symbol
:
*
const
c_char
)
->
*
mut
c_void
{
pub
unsafe
extern
"C"
fn
dlsym
(
handle
:
*
mut
c_void
,
symbol
:
*
const
c_char
)
->
*
mut
c_void
{
let
symbol_opt
=
if
symbol
.is_null
()
{
None
}
else
{
Some
(
str
::
from_utf8_unchecked
(
CStr
::
from_ptr
(
symbol
)
.to_bytes
()))
};
eprintln!
(
"dlsym({:p}, {:?})"
,
handle
,
symbol_opt
);
ptr
::
null_mut
()
}
...
...
@@ -47,5 +71,5 @@ pub extern "C" fn dlclose(handle: *mut c_void) -> c_int {
#[no_mangle]
pub
extern
"C"
fn
dlerror
()
->
*
mut
c_char
{
ptr
::
null_mut
()
ERROR
.swap
(
0
,
Ordering
::
SeqCst
)
as
*
mut
c_char
}
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