瀏覽代碼

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 4 年之前
父節點
當前提交
1b10c3d246
共有 1 個文件被更改,包括 3 次插入3 次删除
  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) => {