Browse Source

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
oddcoder 5 năm trước cách đây
mục cha
commit
1b10c3d246
1 tập tin đã thay đổi với 3 bổ sung3 xóa
  1. 3 3
      src/ld_so/start.rs

+ 3 - 3
src/ld_so/start.rs

@@ -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) => {