Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle radare2 inside the macOS app #209

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

prodrigestivill
Copy link
Collaborator

@prodrigestivill prodrigestivill commented Jan 12, 2025

Reuse the radare2.pkg build but moving to the corresponding folders.

R2_BINDIR="${APPDIR}/Contents/Helpers"
R2_LIBDIR="${APPDIR}/Contents/Frameworks"
R2_LIBR_PLUGINS="${APPDIR}/Contents/PlugIns/radare2" # only the binaries
R2_PREFIX="${APPDIR}/Contents/Resources/radare2"

Also R2_PREFIX keeps the typical folder structure thanks to symlinks.
It has been found some traces of this in the cpp code, but I opted to reimplement using environment variables at application start, so running any other radare2 command will work from inside iaito.

Also include latest r2ai-decai release.

@prodrigestivill
Copy link
Collaborator Author

The code that has been found, this has been re-adapted:

#ifdef Q_OS_MACOS
{
auto r2prefix = QDir(QCoreApplication::applicationDirPath()); // Contents/MacOS
r2prefix.cdUp(); // Contents
r2prefix.cd("Resources/r2"); // Contents/Resources/r2
auto sleighHome = r2prefix;
sleighHome.cd("share/radare2/plugins/r2ghidra_sleigh"); // Contents/Resources/r2/share/radare2/plugins/r2ghidra_sleigh
Core()->setConfig("r2ghidra.sleighhome", sleighHome.absolutePath());
auto r2decHome = r2prefix;
r2decHome.cd("share/radare2/plugins/r2dec-js"); // Contents/Resources/r2/share/radare2/plugins/r2dec-js
qputenv("R2DEC_HOME", r2decHome.absolutePath().toLocal8Bit());
}
#endif

Also this other code has been removed to cleanup a little bit:

iaito/src/core/Iaito.cpp

Lines 220 to 226 in 31a1203

#else // MACOS_R2_BUNDLED \
// Executable is in Contents/MacOS, prefix is Contents/Resources/r2
prefix.cdUp();
prefix.cd("Resources");
prefix.cd("r2");
qInfo() << "Setting r2 prefix =" << prefix.absolutePath() << " for macOS Application Bundle.";
#endif

@prodrigestivill
Copy link
Collaborator Author

prodrigestivill commented Jan 12, 2025

Seams it fails in macos arm64 with:

install_name_tool: changing install names or rpaths can't be redone for:
libr_egg.5.9.8.dylib (for architecture arm64) because larger updated load commands do not fit
(the program must be relinked, and you may need to use -headerpad or -headerpad_max_install_names)

@prodrigestivill
Copy link
Collaborator Author

This will fail for macOS ARM64 until radare2 have a release pkg with this radareorg/radare2#23885 flags in it.

@prodrigestivill prodrigestivill force-pushed the bundle-radare2 branch 4 times, most recently from 60af097 to 96f8048 Compare January 25, 2025 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

iaito_5.9.2_m1.dmg is not working
1 participant