Compare commits
7 Commits
gdb-15.2-u
...
enable-tui
Author | SHA1 | Date | |
---|---|---|---|
d55a31bb5e | |||
a962fbb441 | |||
d5e1dbb011 | |||
8dc07deb66 | |||
3738fc8629 | |||
fe4c0763e8 | |||
08909223f2 |
@ -5,11 +5,16 @@ RUN apt update && apt install -y \
|
||||
g++ \
|
||||
g++-aarch64-linux-gnu \
|
||||
g++-arm-linux-gnueabi \
|
||||
g++-mips-linux-gnu \
|
||||
g++-mipsel-linux-gnu \
|
||||
g++-powerpc-linux-gnu \
|
||||
gcc \
|
||||
gcc-aarch64-linux-gnu \
|
||||
gcc-arm-linux-gnueabi \
|
||||
gcc-mips-linux-gnu \
|
||||
gcc-mipsel-linux-gnu \
|
||||
gcc-powerpc-linux-gnu \
|
||||
libncurses-dev \
|
||||
m4 \
|
||||
make \
|
||||
patch \
|
||||
|
2
Makefile
2
Makefile
@ -1,4 +1,4 @@
|
||||
ARCHS := x86_64 arm aarch64 powerpc
|
||||
ARCHS := x86_64 arm aarch64 powerpc mips mipsel
|
||||
TARGETS := $(addprefix build-, $(ARCHS))
|
||||
PACK_TARGETS := $(addprefix pack-, $(ARCHS))
|
||||
|
||||
|
106
README.md
106
README.md
@ -1,8 +1,12 @@
|
||||
# Repository of static gdb and gdbserver
|
||||
|
||||
The statically compiled gdb / gdbserver binaries are avaliable to download under github releases!
|
||||
## **The statically compiled gdb / gdbserver binaries are avaliable to download under github releases!**
|
||||
|
||||
# Compiling gdb using docker
|
||||
link: [gdb-static github releases](https://github.com/guyush1/gdb-static/releases)
|
||||
|
||||
## For manual gdb/gdbserver compilation instructions, have a look at the compilation.md file
|
||||
|
||||
## Compiling gdb using docker
|
||||
|
||||
This repository contains a dockerfile and build scripts to compile gdb and gdbserver statically for multiple architectures.
|
||||
Currently, the supported architectures are:
|
||||
@ -14,7 +18,7 @@ You can easily expand it to support more architectures by adding the appropriate
|
||||
|
||||
NOTE: You don't need to interact with the dockerfile directly, as the Makefile will take care of everything for you.
|
||||
|
||||
## Building for a specific architecture
|
||||
### Building for a specific architecture
|
||||
|
||||
To build for a specific architecture, you can use the following command:
|
||||
```bash
|
||||
@ -35,108 +39,16 @@ build/
|
||||
...
|
||||
```
|
||||
|
||||
## Building for all architectures
|
||||
### Building for all architectures
|
||||
|
||||
To build for all architectures, you can use the following command:
|
||||
```bash
|
||||
make build
|
||||
```
|
||||
|
||||
## Cleaning the build
|
||||
### Cleaning the build
|
||||
|
||||
To clean the build, you can use the following command:
|
||||
```bash
|
||||
make clean
|
||||
```
|
||||
|
||||
# Notes about this file - read before proceeding!
|
||||
|
||||
While i already provided the gdb/gdbserver-15 statically compiled binaries handed out to you, some people might want to compile it to a different architecture, or compile a newer version of gdb in the future :). This rest of the file contains my compilation documentation so that you could save yourself some time and do it yourself, if you wish.
|
||||
|
||||
## <VARAIBLES> in the script
|
||||
|
||||
When specifying the compilation dir throughout the compilation process (specified as <COMPILATION_DIR_PATH> in this file), DO NOT use relative pathing, or bash characters such as `~`. They will not get parsed correctly! Instead, use absolute paths only.
|
||||
|
||||
Examples to the <VARIABLES> throughout the script:
|
||||
<CROSS_COMPILER_C> - arm-linux-gnueabi-gcc
|
||||
<CROSS_COMPILER_CPP> - arm-linux-gnueabi-g++
|
||||
<HOST_NAME> - arm-linux-gnueabi
|
||||
<COMPILATION_DIR_PATH> - /home/username/projects/libgmp-x.y.z/build-arm/
|
||||
|
||||
Environment info:
|
||||
- glibc version: 2.39-0ubuntu8.3 (NOTE: When i compiled gdb-15 using an older glibc, such as the one i had in my ubuntu-20.04 machine, i received a segfault in gdb...).
|
||||
|
||||
# Compiling gdb statically to the host platform
|
||||
|
||||
## 1) Compiling iconv
|
||||
|
||||
While compiling iconv is not a must, the libc-provided iconv (a utility to convert between encodings) may fail on different architectures,
|
||||
at least in my experiance. Thus, I recommended using a custom libiconv and compiling it into gdb.
|
||||
|
||||
Download the source from https://github.com/roboticslibrary/libiconv.git
|
||||
Make sure to check out to a stable tag (in my case - v1.17).
|
||||
|
||||
Work according to the following steps:
|
||||
I) run `./gitsub.sh pull`
|
||||
II) run `./autogen.sh` to create the configure script from configure.sh.
|
||||
III) create a build dir (e.g build), and then cd into it.
|
||||
IV) run `../configure --enable-static`
|
||||
V) run `cp -r ./include ./lib/.libs/`
|
||||
VI) run `mkdir ./lib/.libs/lib/`
|
||||
VII) run `cp ./lib/.libs/libiconv.a ./lib/.libs/lib/`
|
||||
|
||||
## 2) Compiling gdb
|
||||
|
||||
Clone gdb from sourceware - https://sourceware.org/git/binutils-gdb.git.
|
||||
I checked out to the 15.2 tag.
|
||||
|
||||
Work according to the following steps:
|
||||
I) Apply my patches (gdb_static.patch). If you are not on the exact tag i used (15.2) - you might need to apply them manually, and change some stuff.
|
||||
II) create a build dir.
|
||||
III) run `../configure --enable-static --with-static-standard-libraries --disable-tui --disable-inprocess-agent --with-libiconv-prefix=<COMPILATION_DIR_PATH>/lib/.libs/ --with-libiconv-type=static`
|
||||
IV) run `make all-gdb -j$(nproc)` - for gdbserver, run `make all-gdbserver -j$(nproc)`.
|
||||
|
||||
gdb will sit under gdb/gdb.
|
||||
gdbserver will sit under gdbserver/gdbserver.
|
||||
|
||||
# Cross compiling gdb statically to other architectures.
|
||||
|
||||
Cross compiling gdb statically is a bit more complicated then regular static compilation. In order to cross compile gdb statically, we will need to compile libgmp and libmpfr as well as iconv.
|
||||
|
||||
## 1) Compiling iconv
|
||||
|
||||
Work according to the same process as described under the compilation to the host platform, aside from the configure script:
|
||||
IV) run `../configure --enable-static CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --host=<HOST_NAME>`
|
||||
|
||||
## 2) Compiling libgmp
|
||||
|
||||
Download and extract the latest edition from https://gmplib.org/.
|
||||
I used the 6.3.0 edition.
|
||||
|
||||
Work according to the following steps:
|
||||
I) Create a build dir and cd into it.
|
||||
II) run `../configure CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --enable-static --host=<HOST_NAME>`
|
||||
III) run `make -j$(nproc)`
|
||||
IV) run `mkdir ./.libs/include/`
|
||||
V) run `cp gmp.h ./.libs/include/`
|
||||
VI) run `mkdir ./.libs/lib`
|
||||
VII) run `cp ./.libs/libgmp.a ./.libs/lib`
|
||||
|
||||
## 3) Compiling libmpfr
|
||||
|
||||
Download and extract the latest edition from https://www.mpfr.org/.
|
||||
I used the 4.2.1 edition.
|
||||
|
||||
Work according to the following steps:
|
||||
I) Create a build dir and cd into it.
|
||||
II) run `../configure CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --enable-static --with-gmp-build=<COMPILATION_DIR_PATH> --host=<HOST_NAME>`
|
||||
III) run `make -j$(nproc)`
|
||||
IV) run `mkdir ./src/.libs/lib`
|
||||
V) run `cp ./src/.libs/libmpfr.a ./src/.libs/lib`
|
||||
VI) run `mkdir ./src/.libs/include`
|
||||
VII) run `cp ../src/mpfr.h ./src/.libs/include/`
|
||||
|
||||
## 4) Compiling gdb
|
||||
|
||||
Work according to the same process as described under the compilation to the host platform, aside from the configure script:
|
||||
III) run `../configure --enable-static --with-static-standard-libraries --disable-tui --disable-inprocess-agent --with-libiconv-prefix=<COMPILATION_DIR_PATH>/lib/.libs/ --with-libiconv-type=static --with-gmp=<COMPILATION_DIR_PATH>/.libs/ --with-mpfr=<COMPILATION_DIR_PATH>/src/.libs/ CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --host=<HOST_NAME>`
|
||||
|
91
compilation.md
Normal file
91
compilation.md
Normal file
@ -0,0 +1,91 @@
|
||||
# Notes about this file - read before proceeding!
|
||||
|
||||
While i have already provided the gdb/gdbserver-15 statically compiled binaries for you, some people might want to compile it to a different architecture (without our build scripts), or compile a newer version of gdb in the future :). The rest of the file contains a documentation of the compilation process, in order to help you out.
|
||||
|
||||
## <VARAIBLES> in the script
|
||||
|
||||
When specifying the compilation dir throughout the compilation process (specified as <COMPILATION_DIR_PATH> in this file), DO NOT use relative pathing, or bash characters such as `~`. They will not get parsed correctly! Instead, use absolute paths only.
|
||||
|
||||
Examples to the <VARIABLES> throughout the script:
|
||||
<CROSS_COMPILER_C> - arm-linux-gnueabi-gcc
|
||||
<CROSS_COMPILER_CPP> - arm-linux-gnueabi-g++
|
||||
<HOST_NAME> - arm-linux-gnueabi
|
||||
<COMPILATION_DIR_PATH> - /home/username/projects/libgmp-x.y.z/build-arm/
|
||||
|
||||
Environment info:
|
||||
- glibc version: 2.39-0ubuntu8.3 (NOTE: When i compiled gdb-15 using an older glibc, such as the one i had in my ubuntu-20.04 machine, i received a segfault in gdb...).
|
||||
|
||||
# Compiling gdb statically to the host platform
|
||||
|
||||
## 1) Compiling iconv
|
||||
|
||||
While compiling iconv is not a must, the libc-provided iconv (a utility to convert between encodings) may fail on different architectures,
|
||||
at least in my experiance. Thus, I recommended using a custom libiconv and compiling it into gdb.
|
||||
|
||||
Download the source from https://github.com/roboticslibrary/libiconv.git
|
||||
Make sure to check out to a stable tag (in my case - v1.17).
|
||||
|
||||
Work according to the following steps:
|
||||
I) run `./gitsub.sh pull`
|
||||
II) run `./autogen.sh` to create the configure script from configure.sh.
|
||||
III) create a build dir (e.g build), and then cd into it.
|
||||
IV) run `../configure --enable-static`
|
||||
V) run `cp -r ./include ./lib/.libs/`
|
||||
VI) run `mkdir ./lib/.libs/lib/`
|
||||
VII) run `cp ./lib/.libs/libiconv.a ./lib/.libs/lib/`
|
||||
|
||||
## 2) Compiling gdb
|
||||
|
||||
Clone gdb from sourceware - https://sourceware.org/git/binutils-gdb.git.
|
||||
I checked out to the 15.2 tag.
|
||||
|
||||
Work according to the following steps:
|
||||
I) Apply my patches (gdb_static.patch). If you are not on the exact tag i used (15.2) - you might need to apply them manually, and change some stuff.
|
||||
II) create a build dir.
|
||||
III) run `../configure --enable-static --with-static-standard-libraries --disable-tui --disable-inprocess-agent --with-libiconv-prefix=<COMPILATION_DIR_PATH>/lib/.libs/ --with-libiconv-type=static`
|
||||
IV) run `make all-gdb -j$(nproc)` - for gdbserver, run `make all-gdbserver -j$(nproc)`.
|
||||
|
||||
gdb will sit under gdb/gdb.
|
||||
gdbserver will sit under gdbserver/gdbserver.
|
||||
|
||||
# Cross compiling gdb statically to other architectures.
|
||||
|
||||
Cross compiling gdb statically is a bit more complicated then regular static compilation. In order to cross compile gdb statically, we will need to compile libgmp and libmpfr as well as iconv.
|
||||
|
||||
## 1) Compiling iconv
|
||||
|
||||
Work according to the same process as described under the compilation to the host platform, aside from the configure script:
|
||||
IV) run `../configure --enable-static CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --host=<HOST_NAME>`
|
||||
|
||||
## 2) Compiling libgmp
|
||||
|
||||
Download and extract the latest edition from https://gmplib.org/.
|
||||
I used the 6.3.0 edition.
|
||||
|
||||
Work according to the following steps:
|
||||
I) Create a build dir and cd into it.
|
||||
II) run `../configure CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --enable-static --host=<HOST_NAME>`
|
||||
III) run `make -j$(nproc)`
|
||||
IV) run `mkdir ./.libs/include/`
|
||||
V) run `cp gmp.h ./.libs/include/`
|
||||
VI) run `mkdir ./.libs/lib`
|
||||
VII) run `cp ./.libs/libgmp.a ./.libs/lib`
|
||||
|
||||
## 3) Compiling libmpfr
|
||||
|
||||
Download and extract the latest edition from https://www.mpfr.org/.
|
||||
I used the 4.2.1 edition.
|
||||
|
||||
Work according to the following steps:
|
||||
I) Create a build dir and cd into it.
|
||||
II) run `../configure CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --enable-static --with-gmp-build=<COMPILATION_DIR_PATH> --host=<HOST_NAME>`
|
||||
III) run `make -j$(nproc)`
|
||||
IV) run `mkdir ./src/.libs/lib`
|
||||
V) run `cp ./src/.libs/libmpfr.a ./src/.libs/lib`
|
||||
VI) run `mkdir ./src/.libs/include`
|
||||
VII) run `cp ../src/mpfr.h ./src/.libs/include/`
|
||||
|
||||
## 4) Compiling gdb
|
||||
|
||||
Work according to the same process as described under the compilation to the host platform, aside from the configure script:
|
||||
III) run `../configure --enable-static --with-static-standard-libraries --disable-tui --disable-inprocess-agent --with-libiconv-prefix=<COMPILATION_DIR_PATH>/lib/.libs/ --with-libiconv-type=static --with-gmp=<COMPILATION_DIR_PATH>/.libs/ --with-mpfr=<COMPILATION_DIR_PATH>/src/.libs/ CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --host=<HOST_NAME>`
|
73
src/build.sh
73
src/build.sh
@ -13,7 +13,7 @@ function set_compliation_variables() {
|
||||
# Returns:
|
||||
# 0: success
|
||||
# 1: failure
|
||||
supported_archs=("arm" "aarch64" "powerpc" "x86_64")
|
||||
supported_archs=("arm" "aarch64" "powerpc" "x86_64" "mips" "mipsel")
|
||||
|
||||
local target_arch="$1"
|
||||
|
||||
@ -33,6 +33,12 @@ function set_compliation_variables() {
|
||||
elif [[ "$target_arch" == "powerpc" ]]; then
|
||||
CROSS=powerpc-linux-gnu-
|
||||
export HOST=powerpc-linux-gnu
|
||||
elif [[ "$target_arch" == "mips" ]]; then
|
||||
CROSS=mips-linux-gnu-
|
||||
export HOST=mips-linux-gnu
|
||||
elif [[ "$target_arch" == "mipsel" ]]; then
|
||||
CROSS=mipsel-linux-gnu-
|
||||
export HOST=mipsel-linux-gnu
|
||||
elif [[ "$target_arch" == "x86_64" ]]; then
|
||||
CROSS=""
|
||||
export HOST=x86_64-linux-gnu
|
||||
@ -45,6 +51,17 @@ function set_compliation_variables() {
|
||||
export CXXFLAGS="-O2"
|
||||
}
|
||||
|
||||
function set_ncurses_link_variables() {
|
||||
# Set up ncurses library link variables
|
||||
#
|
||||
# Parameters:
|
||||
# $1: ncursesw build dir
|
||||
local ncursesw_build_dir="$1"
|
||||
|
||||
# Allow tui mode by adding our custom built static ncursesw library to the linker search path.
|
||||
export LDFLAGS="-L$ncursesw_build_dir/lib $LDFLAGS"
|
||||
}
|
||||
|
||||
function build_iconv() {
|
||||
# Build libiconv.
|
||||
#
|
||||
@ -146,6 +163,51 @@ function build_libgmp() {
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
function build_ncurses() {
|
||||
# Build libncursesw.
|
||||
#
|
||||
# Parameters:
|
||||
# $1: libncursesw package directory
|
||||
# $2: target architecture
|
||||
#
|
||||
# Echoes:
|
||||
# The libncursesw build directory
|
||||
#
|
||||
# Returns:
|
||||
# 0: success
|
||||
# 1: failure
|
||||
local ncurses_dir="$1"
|
||||
local target_arch="$2"
|
||||
local ncurses_build_dir="$(realpath "$ncurses_dir/build-$target_arch")"
|
||||
|
||||
echo "$ncurses_build_dir"
|
||||
mkdir -p "$ncurses_build_dir"
|
||||
|
||||
if [[ -f "$ncurses_build_dir/lib/libncursesw.a" ]]; then
|
||||
>&2 echo "Skipping build: libncursesw already built for $target_arch"
|
||||
return 0
|
||||
fi
|
||||
|
||||
pushd "$ncurses_build_dir" > /dev/null
|
||||
|
||||
>&2 fancy_title "Building libncursesw for $target_arch"
|
||||
|
||||
../configure --enable-static "CC=$CC" "CXX=$CXX" "--host=$HOST" \
|
||||
"CFLAGS=$CFLAGS" "CXXFLAGS=$CXXFLAGS" "--enable-widec" 1>&2
|
||||
if [[ $? -ne 0 ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
make -j$(nproc) 1>&2
|
||||
if [[ $? -ne 0 ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
>&2 fancy_title "Finished building libncursesw for $target_arch"
|
||||
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
function build_libmpfr() {
|
||||
# Build libmpfr.
|
||||
#
|
||||
@ -236,7 +298,7 @@ function build_gdb() {
|
||||
|
||||
>&2 fancy_title "Building gdb for $target_arch"
|
||||
|
||||
../configure --enable-static --with-static-standard-libraries --disable-tui --disable-inprocess-agent \
|
||||
../configure --enable-static --enable-tui --with-static-standard-libraries --disable-inprocess-agent \
|
||||
"--with-libiconv-prefix=$libiconv_prefix" --with-libiconv-type=static \
|
||||
"--with-gmp=$libgmp_prefix" \
|
||||
"--with-mpfr=$libmpfr_prefix" \
|
||||
@ -361,6 +423,13 @@ function build_gdb_with_dependencies() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
ncursesw_build_dir="$(build_ncurses "$packages_dir/ncurses" "$target_arch")"
|
||||
if [[ $? -ne 0 ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
set_ncurses_link_variables "$ncursesw_build_dir"
|
||||
|
||||
build_and_install_gdb "$packages_dir/gdb" \
|
||||
"$iconv_build_dir/lib/.libs/" \
|
||||
"$gmp_build_dir/.libs/" \
|
||||
|
@ -10,6 +10,7 @@ PACKAGE_URLS=(
|
||||
"https://ftp.gnu.org/pub/gnu/gmp/gmp-6.3.0.tar.xz"
|
||||
"https://ftp.gnu.org/pub/gnu/mpfr/mpfr-4.2.1.tar.xz"
|
||||
"https://ftp.gnu.org/gnu/gdb/gdb-15.2.tar.xz"
|
||||
"https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.5.tar.gz"
|
||||
)
|
||||
|
||||
function unpack_tarball() {
|
||||
|
Reference in New Issue
Block a user