#!/usr/bin/sh # Create a new file to be patched binary=/usr/lib/systemd/systemd-volatile-root target=/usr/lib/systemd/systemd-volatile-root.reliant-profiling cp $binary $target # We must NOP calls to umount and rmdir hex_offsets=$(objdump -d "$binary" | grep -E 'call.*(umount|rmdir)' | awk '{ print $1 }' | tr -d ':') for hex_offset in $hex_offsets; do dec_offset=$(perl -le "print hex(\"$hex_offset\")") printf '\x90\x90\x90\x90\x90' | dd of="$target" bs=1 seek=$dec_offset conv=notrunc done # Verify the patch has succeeded for hex_offset in $hex_offsets; do echo -n "$hex_offset: " opcode=$(objdump -d "$target" | grep $hex_offset | awk '{ print $2 }') if [ "$opcode" -eq 90 ]; then echo "OK" else echo "FAIL" fi done