4040echo  " " 
4141echo  " === Relocation Count Comparison ===" 
4242
43- #  Detect OS and use appropriate tool 
43+ #  Determine os-specific reloc config 
4444if  [[ " $OSTYPE " ==  " darwin" *  ]];  then 
45-     #  macOS
46-     otool -rv " $NIX_LIB " >  " $TMPDIR /nix-relocs.txt" 
47-     otool -rv " $CARGO_LIB " >  " $TMPDIR /cargo-relocs.txt" 
45+     RELOC_CMD=" otool -rv" 
4846    RELOC_PATTERN=' [A-Z_]+_RELOC_[A-Z0-9_]+' 
4947else 
50-     #  Linux
51-     readelf -r " $NIX_LIB " >  " $TMPDIR /nix-relocs.txt" 
52-     readelf -r " $CARGO_LIB " >  " $TMPDIR /cargo-relocs.txt" 
48+     RELOC_CMD=" readelf -r" 
5349    RELOC_PATTERN=' R_[A-Z0-9_]+' 
5450fi 
5551
52+ $RELOC_CMD  " $NIX_LIB " >  " $TMPDIR /nix-relocs.txt" 
53+ $RELOC_CMD  " $CARGO_LIB " >  " $TMPDIR /cargo-relocs.txt" 
54+ 
5655NIX_RELOCS=$( wc -l <  " $TMPDIR /nix-relocs.txt" ) 
5756CARGO_RELOCS=$( wc -l <  " $TMPDIR /cargo-relocs.txt" ) 
5857echo  " Nix build:   $NIX_RELOCS  relocation entries" 
@@ -67,13 +66,8 @@ echo ""
6766echo  " === Relocation Type Comparison ===" 
6867
6968#  Use grep with -E for better portability (avoid -P which isn't available on macOS)
70- if  [[ " $OSTYPE " ==  " darwin" *  ]];  then 
71-     grep -Eo " $RELOC_PATTERN " " $TMPDIR /nix-relocs.txt" |  sort |  uniq -c >  " $TMPDIR /nix-reloc-types.txt" 
72-     grep -Eo " $RELOC_PATTERN " " $TMPDIR /cargo-relocs.txt" |  sort |  uniq -c >  " $TMPDIR /cargo-reloc-types.txt" 
73- else 
74-     grep -oP " $RELOC_PATTERN " " $TMPDIR /nix-relocs.txt" |  sort |  uniq -c >  " $TMPDIR /nix-reloc-types.txt" 
75-     grep -oP " $RELOC_PATTERN " " $TMPDIR /cargo-relocs.txt" |  sort |  uniq -c >  " $TMPDIR /cargo-reloc-types.txt" 
76- fi 
69+ grep -Eo " $RELOC_PATTERN " " $TMPDIR /nix-relocs.txt" |  sort |  uniq -c >  " $TMPDIR /nix-reloc-types.txt" 
70+ grep -Eo " $RELOC_PATTERN " " $TMPDIR /cargo-relocs.txt" |  sort |  uniq -c >  " $TMPDIR /cargo-reloc-types.txt" 
7771
7872if  diff " $TMPDIR /nix-reloc-types.txt" " $TMPDIR /cargo-reloc-types.txt" >  /dev/null;  then 
7973    echo  " ✅ Relocation types match" 
0 commit comments