Added gdb x86 and x86_64 recipes

This commit is contained in:
takeshix 2018-04-19 21:17:04 +02:00
parent e0ffd8e604
commit a6dbd2719c
5 changed files with 331 additions and 0 deletions

15
recipes/gdb/README.md Normal file
View file

@ -0,0 +1,15 @@
# GDB
## Build Linux x86
```
sudo docker build -t static-toolbox-gdb-x86 .
sudo docker run -v $(pwd)/output:/output static-toolbox-gdb-x86
```
## Build Linux x86_64
```
sudo docker build -t static-toolbox-gdb-x86-64 .
sudo docker run -v $(pwd)/output:/output static-toolbox-gdb-x86-64
```

View file

@ -0,0 +1,24 @@
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
RUN mkdir /build
ADD . /build
RUN chmod +x /build/build_x86.sh
CMD /build/build_x86.sh

View file

@ -0,0 +1,135 @@
#!/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 -
GDB_COMMIT=$(cd /build/binutils-gdb/ && git rev-parse --short HEAD)
}
build_musl_x86() {
cd /build/musl
git clean -fdx
echo "ARCH=i486" >> config.sh
echo "GCC_BUILTIN_PREREQS=yes" >> config.sh
./build.sh
echo "[+] Finished building musl-cross x86"
}
build_gdb_x86() {
cd /build/binutils-gdb
git clean -fdx
make clean || true
cd /build/binutils-gdb/bfd
CC='/opt/cross/i486-linux-musl/bin/i486-linux-musl-gcc -static -fPIC' \
CXX='/opt/cross/i486-linux-musl/bin/i486-linux-musl-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/i486-linux-musl/bin/i486-linux-musl-ld \
LDFLAGS="" \
./configure
make -j4
cd /build/binutils-gdb/readline
CC='/opt/cross/i486-linux-musl/bin/i486-linux-musl-gcc -static -fPIC' \
CXX='/opt/cross/i486-linux-musl/bin/i486-linux-musl-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/i486-linux-musl/bin/i486-linux-musl-ld \
./configure \
--target=i686-linux-gnu \
--disable-shared \
--enable-static
make -j4
cd /build/binutils-gdb/opcodes
CC='/opt/cross/i486-linux-musl/bin/i486-linux-musl-gcc -static -fPIC' \
CXX='/opt/cross/i486-linux-musl/bin/i486-linux-musl-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/i486-linux-musl/bin/i486-linux-musl-ld \
./configure \
--target=i686-linux-gnu \
--disable-shared \
--enable-static
make -j4
cd /build/binutils-gdb/libiberty
CC='/opt/cross/i486-linux-musl/bin/i486-linux-musl-gcc -static -fPIC' \
CXX='/opt/cross/i486-linux-musl/bin/i486-linux-musl-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/i486-linux-musl/bin/i486-linux-musl-ld \
./configure \
--target=i686-linux-gnu \
--disable-shared \
--enable-static
make -j4
cd /build/binutils-gdb/libdecnumber
CC='/opt/cross/i486-linux-musl/bin/i486-linux-musl-gcc -static -fPIC' \
CXX='/opt/cross/i486-linux-musl/bin/i486-linux-musl-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/i486-linux-musl/bin/i486-linux-musl-ld \
./configure \
--target=i686-linux-gnu \
--disable-shared \
--enable-static
make -j4
cd /build/binutils-gdb/zlib
CC='/opt/cross/i486-linux-musl/bin/i486-linux-musl-gcc -static -fPIC' \
CXX='/opt/cross/i486-linux-musl/bin/i486-linux-musl-g++ -static -static-libstdc++ -fPIC' \
cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_LINKER=/opt/cross/i486-linux-musl/bin/i486-linux-musl-ld .
make zlibstatic
cd /build/binutils-gdb/gdb
CC='/opt/cross/i486-linux-musl/bin/i486-linux-musl-gcc -m32 -static -fPIC' \
CXX='/opt/cross/i486-linux-musl/bin/i486-linux-musl-g++ -m32 -static -static-libstdc++ -fPIC' \
LD=/opt/cross/i486-linux-musl/bin/i486-linux-musl-ld \
./configure \
--enable-static=yes \
--host=x86_64-linux-gnu \
--target=i686-linux-gnu \
--disable-interprocess-agent
make -j4
cd /build/binutils-gdb/gdb/gdbserver/
CC='/opt/cross/i486-linux-musl/bin/i486-linux-musl-gcc -m32 -static -fPIC' \
CXX='/opt/cross/i486-linux-musl/bin/i486-linux-musl-g++ -m32 -static -static-libstdc++ -fPIC' \
LD=/opt/cross/i486-linux-musl/bin/i486-linux-musl-ld \
./configure \
--enable-static=yes \
--host=x86_64-linux-gnu \
--target=i686-linux-gnu \
--disable-interprocess-agent
make -j4
/opt/cross/i486-linux-musl/bin/i486-linux-musl-strip /build/binutils-gdb/gdb/gdb /build/binutils-gdb/gdb/gdbserver/gdbserver
}
build_x86(){
OUT_DIR_x86=/output/`uname | tr 'A-Z' 'a-z'`/x86
mkdir -p $OUT_DIR_x86
build_musl_x86
build_gdb_x86
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}')
cp /build/binutils-gdb/gdb/gdb "${OUT_DIR_x86}/gdb-${GDB_VERSION}-${GDB_COMMIT}"
cp /build/binutils-gdb/gdb/gdbserver/gdbserver "${OUT_DIR_x86}/gdbserver-${GDBSERVER_VERSION}-${GDB_COMMIT}"
echo "[+] Finished building x86"
}
main() {
if [ ! -d "/output" ];then
echo "[-] /output does not exist, creating it"
mkdir /output
fi
fetch
build_x86
}
main

View file

@ -0,0 +1,24 @@
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
RUN mkdir /build
ADD . /build
RUN chmod +x /build/build_x86_64.sh
CMD /build/build_x86_64.sh

View file

@ -0,0 +1,133 @@
#!/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 -
GDB_COMMIT=$(cd /build/binutils-gdb/ && git rev-parse --short HEAD)
}
build_musl_x86_64() {
cd /build/musl
git clean -fdx
./build.sh
echo "[+] Finished building musl-cross x86_64"
}
build_gdb_x86_64() {
cd /build/binutils-gdb
git clean -fdx
make clean || true
cd /build/binutils-gdb/bfd
CC='/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-gcc -static -fPIC' \
CXX='/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-ld \
LDFLAGS="" \
./configure
make -j4
cd /build/binutils-gdb/readline
CC='/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-gcc -static -fPIC' \
CXX='/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-ld \
./configure \
--target=x86_64-linux-gnu \
--disable-shared \
--enable-static
make -j4
cd /build/binutils-gdb/opcodes
CC='/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-gcc -static -fPIC' \
CXX='/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-ld \
./configure \
--target=x86_64-linux-gnu \
--disable-shared \
--enable-static
make -j4
cd /build/binutils-gdb/libiberty
CC='/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-gcc -static -fPIC' \
CXX='/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-ld \
./configure \
--target=x86_64-linux-gnu \
--disable-shared \
--enable-static
make -j4
cd /build/binutils-gdb/libdecnumber
CC='/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-gcc -static -fPIC' \
CXX='/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-ld \
./configure \
--target=x86_64-linux-gnu \
--disable-shared \
--enable-static
make -j4
cd /build/binutils-gdb/zlib
CC='/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-gcc -static -fPIC' \
CXX='/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-g++ -static -static-libstdc++ -fPIC' \
cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_LINKER=/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-ld
make zlibstatic
cd /build/binutils-gdb/gdb
CC='/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-gcc -static -fPIC' \
CXX='/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-ld \
LDFLAGS='-static' \
./configure \
--enable-static=yes \
--host=x86_64-linux-gnu \
--target=x86_64-linux-gnu \
--disable-interprocess-agent
make -j4
cd /build/binutils-gdb/gdb/gdbserver/
CC='/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-gcc -static -fPIC' \
CXX='/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-g++ -static -static-libstdc++ -fPIC' \
LD=/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-ld \
LDFLAGS='-static' \
./configure \
--enable-static=yes \
--disable-interprocess-agent
make -j4
/opt/cross/x86_64-linux-musl/bin/x86_64-linux-musl-strip /build/binutils-gdb/gdb/gdb /build/binutils-gdb/gdb/gdbserver/gdbserver
}
build_x86_64(){
OUT_DIR_x86_64=/output/`uname | tr 'A-Z' 'a-z'`/x86_64
mkdir -p $OUT_DIR_x86_64
build_musl_x86_64
build_gdb_x86_64
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}')
cp /build/binutils-gdb/gdb/gdb "${OUT_DIR_x86_64}/gdb-${GDB_VERSION}-${GDB_COMMIT}"
cp /build/binutils-gdb/gdb/gdbserver/gdbserver "${OUT_DIR_x86_64}/gdbserver-${GDBSERVER_VERSION}-${GDB_COMMIT}"
echo "[+] Finished building x86_64"
}
main() {
if [ ! -d "/output" ];then
echo "[-] /output does not exist, creating it"
mkdir /output
fi
fetch
build_x86_64
}
main