Merge branch 'destructor' into 'master'

Call DSO destructors during exit()

See merge request redox-os/relibc!326
This commit is contained in:
Jeremy Soller
2021-01-05 23:02:07 +00:00
5 changed files with 19 additions and 8 deletions
+3
View File
@@ -21,6 +21,7 @@ use crate::{
unistd::{self, sysconf, _SC_PAGESIZE},
wchar::*,
},
ld_so,
platform::{self, types::*, Pal, Sys},
};
@@ -292,6 +293,8 @@ pub unsafe extern "C" fn exit(status: c_int) {
_fini();
ld_so::fini();
pthread_terminate();
Sys::exit(status);
+6
View File
@@ -113,6 +113,12 @@ impl Linker {
}
}
pub fn fini(&self) {
for obj in self.objects.values() {
obj.run_fini();
}
}
fn load_object(
&mut self,
path: &str,
+9
View File
@@ -108,3 +108,12 @@ pub unsafe fn init(sp: &'static Stack) {
#[cfg(target_os = "redox")]
pub unsafe fn init(_sp: &'static Stack) {}
pub unsafe fn fini() {
if let Some(tcb) = Tcb::current() {
if tcb.linker_ptr != ptr::null_mut() {
let linker = (&*tcb.linker_ptr).lock();
linker.fini();
}
}
}
-1
View File
@@ -34,7 +34,6 @@ next: pop rsi
xor r11, r11
fninit
jmp rax
# TODO: Loader::fini() should be called about here
"
:
:
+1 -7
View File
@@ -6,6 +6,7 @@ EXPECT_NAMES=\
assert \
constructor \
ctype \
destructor \
dirent/scandir \
errno \
error \
@@ -119,11 +120,6 @@ EXPECT_NAMES=\
# mkfifo
# netdb/netdb \
# need to call fini in ld_so's _start
STATIC_ONLY_NAMES=\
destructor
DYNAMIC_ONLY_NAMES=\
dlfcn
@@ -155,11 +151,9 @@ NAMES=\
# time/times
BINS=$(patsubst %,bins_static/%,$(NAMES))
BINS+=$(patsubst %,bins_static/%,$(STATIC_ONLY_NAMES))
BINS+=$(patsubst %,bins_dynamic/%,$(NAMES))
BINS+=$(patsubst %,bins_dynamic/%,$(DYNAMIC_ONLY_NAMES))
EXPECT_BINS=$(patsubst %,bins_static/%,$(EXPECT_NAMES))
EXPECT_BINS+=$(patsubst %,bins_static/%,$(STATIC_ONLY_NAMES))
EXPECT_BINS+=$(patsubst %,bins_dynamic/%,$(EXPECT_NAMES))
EXPECT_BINS+=$(patsubst %,bins_dynamic/%,$(DYNAMIC_ONLY_NAMES))