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
Container Registry
Model registry
Operate
Environments
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
Peter Limkilde Svendsen
relibc
Commits
2cbc78f2
Verified
Commit
2cbc78f2
authored
5 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Add linker pointer
parent
36eb5611
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/ld_so/start.rs
+8
-1
8 additions, 1 deletion
src/ld_so/start.rs
src/ld_so/tcb.rs
+8
-1
8 additions, 1 deletion
src/ld_so/tcb.rs
src/platform/pte.rs
+11
-1
11 additions, 1 deletion
src/platform/pte.rs
with
27 additions
and
3 deletions
src/ld_so/start.rs
+
8
−
1
View file @
2cbc78f2
// Start code adapted from https://gitlab.redox-os.org/redox-os/relibc/blob/master/src/start.rs
// Start code adapted from https://gitlab.redox-os.org/redox-os/relibc/blob/master/src/start.rs
use
crate
::{
c_str
::
CStr
,
header
::
unistd
,
platform
::
types
::
c_char
,
start
::
Stack
};
use
alloc
::
boxed
::
Box
;
use
crate
::{
c_str
::
CStr
,
header
::
unistd
,
platform
::
types
::
c_char
,
start
::
Stack
,
sync
::
mutex
::
Mutex
};
use
super
::
linker
::
Linker
;
use
super
::
linker
::
Linker
;
use
super
::
tcb
::
Tcb
;
#[no_mangle]
#[no_mangle]
pub
extern
"C"
fn
relibc_ld_so_start
(
sp
:
&
'static
mut
Stack
)
->
usize
{
pub
extern
"C"
fn
relibc_ld_so_start
(
sp
:
&
'static
mut
Stack
)
->
usize
{
...
@@ -122,6 +125,10 @@ pub extern "C" fn relibc_ld_so_start(sp: &'static mut Stack) -> usize {
...
@@ -122,6 +125,10 @@ pub extern "C" fn relibc_ld_so_start(sp: &'static mut Stack) -> usize {
}
}
};
};
if
let
Some
(
tcb
)
=
unsafe
{
Tcb
::
current
()
}
{
tcb
.linker_ptr
=
Box
::
into_raw
(
Box
::
new
(
Mutex
::
new
(
linker
)));
}
eprintln!
(
"ld.so: entry '{}': {:#x}"
,
path
,
entry
);
eprintln!
(
"ld.so: entry '{}': {:#x}"
,
path
,
entry
);
entry
entry
}
}
This diff is collapsed.
Click to expand it.
src/ld_so/tcb.rs
+
8
−
1
View file @
2cbc78f2
...
@@ -2,7 +2,11 @@ use alloc::boxed::Box;
...
@@ -2,7 +2,11 @@ use alloc::boxed::Box;
use
core
::{
mem
,
ops
::
Range
,
ptr
,
slice
};
use
core
::{
mem
,
ops
::
Range
,
ptr
,
slice
};
use
goblin
::
error
::{
Error
,
Result
};
use
goblin
::
error
::{
Error
,
Result
};
use
crate
::
header
::
sys_mman
;
use
crate
::{
header
::
sys_mman
,
ld_so
::
linker
::
Linker
,
sync
::
mutex
::
Mutex
,
};
use
super
::
PAGE_SIZE
;
use
super
::
PAGE_SIZE
;
...
@@ -43,6 +47,8 @@ pub struct Tcb {
...
@@ -43,6 +47,8 @@ pub struct Tcb {
pub
masters_ptr
:
*
mut
Master
,
pub
masters_ptr
:
*
mut
Master
,
/// Size of the masters list in bytes (multiple of mem::size_of::<Master>())
/// Size of the masters list in bytes (multiple of mem::size_of::<Master>())
pub
masters_len
:
usize
,
pub
masters_len
:
usize
,
/// Pointer to dynamic linker
pub
linker_ptr
:
*
const
Mutex
<
Linker
>
,
}
}
impl
Tcb
{
impl
Tcb
{
...
@@ -61,6 +67,7 @@ impl Tcb {
...
@@ -61,6 +67,7 @@ impl Tcb {
tcb_len
:
tcb_page
.len
(),
tcb_len
:
tcb_page
.len
(),
masters_ptr
:
ptr
::
null_mut
(),
masters_ptr
:
ptr
::
null_mut
(),
masters_len
:
0
,
masters_len
:
0
,
linker_ptr
:
ptr
::
null
(),
},
},
);
);
...
...
This diff is collapsed.
Click to expand it.
src/platform/pte.rs
+
11
−
1
View file @
2cbc78f2
...
@@ -8,7 +8,10 @@ use core::{
...
@@ -8,7 +8,10 @@ use core::{
use
crate
::{
use
crate
::{
header
::{
sys_mman
,
time
::
timespec
},
header
::{
sys_mman
,
time
::
timespec
},
ld_so
::
tcb
::{
Master
,
Tcb
},
ld_so
::{
linker
::
Linker
,
tcb
::{
Master
,
Tcb
},
},
platform
::{
platform
::{
types
::{
c_int
,
c_uint
,
c_void
,
pid_t
,
size_t
},
types
::{
c_int
,
c_uint
,
c_void
,
pid_t
,
size_t
},
Pal
,
Sys
,
Pal
,
Sys
,
...
@@ -72,6 +75,7 @@ unsafe extern "C" fn pte_osThreadShim(
...
@@ -72,6 +75,7 @@ unsafe extern "C" fn pte_osThreadShim(
tls_size
:
usize
,
tls_size
:
usize
,
tls_masters_ptr
:
*
mut
Master
,
tls_masters_ptr
:
*
mut
Master
,
tls_masters_len
:
usize
,
tls_masters_len
:
usize
,
tls_linker_ptr
:
*
const
Mutex
<
Linker
>
,
)
{
)
{
// The kernel allocated TLS does not have masters set, so do not attempt to copy it.
// The kernel allocated TLS does not have masters set, so do not attempt to copy it.
// It will be copied by the kernel.
// It will be copied by the kernel.
...
@@ -79,6 +83,7 @@ unsafe extern "C" fn pte_osThreadShim(
...
@@ -79,6 +83,7 @@ unsafe extern "C" fn pte_osThreadShim(
let
tcb
=
Tcb
::
new
(
tls_size
)
.unwrap
();
let
tcb
=
Tcb
::
new
(
tls_size
)
.unwrap
();
tcb
.masters_ptr
=
tls_masters_ptr
;
tcb
.masters_ptr
=
tls_masters_ptr
;
tcb
.masters_len
=
tls_masters_len
;
tcb
.masters_len
=
tls_masters_len
;
tcb
.linker_ptr
=
tls_linker_ptr
;
tcb
.copy_masters
()
.unwrap
();
tcb
.copy_masters
()
.unwrap
();
tcb
.activate
();
tcb
.activate
();
}
}
...
@@ -125,7 +130,11 @@ pub unsafe extern "C" fn pte_osThreadCreate(
...
@@ -125,7 +130,11 @@ pub unsafe extern "C" fn pte_osThreadCreate(
*
stack
=
value
;
*
stack
=
value
;
};
};
// Stack must be 128-bit aligned for SSE
push
(
0
);
if
let
Some
(
tcb
)
=
Tcb
::
current
()
{
if
let
Some
(
tcb
)
=
Tcb
::
current
()
{
push
(
tcb
.linker_ptr
as
usize
);
push
(
tcb
.masters_len
);
push
(
tcb
.masters_len
);
push
(
tcb
.masters_ptr
as
usize
);
push
(
tcb
.masters_ptr
as
usize
);
push
(
tcb
.tls_len
);
push
(
tcb
.tls_len
);
...
@@ -133,6 +142,7 @@ pub unsafe extern "C" fn pte_osThreadCreate(
...
@@ -133,6 +142,7 @@ pub unsafe extern "C" fn pte_osThreadCreate(
push
(
0
);
push
(
0
);
push
(
0
);
push
(
0
);
push
(
0
);
push
(
0
);
push
(
0
);
}
}
push
(
mutex
as
usize
);
push
(
mutex
as
usize
);
...
...
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