Created
July 13, 2022 20:43
-
-
Save leoadberg/3ba413fbb6d8ee7b8dcc5006eda6e84e to your computer and use it in GitHub Desktop.
Patches the VTune Profiler to run on M1 Macs when profiling remotely
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash -e | |
# Change these as needed for other VTune versions | |
VTUNE="/Applications/Intel VTune Profiler 2020.app" | |
TOPATCH=( | |
"$VTUNE/Contents/Frameworks/libamplxe_dpihelpers_1.42.dylib" | |
) | |
for FILE in "${TOPATCH[@]}"; do | |
# Get addresses of all xacquire or xrelease instructions in binary | |
ADDRS=$(otool -xv "${FILE}" | egrep "xacquire|xrelease" | awk '{print $1}') | |
for ADDR in $ADDRS; do | |
# Overwrite each xacquire/xrelease with a 0x90 (NOP in x86) | |
printf '\x90' | dd bs=1 seek=$((16#$ADDR)) conv=notrunc of="${FILE}" | |
done | |
done | |
# Need to re-codesign the app | |
codesign -s - -f --deep "${VTUNE}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment