4040echo  " " 
4141echo  " === Relocation Count Comparison ===" 
4242
43- #  Detect OS and use appropriate tool 
43+ #  Determine os-specific reloc config 
4444if  [[ " $OSTYPE " ==  " darwin" *  ]];  then 
4545    #  macOS
46-     otool -rv " $NIX_LIB " >  " $TMPDIR /nix-relocs.txt" 
47-     otool -rv " $CARGO_LIB " >  " $TMPDIR /cargo-relocs.txt" 
46+     RELOC_CMD=" otool -rv" 
4847    RELOC_PATTERN=' [A-Z_]+_RELOC_[A-Z0-9_]+' 
4948else 
5049    #  Linux
51-     readelf -r " $NIX_LIB " >  " $TMPDIR /nix-relocs.txt" 
52-     readelf -r " $CARGO_LIB " >  " $TMPDIR /cargo-relocs.txt" 
50+     RELOC_CMD=" readelf -r" 
5351    RELOC_PATTERN=' R_[A-Z0-9_]+' 
5452fi 
5553
54+ $RELOC_CMD  " $NIX_LIB " >  " $TMPDIR /nix-relocs.txt" 
55+ $RELOC_CMD  " $CARGO_LIB " >  " $TMPDIR /cargo-relocs.txt" 
56+ 
5657NIX_RELOCS=$( wc -l <  " $TMPDIR /nix-relocs.txt" ) 
5758CARGO_RELOCS=$( wc -l <  " $TMPDIR /cargo-relocs.txt" ) 
5859echo  " Nix build:   $NIX_RELOCS  relocation entries" 
@@ -67,13 +68,8 @@ echo ""
6768echo  " === Relocation Type Comparison ===" 
6869
6970#  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 
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" 
7773
7874if  diff " $TMPDIR /nix-reloc-types.txt" " $TMPDIR /cargo-reloc-types.txt" >  /dev/null;  then 
7975    echo  " ✅ Relocation types match" 
0 commit comments