Added gdb and gdbserver recipes

This commit is contained in:
takeshix 2018-04-19 23:32:21 +02:00
parent ac79dfa852
commit bfc93fd919
8 changed files with 378 additions and 14 deletions

View file

@ -25,6 +25,15 @@ Precompiled versions of socat are available for the following operating systems/
* [Linux x86](bin/linux/x86) * [Linux x86](bin/linux/x86)
* [Linux x86_64](bin/linux/x86_64) * [Linux x86_64](bin/linux/x86_64)
## GDB
Precompiled versions of `gdb` and `gdbserver` are available for the following operating systems/architecturs:
* [Linux x86](bin/linux/x86)
* [Linux x86_64](bin/linux/x86_64)
* [Linux armhf](bin/linux/armhf)
* [Linux aarch64](bin/linux/aarch64)
# Building with Vagrant # Building with Vagrant
The recipes are supposed to be built in Docker containers. In case Docker is not available, it is recommended to use Vagrant to built everything in a VM, e.g. Nmap for Linux x86: The recipes are supposed to be built in Docker containers. In case Docker is not available, it is recommended to use Vagrant to built everything in a VM, e.g. Nmap for Linux x86:

View file

@ -13,3 +13,16 @@ sudo docker run -v $(pwd)/output:/output static-toolbox-gdb-x86
sudo docker build -t static-toolbox-gdb-x86-64 . sudo docker build -t static-toolbox-gdb-x86-64 .
sudo docker run -v $(pwd)/output:/output static-toolbox-gdb-x86-64 sudo docker run -v $(pwd)/output:/output static-toolbox-gdb-x86-64
``` ```
## Build Linux armhf
```
sudo docker build -t static-toolbox-gdb-armhf .
sudo docker run -v $(pwd)/output:/output static-toolbox-gdb-armhf
```
## Build Linux aarch64
```
sudo docker build -t static-toolbox-gdb-aarch64 .
sudo docker run -v $(pwd)/output:/output static-toolbox-gdb-aarch64

View file

@ -0,0 +1,25 @@
FROM ubuntu:xenial
RUN apt-get update && \
apt upgrade -yy && \
apt install -yy \
automake \
cmake \
build-essential \
checkinstall \
libgmp-dev \
libmpfr-dev \
libmpc-dev \
wget \
git \
pkg-config \
python \
binutils-dev \
lib32z1-dev \
byacc \
flex \
texinfo \
qemu
RUN mkdir /build
ADD . /build
RUN chmod +x /build/build_aarch64.sh
CMD /build/build_aarch64.sh

View file

@ -0,0 +1,146 @@
#!/bin/bash
#set -e
set -o pipefail
set -x
NMAP_COMMIT=
fetch(){
if [ ! -d "/build/musl" ];then
#git clone https://github.com/GregorR/musl-cross.git /build/musl
git clone https://github.com/takeshixx/musl-cross.git /build/musl
fi
if [ ! -d "/build/binutils-gdb" ];then
git clone https://github.com/bminor/binutils-gdb.git /build/binutils-gdb
fi
cd /build/binutils-gdb
git checkout binutils-2_30
cd -
}
build_musl_aarch64() {
cd /build/musl
git clean -fdx
echo "ARCH=arm64" >> config.sh
echo "GCC_BUILTIN_PREREQS=yes" >> config.sh
echo "TRIPLE=aarch64-linux-musleabi" >> config.sh
./build.sh
echo "[+] Finished building musl-cross aarch64"
}
build_gdb_aarch64() {
cd /build/binutils-gdb
git clean -fdx
make clean || true
cd /build/binutils-gdb/bfd
CC='/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-gcc -static -fPIC' \
CXX='/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-ld \
./configure \
--host=x86_64-linux-gnu \
--target=aarch64-none-linux-gnueabi
make -j4
cd /build/binutils-gdb/readline
CC='/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-gcc -static -fPIC' \
CXX='/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-ld \
./configure \
--host=x86_64-linux-gnu \
--target=aarch64-none-linux-gnueabi \
--disable-shared \
--enable-static
make -j4
cd /build/binutils-gdb/opcodes
CC='/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-gcc -static -fPIC' \
CXX='/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-ld \
./configure \
--host=x86_64-linux-gnu \
--target=aarch64-none-linux-gnueabi \
--disable-shared \
--enable-static
make -j4
cd /build/binutils-gdb/libiberty
CC='/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-gcc -static -fPIC' \
CXX='/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-ld \
./configure \
--host=x86_64-linux-gnu \
--target=aarch64-none-linux-gnueabi \
--disable-shared \
--enable-static
make -j4
cd /build/binutils-gdb/libdecnumber
CC='/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-gcc -static -fPIC' \
CXX='/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-ld \
./configure \
--host=x86_64-linux-gnu \
--target=aarch64-none-linux-gnueabi \
--disable-shared \
--enable-static
make -j4
cd /build/binutils-gdb/zlib
CC='/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-gcc -static -fPIC' \
CXX='/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-g++ -static -static-libstdc++ -fPIC' \
cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_LINKER=/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-ld .
make zlibstatic
cd /build/binutils-gdb/gdb
CC='/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-gcc -static -fPIC' \
CXX='/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-ld \
LDFLAGS='-static' \
./configure \
--enable-static=yes \
--host=x86_64-linux-gnu \
--target=aarch64-none-linux-gnueabi \
--disable-interprocess-agent
make -j4
cd /build/binutils-gdb/gdb/gdbserver/
CC='/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-gcc -static -fPIC' \
CXX='/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-ld \
LDFLAGS='-static' \
./configure \
--enable-static=yes \
--host=x86_64-linux-gnu \
--target=aarch64-none-linux-gnueabi \
--disable-interprocess-agent
make -j4
/opt/cross/aarch64-linux-musleabi/bin/aarch64-linux-musleabi-strip /build/binutils-gdb/gdb/gdb /build/binutils-gdb/gdb/gdbserver/gdbserver
}
build_aarch64(){
OUT_DIR=/output/`uname | tr 'A-Z' 'a-z'`/aarch64
mkdir -p $OUT_DIR
build_musl_aarch64
build_gdb_aarch64
GDB_VERSION=
GDBSERVER_VERSION=
if which qemu-aarch64 >/dev/null;then
GDB_VERSION="-$(qemu-aarch64 /build/binutils-gdb/gdb/gdb --version |head -n1 |awk '{print $4}')"
GDBSERVER_VERSION="-$(qemu-aarch64 /build/binutils-gdb/gdb/gdbserver/gdbserver --version |head -n1 |awk '{print $4}')"
fi
cp /build/binutils-gdb/gdb/gdb "${OUT_DIR}/gdb-aarch64${GDB_VERSION}"
cp /build/binutils-gdb/gdb/gdbserver/gdbserver "${OUT_DIR}/gdbserver-aarch64${GDBSERVER_VERSION}"
echo "[+] Finished building aarch64"
}
main() {
if [ ! -d "/output" ];then
echo "[-] /output does not exist, creating it"
mkdir /output
fi
fetch
build_aarch64
}
main

View file

@ -0,0 +1,25 @@
FROM ubuntu:xenial
RUN apt-get update && \
apt upgrade -yy && \
apt install -yy \
automake \
cmake \
build-essential \
checkinstall \
libgmp-dev \
libmpfr-dev \
libmpc-dev \
wget \
git \
pkg-config \
python \
binutils-dev \
lib32z1-dev \
byacc \
flex \
texinfo \
qemu
RUN mkdir /build
ADD . /build
RUN chmod +x /build/build_armhf.sh
CMD /build/build_armhf.sh

View file

@ -0,0 +1,148 @@
#!/bin/bash
#set -e
set -o pipefail
set -x
NMAP_COMMIT=
fetch(){
if [ ! -d "/build/musl" ];then
#git clone https://github.com/GregorR/musl-cross.git /build/musl
git clone https://github.com/takeshixx/musl-cross.git /build/musl
fi
if [ ! -d "/build/binutils-gdb" ];then
git clone https://github.com/bminor/binutils-gdb.git /build/binutils-gdb
fi
cd /build/binutils-gdb
git checkout binutils-2_30
cd -
}
build_musl_armhf() {
cd /build/musl
git clean -fdx
echo "ARCH=arm" >> config.sh
echo "GCC_BUILTIN_PREREQS=yes" >> config.sh
echo "TRIPLE=arm-linux-musleabihf" >> config.sh
echo "GCC_BOOTSTRAP_CONFFLAGS='--with-arch=armv7-a --with-float=hard --with-fpu=vfpv3-d16'" >> config.sh
echo "GCC_CONFFLAGS='--with-arch=armv7-a --with-float=hard --with-fpu=vfpv3-d16'" >> config.sh
./build.sh
echo "[+] Finished building musl-cross armhf"
}
build_gdb_armhf() {
cd /build/binutils-gdb
git clean -fdx
make clean || true
cd /build/binutils-gdb/bfd
CC='/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-gcc -static -fPIC' \
CXX='/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-ld \
./configure \
--host=x86_64-linux-gnu \
--target=arm-none-linux-gnueabi
make -j4
cd /build/binutils-gdb/readline
CC='/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-gcc -static -fPIC' \
CXX='/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-ld \
./configure \
--host=x86_64-linux-gnu \
--target=arm-none-linux-gnueabi \
--disable-shared \
--enable-static
make -j4
cd /build/binutils-gdb/opcodes
CC='/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-gcc -static -fPIC' \
CXX='/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-ld \
./configure \
--host=x86_64-linux-gnu \
--target=arm-none-linux-gnueabi \
--disable-shared \
--enable-static
make -j4
cd /build/binutils-gdb/libiberty
CC='/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-gcc -static -fPIC' \
CXX='/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-ld \
./configure \
--host=x86_64-linux-gnu \
--target=arm-none-linux-gnueabi \
--disable-shared \
--enable-static
make -j4
cd /build/binutils-gdb/libdecnumber
CC='/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-gcc -static -fPIC' \
CXX='/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-ld \
./configure \
--host=x86_64-linux-gnu \
--target=arm-none-linux-gnueabi \
--disable-shared \
--enable-static
make -j4
cd /build/binutils-gdb/zlib
CC='/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-gcc -static -fPIC' \
CXX='/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-g++ -static -static-libstdc++ -fPIC' \
cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_LINKER=/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-ld .
make zlibstatic
cd /build/binutils-gdb/gdb
CC='/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-gcc -static -fPIC' \
CXX='/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-ld \
LDFLAGS='-static' \
./configure \
--enable-static=yes \
--host=x86_64-linux-gnu \
--target=arm-none-linux-gnueabi \
--disable-interprocess-agent
make -j4
cd /build/binutils-gdb/gdb/gdbserver/
CC='/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-gcc -static -fPIC' \
CXX='/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-ld \
LDFLAGS='-static' \
./configure \
--host=x86_64-linux-gnu \
--target=arm-none-linux-gnueabi \
--enable-static=yes \
--disable-interprocess-agent
make -j4
/opt/cross/arm-linux-musleabihf/bin/arm-linux-musleabihf-strip /build/binutils-gdb/gdb/gdb /build/binutils-gdb/gdb/gdbserver/gdbserver
}
build_armhf(){
OUT_DIR=/output/`uname | tr 'A-Z' 'a-z'`/armhf
mkdir -p $OUT_DIR
build_musl_armhf
build_gdb_armhf
GDB_VERSION=
GDBSERVER_VERSION=
if which qemu-arm >/dev/null;then
GDB_VERSION="-$(qemu-arm /build/binutils-gdb/gdb/gdb --version |head -n1 |awk '{print $4}')"
GDBSERVER_VERSION="-$(qemu-arm /build/binutils-gdb/gdb/gdbserver/gdbserver --version |head -n1 |awk '{print $4}')"
fi
cp /build/binutils-gdb/gdb/gdb "${OUT_DIR}/gdb-armhf${GDB_VERSION}"
cp /build/binutils-gdb/gdb/gdbserver/gdbserver "${OUT_DIR}/gdbserver-armhf${GDBSERVER_VERSION}"
echo "[+] Finished building armhf"
}
main() {
if [ ! -d "/output" ];then
echo "[-] /output does not exist, creating it"
mkdir /output
fi
fetch
build_armhf
}
main

View file

@ -15,7 +15,6 @@ fetch(){
cd /build/binutils-gdb cd /build/binutils-gdb
git checkout binutils-2_30 git checkout binutils-2_30
cd - cd -
GDB_COMMIT=$(cd /build/binutils-gdb/ && git rev-parse --short HEAD)
} }
build_musl_x86() { build_musl_x86() {
@ -112,14 +111,14 @@ build_gdb_x86() {
} }
build_x86(){ build_x86(){
OUT_DIR_x86=/output/`uname | tr 'A-Z' 'a-z'`/x86 OUT_DIR=/output/`uname | tr 'A-Z' 'a-z'`/x86
mkdir -p $OUT_DIR_x86 mkdir -p $OUT_DIR
build_musl_x86 build_musl_x86
build_gdb_x86 build_gdb_x86
GDB_VERSION=$(/build/binutils-gdb/gdb/gdb --version |head -n1 |awk '{print $4}') GDB_VERSION="-$(/build/binutils-gdb/gdb/gdb --version |head -n1 |awk '{print $4}')"
GDBSERVER_VERSION=$(/build/binutils-gdb/gdb/gdbserver/gdbserver --version |head -n1 |awk '{print $4}') GDBSERVER_VERSION="-$(/build/binutils-gdb/gdb/gdbserver/gdbserver --version |head -n1 |awk '{print $4}')"
cp /build/binutils-gdb/gdb/gdb "${OUT_DIR_x86}/gdb-${GDB_VERSION}-${GDB_COMMIT}" cp /build/binutils-gdb/gdb/gdb "${OUT_DIR}/gdb-x86${GDB_VERSION}"
cp /build/binutils-gdb/gdb/gdbserver/gdbserver "${OUT_DIR_x86}/gdbserver-${GDBSERVER_VERSION}-${GDB_COMMIT}" cp /build/binutils-gdb/gdb/gdbserver/gdbserver "${OUT_DIR}/gdbserver-x86${GDBSERVER_VERSION}"
echo "[+] Finished building x86" echo "[+] Finished building x86"
} }

View file

@ -15,7 +15,6 @@ fetch(){
cd /build/binutils-gdb cd /build/binutils-gdb
git checkout binutils-2_30 git checkout binutils-2_30
cd - cd -
GDB_COMMIT=$(cd /build/binutils-gdb/ && git rev-parse --short HEAD)
} }
build_musl_x86_64() { build_musl_x86_64() {
@ -110,14 +109,14 @@ build_gdb_x86_64() {
} }
build_x86_64(){ build_x86_64(){
OUT_DIR_x86_64=/output/`uname | tr 'A-Z' 'a-z'`/x86_64 OUT_DIR_x86=/output/`uname | tr 'A-Z' 'a-z'`/x86_64
mkdir -p $OUT_DIR_x86_64 mkdir -p $OUT_DIR_x86
build_musl_x86_64 build_musl_x86_64
build_gdb_x86_64 build_gdb_x86_64
GDB_VERSION=$(/build/binutils-gdb/gdb/gdb --version |head -n1 |awk '{print $4}') GDB_VERSION="-$(/build/binutils-gdb/gdb/gdb --version |head -n1 |awk '{print $4}')"
GDBSERVER_VERSION=$(/build/binutils-gdb/gdb/gdbserver/gdbserver --version |head -n1 |awk '{print $4}') GDBSERVER_VERSION="-$(/build/binutils-gdb/gdb/gdbserver/gdbserver --version |head -n1 |awk '{print $4}')"
cp /build/binutils-gdb/gdb/gdb "${OUT_DIR_x86_64}/gdb-${GDB_VERSION}-${GDB_COMMIT}" cp /build/binutils-gdb/gdb/gdb "${OUT_DIR}/gdb-x86_64${GDB_VERSION}"
cp /build/binutils-gdb/gdb/gdbserver/gdbserver "${OUT_DIR_x86_64}/gdbserver-${GDBSERVER_VERSION}-${GDB_COMMIT}" cp /build/binutils-gdb/gdb/gdbserver/gdbserver "${OUT_DIR}/gdbserver-x86_64${GDBSERVER_VERSION}"
echo "[+] Finished building x86_64" echo "[+] Finished building x86_64"
} }