Skip to content

Commit 0c794ef

Browse files
committed
Added a readme file
The readme file may help other people to compile gdb statically as well!
0 parents  commit 0c794ef

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Repository of static gdb and gdbserver
2+
3+
The statically compiled gdb / gdbserver binaries are avaliable to download under github releases!
4+
5+
# Notes about this file - read before proceeding!
6+
7+
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.
8+
9+
## <VARAIBLES> in the script
10+
11+
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.
12+
13+
Examples to the <VARIABLES> throughout the script:
14+
<CROSS_COMPILER_C> - arm-linux-gnueabi-gcc
15+
<CROSS_COMPILER_CPP> - arm-linux-gnueabi-g++
16+
<HOST_NAME> - arm-linux-gnueabi
17+
<COMPILATION_DIR_PATH> - /home/username/projects/libgmp-x.y.z/build-arm/
18+
19+
Environment info:
20+
- 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...).
21+
22+
# Compiling gdb statically to the host platform
23+
24+
## 1) Compiling iconv
25+
26+
While compiling iconv is not a must, the libc-provided iconv (a utility to convert between encodings) may fail on different architectures,
27+
at least in my experiance. Thus, I recommended using a custom libiconv and compiling it into gdb.
28+
29+
Download the source from https://github.com/roboticslibrary/libiconv.git
30+
Make sure to check out to a stable tag (in my case - v1.17).
31+
32+
Work according to the following steps:
33+
I) run `./gitsub.sh pull`
34+
II) run `./autogen.sh` to create the configure script from configure.sh.
35+
III) create a build dir (e.g build), and then cd into it.
36+
IV) run `../configure --enable-static`
37+
V) run `cp -r ./include ./lib/.libs/`
38+
VI) run `mkdir ./lib/.libs/lib/`
39+
VII) run `cp ./lib/.libs/libiconv.a ./lib/.libs/lib/`
40+
41+
## 2) Compiling gdb
42+
43+
Clone gdb from sourceware - https://sourceware.org/git/binutils-gdb.git.
44+
I checked out to the 15.1 tag.
45+
46+
Work according to the following steps:
47+
I) Apply my patches - if you are not on the exact tag i used (15.1) - you might need to apply them manually.
48+
II) create a build dir.
49+
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`
50+
IV) run `make all-gdb -j$(nproc)` - for gdbserver, run `make all-gdbserver -j$(nproc)`.
51+
52+
gdb will sit under gdb/gdb.
53+
gdbserver will sit under gdbserver/gdbserver.
54+
55+
# Cross compiling gdb statically to other architectures.
56+
57+
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.
58+
59+
## 1) Compiling iconv
60+
61+
Work according to the same process as described under the compilation to the host platform, aside from the configure script:
62+
IV) run `../configure --enable-static CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --host=<HOST_NAME>`
63+
64+
## 2) Compiling libgmp
65+
66+
Download and extract the latest edition from https://gmplib.org/.
67+
I used the 6.3.0 edition.
68+
69+
Work according to the following steps:
70+
I) Create a build dir and cd into it.
71+
II) run `../configure CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --enable-static --host=<HOST_NAME>`
72+
III) run `make -j$(nproc)`
73+
IV) run `mkdir ./.libs/include/`
74+
V) run `cp gmp.h ./.libs/include/`
75+
VI) run `mkdir ./.libs/lib`
76+
VII) run `cp ./.libs/libgmp.a ./.libs/lib`
77+
78+
## 3) Compiling libmpfr
79+
80+
Download and extract the latest edition from https://www.mpfr.org/.
81+
I used the 4.2.1 edition.
82+
83+
Work according to the following steps:
84+
I) Create a build dir and cd into it.
85+
II) run `../configure CC=<CROSS_COMPILER_C> CXX=<CROSS_COMPILER_CPP> --enable-static --with-gmp-build=<COMPILATION_DIR_PATH> --host=<HOST_NAME>`
86+
III) run `make -j$(nproc)`
87+
IV) run `mkdir ./src/.libs/lib`
88+
V) run `cp ./src/.libs/libmpfr.a ./src/.libs/lib`
89+
90+
## 4) Compiling gdb
91+
92+
Work according to the same process as described under the compilation to the host platform, aside from the configure script:
93+
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>`

0 commit comments

Comments
 (0)