Prioterize search path instead of overwriting it.

Current LD_LIBRARY_PATH implementation overwrites the original search
path, which is not the best idea, instead this patch would check
LD_LIBRARY_PATH first and if it didn't find the libraries it is looking
for, then it will search the original search path
This commit is contained in:
oddcoder
2020-06-01 11:41:19 +02:00
parent c7910a8754
commit 1b10c3d246
+3 -3
View File
@@ -138,8 +138,8 @@ pub extern "C" fn relibc_ld_so_start(sp: &'static mut Stack, ld_entry: usize) ->
// Some variables that will be overridden by environment and auxiliary vectors
let library_path = match envs.get("LD_LIBRARY_PATH") {
Some(lib_path) => lib_path,
None => "/lib",
Some(lib_path) => lib_path.to_owned() + ":/lib",
None => "/lib".to_owned(),
};
let path = if is_manual {
@@ -178,7 +178,7 @@ pub extern "C" fn relibc_ld_so_start(sp: &'static mut Stack, ld_entry: usize) ->
}
pr
};
let mut linker = Linker::new(library_path, false);
let mut linker = Linker::new(&library_path, false);
match linker.load(&path, &path) {
Ok(()) => (),
Err(err) => {