Merge remote-tracking branch

'origin/GP-3247_PR-5061_cyberkaida_lldb-documentation'
(Closes #5061)
This commit is contained in:
Ryan Kurtz
2023-03-24 11:34:11 -04:00
3 changed files with 78 additions and 0 deletions
@@ -1,5 +1,9 @@
To use the LLDB agent in Ghidra, you will need to build the JNI interface to the LLDB Scripting Bridge.
If you are using the distribution (vs. source) and wish to use the default swig files included (LLDB v14), you can use the
macos_debugger_lldb_build_from_brew script in this same directory, kindly provide by @cyberkaida. Make sure a 7.x version
of gradle is in your path, and you've defined GHIDRA_INSTALL_DIR.
To do this:
(1) check the version for your copy of lldb:
lldb --version
@@ -45,6 +45,7 @@ sourceSets {
rootProject.assembleDistribution {
from (this.project.projectDir.toString()) {
include "src/**"
include "*.sh"
include "*.txt"
into { getZipPath(this.project) }
}
@@ -0,0 +1,73 @@
#!/usr/bin/env bash
## ###
# IP: GHIDRA
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##
# This script will download lldb from homebrew and
# build the Ghidra JNI bindings for this version of
# lldb. It will then patch your Ghidra distribution
# to use these built libraries.
set -ex
if [ -z "${GHIDRA_INSTALL_DIR}" ]; then
echo "Please set the GHIDRA_INSTALL_DIR environment variable to your Ghidra install location"
exit 1
fi
if [ ! -z "${GHIDRA_INSTALL_DIR}" ]; then
pushd "${GHIDRA_INSTALL_DIR}/Ghidra/Debug/Debugger-swig-lldb"
fi
# Pin to 14, as this is what Ghidra's built in bindings are built against
LLVM_VERSION="14"
# Install llvm and unpack the source code for this version, patched
# with the brew patches
brew install llvm@${LLVM_VERSION}
LLVM_TEMP_DIR=$(mktemp -d)
# Download the source code brew used to build llvm, including
# brew specific patches.
brew unpack --patch --destdir ${LLVM_TEMP_DIR} llvm@${LLVM_VERSION}
export LLVM_HOME="$(echo ${LLVM_TEMP_DIR}/llvm@${LLVM_VERSION}-*)"
# Set the appropriate build variables to link and compile the
# liblldb-java library below.
BREW_LLVM="$(brew --prefix llvm@${LLVM_VERSION})"
export LDFLAGS="-L${BREW_LLVM}/lib/c++ -Wl,-rpath,${BREW_LLVM}/lib/c++,-L${BREW_LLVM}/lib"
export PATH="${BREW_LLVM}/bin:$PATH"
export CPPFLAGS="-I${BREW_LLVM}/include"
export LLVM_BUILD="$(echo ${BREW_LLVM})"
# Build native components
gradle buildNatives
# Build only the library required for our architecture.
# The brew llvm package installs a thinned binary containing
# only the native architecture of your machine.
if [ $(arch) == "arm64" ]; then
gradle :Debugger-swig-lldb:linkMainMac_arm_64SharedLibrary
export LIBLLDB_JAVA_DIR=Ghidra/Debug/Debugger-swig-lldb/build/os/mac_arm_64/
else
gradle :Debugger-swig-lldb:linkMainMac_x86_64SharedLibrary
export LIBLLDB_JAVA_DIR=Ghidra/Debug/Debugger-swig-lldb/build/os/mac_x86_64/
fi
# Patch the launch.properties with our library location
LAUNCH_PROPERTIES=${GHIDRA_INSTALL_DIR}/support/launch.properties
sed -i '' /llvm/d ${LAUNCH_PROPERTIES}
echo "VMARGS=-Djava.library.path=${GHIDRA_INSTALL_DIR}/${LIBLLDB_JAVA_DIR}:${BREW_LLVM}/lib" >> ${LAUNCH_PROPERTIES}