fortrangoingonforty/afs-ld / fdcd358

Browse files

Preserve mixed dylib load order

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
fdcd358c8e951506fc0456874a5928ad54e17a75
Parents
de7cc73
Tree
b67ff8e

3 changed files

StatusFile+-
M src/lib.rs 9 1
M tests/parity_corpus/strip_locals_exec/args.txt 7 0
M tests/parity_corpus/symtab_partition_exec/args.txt 7 0
src/lib.rsmodified
@@ -426,7 +426,14 @@ impl Linker {
426426
             );
427427
         }
428428
 
429
-        let mut load_paths = opts.inputs.clone();
429
+        let mut load_paths = Vec::new();
430
+        let mut positional_dylibs = Vec::new();
431
+        for path in &opts.inputs {
432
+            match path.extension().and_then(|ext| ext.to_str()) {
433
+                Some("dylib" | "tbd") => positional_dylibs.push(path.clone()),
434
+                _ => load_paths.push(path.clone()),
435
+            }
436
+        }
430437
         let mut dylib_load_kinds = std::collections::HashMap::new();
431438
         for name in &opts.library_names {
432439
             let path = resolve_library_input(opts, name)?;
@@ -445,6 +452,7 @@ impl Linker {
445452
             );
446453
             load_paths.push(path);
447454
         }
455
+        load_paths.extend(positional_dylibs);
448456
 
449457
         let mut inputs = Inputs::new();
450458
         let phase_started = Instant::now();
tests/parity_corpus/strip_locals_exec/args.txtmodified
@@ -1,5 +1,12 @@
11
 -arch
22
 arm64
3
+-platform_version
4
+macos
5
+@SDK_VERSION@
6
+@SDK_VERSION@
7
+-syslibroot
8
+@SDK_PATH@
9
+-lSystem
310
 -x
411
 -no_fixup_chains
512
 -e
tests/parity_corpus/symtab_partition_exec/args.txtmodified
@@ -1,5 +1,12 @@
11
 -arch
22
 arm64
3
+-platform_version
4
+macos
5
+@SDK_VERSION@
6
+@SDK_VERSION@
7
+-syslibroot
8
+@SDK_PATH@
9
+-lSystem
310
 -no_fixup_chains
411
 -e
512
 _main