/gsym_yaml_repro.sh Secret
Created
August 2, 2024 20:20
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 | |
set -ex | |
# Global variable for LLVM toolchain path | |
TOOLCHAIN_PATH=[...] | |
# Switch to the script directory | |
cd "$(dirname "$0")" | |
# Create and clean 'out' directory | |
mkdir -p out | |
rm -rf out/* | |
# Generate C++ files | |
for i in {1..3}; do | |
cat << EOF > out/file_0${i}.cpp | |
extern "C" int my_func_0${i}( | |
int a, | |
int b) | |
{ | |
return | |
a | |
* | |
a | |
+ | |
b; | |
} | |
EOF | |
done | |
# Compile to object files with debug info | |
for i in {1..3}; do | |
${TOOLCHAIN_PATH}/bin/clang++ \ | |
-fno-unwind-tables -fno-asynchronous-unwind-tables \ | |
-target arm64-apple-macos -c -g out/file_0${i}.cpp -o out/file_0${i}.o | |
done | |
# Link object files to dylib using lld directly | |
${TOOLCHAIN_PATH}/bin/ld64.lld \ | |
-dylib \ | |
-arch arm64 \ | |
-platform_version macos 11.0 11.0 \ | |
-o out/libmyfuncs.dylib \ | |
--icf=all --keep-icf-stabs \ | |
-o out/mydylib out/file_01.o out/file_02.o out/file_03.o | |
# Create dsym with --flat option | |
"$TOOLCHAIN_PATH/bin/dsymutil" --flat out/mydylib -o out/mydylib.dSYM | |
# Convert dsym to yaml | |
"$TOOLCHAIN_PATH/bin/obj2yaml" out/mydylib.dSYM > out/mydylib.yaml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment