Compile gdb for aarch64 target to use with MX-Linux. Later compile to use with FreeBSD or GhostBSD-Arm64
Compile gdb for aarch64 target
https://github.com/libexpat/libexpat/releases/download/R_2_6_1/expat-2.6.1.tar.gz
Mar 10, 2024, 17:05:32
wget -c https://github.com/libexpat/libexpat/releases/download/R_2_6_1/expat-2.6.1.tar.gz
gunzip expat-2.6.1.tar.gz
tar xvf expat-2.6.1.tar.gz
cd gdb-14.2
./configure --target=aarch64-linux-android && make -j8 && sudo make install
$ ../configure --target=aarch64-freebsd --program-prefix=aarch64-
../configure --target=aarch64-elf-freebsd --program-prefix=aarch64- --with-expat --with-libexpat-prefix=/usr/local/
mxme@mx16-Klik:/media/mxme/Linux1/RaspberryPi4B/src/gdb/gdb-14.2/build-aarch64-gdb/gdb
$ gdb --configuration
Python Exception <class 'ModuleNotFoundError'> No module named 'gdb':
gdb: warning:
Could not load the Python gdb module from `/usr/local/share/gdb/python'.
Limited Python support is available from the _gdb module.
Suggest passing --data-directory=/path/to/gdb/data-directory.
This GDB was configured as follows:
configure --host=x86_64-linux-gnu --target=x86_64-linux-gnu
--with-auto-load-dir=$debugdir:$datadir/auto-load
--with-auto-load-safe-path=$debugdir:$datadir/auto-load
--with-expat
--with-gdb-datadir=/usr/share/gdb (relocatable)
--with-jit-reader-dir=/usr/lib/gdb (relocatable)
--without-libunwind-ia64
--with-lzma
--with-babeltrace
--with-intel-pt
--with-mpfr
--with-xxhash
--with-python=/usr (relocatable)
--with-python-libdir=/usr/lib (relocatable)
--with-debuginfod
--without-guile
--enable-source-highlight
--with-separate-debug-dir=/usr/lib/debug (relocatable)
--with-system-gdbinit=/etc/gdb/gdbinit
--with-system-gdbinit-dir=/etc/gdb/gdbinit.d
("Relocatable" means the directory can be moved with the GDB installation
tree, and GDB will still find it.)
It seems below does the job.
./configure --host=aarch64-linux-gnu
./configure --target=aarch64-unknown-freebsd --program-prefix=aarch64- --with-expat --with-libexpat-prefix=/usr/local/
$ cd build*
mxme@mx16-Klik:/media/mxme/Linux1/RaspberryPi4B/src/gdb/gdb-14.2/build-aarch64-gdb
$ ../configure --target=aarch64-freebsd --program-prefix=aarch64-
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... aarch64-unknown-freebsd
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for gawk... gawk
checking for gdbserver support... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for gcc option to accept ISO C99... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking whether g++ accepts -static-libstdc++ -static-libgcc... yes
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada and is recent enough... no
checking for gdc... no
checking whether the D compiler works... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for objdir... .libs
checking for the correct version of gmp.h... yes
checking for the correct version of mpfr.h... yes
checking for the correct version of the gmp/mpfr libraries... yes
checking for isl 0.15 or later... no
required isl version is 0.15 or later
*** This configuration is not supported in the following subdirectories:
gdbserver
(Any other directories should still work fine.)
checking for default BUILD_CONFIG...
checking for --enable-vtable-verify... no
checking for bison... no
checking for byacc... no
checking for yacc... no
checking for bison... no
checking for gm4... no
checking for gnum4... no
checking for m4... m4
checking for flex... no
checking for lex... no
checking for flex... no
checking for makeinfo... makeinfo
checking for expect... no
checking for runtest... no
checking for ar... ar
checking for as... as
checking for dlltool... no
checking for dsymutil... no
checking for ld... ld
checking for lipo... no
checking for nm... nm
checking for ranlib... ranlib
checking for strip... strip
checking for windres... no
checking for windmc... no
checking for objcopy... objcopy
checking for objdump... objdump
checking for otool... no
checking for readelf... readelf
checking for -plugin option... --plugin /usr/lib/gcc/x86_64-linux-gnu/10/liblto_plugin.so
checking for aarch64-freebsd-cc... no
checking for aarch64-freebsd-gcc... no
checking for aarch64-freebsd-c++... no
checking for aarch64-freebsd-g++... no
checking for aarch64-freebsd-cxx... no
checking for aarch64-freebsd-gxx... no
checking for aarch64-freebsd-gcc... no
checking for aarch64-freebsd-gfortran... no
checking for aarch64-freebsd-gccgo... no
checking for aarch64-freebsd-gdc... no
checking for aarch64-freebsd-gm2... no
checking for aarch64-freebsd-ar... no
checking for aarch64-freebsd-as... no
checking for aarch64-freebsd-dlltool... no
checking for aarch64-freebsd-dsymutil... no
checking for aarch64-freebsd-ld... no
checking for aarch64-freebsd-lipo... no
checking for aarch64-freebsd-nm... no
checking for aarch64-freebsd-objcopy... no
checking for aarch64-freebsd-objdump... no
checking for aarch64-freebsd-otool... no
checking for aarch64-freebsd-ranlib... no
checking for aarch64-freebsd-readelf... no
checking for aarch64-freebsd-strip... no
checking for aarch64-freebsd-windres... no
checking for aarch64-freebsd-windmc... no
checking where to find the target ar... pre-installed
checking where to find the target as... pre-installed
checking where to find the target cc... pre-installed
checking where to find the target c++... pre-installed
checking where to find the target c++ for libstdc++... pre-installed
checking where to find the target dlltool... pre-installed
checking where to find the target dsymutil... pre-installed
checking where to find the target gcc... pre-installed
checking where to find the target gfortran... pre-installed
checking where to find the target gccgo... pre-installed
checking where to find the target gdc... pre-installed
checking where to find the target gm2... pre-installed
checking where to find the target ld... pre-installed
checking where to find the target lipo... pre-installed
checking where to find the target nm... pre-installed
checking where to find the target objcopy... pre-installed
checking where to find the target objdump... pre-installed
checking where to find the target otool... pre-installed
checking where to find the target ranlib... pre-installed
checking where to find the target readelf... pre-installed
checking where to find the target strip... pre-installed
checking where to find the target windres... pre-installed
checking where to find the target windmc... pre-installed
checking whether to enable maintainer-specific portions of Makefiles... no
configure: creating ./config.status
config.status: creating Makefile
make all-recursive
make[3]: Entering directory '/media/mxme/Linux1/RaspberryPi4B/src/gdb/gdb-14.2/build-aarch64-gdb/sim'
make[4]: Entering directory '/media/mxme/Linux1/RaspberryPi4B/src/gdb/gdb-14.2/build-aarch64-gdb/sim'
CCLD aarch64/run
/usr/bin/ld: ../opcodes/.libs/libopcodes.a(disassemble.o): in function `disassembler':
/media/mxme/Linux1/RaspberryPi4B/src/gdb/gdb-14.2/build-aarch64-gdb/opcodes/../../opcodes/disassemble.c:547: undefined reference to `print_insn_i386'
/usr/bin/ld: ../opcodes/.libs/libopcodes.a(disassemble.o): in function `disassembler_usage':
/media/mxme/Linux1/RaspberryPi4B/src/gdb/gdb-14.2/build-aarch64-gdb/opcodes/../../opcodes/disassemble.c:575: undefined reference to `print_i386_disassembler_options'
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:3635: aarch64/run] Error 1
make[4]: Leaving directory '/media/mxme/Linux1/RaspberryPi4B/src/gdb/gdb-14.2/build-aarch64-gdb/sim'
make[3]: *** [Makefile:4208: all-recursive] Error 1
make[3]: Leaving directory '/media/mxme/Linux1/RaspberryPi4B/src/gdb/gdb-14.2/build-aarch64-gdb/sim'
make[2]: *** [Makefile:3021: all] Error 2
make[2]: Leaving directory '/media/mxme/Linux1/RaspberryPi4B/src/gdb/gdb-14.2/build-aarch64-gdb/sim'
make[1]: *** [Makefile:9791: all-sim] Error 2
make[1]: Leaving directory '/media/mxme/Linux1/RaspberryPi4B/src/gdb/gdb-14.2/build-aarch64-gdb'
make: *** [Makefile:1020: all] Error 2
mxme@mx16-Klik:/media/mxme/Linux1/RaspberryPi4B/src/gdb/gdb-14.2/build-aarch64-gdb
Now to fix 2 errors: referencing i386 disassembly links missing. Maybe add a target i386 ?
root@mx16-Klik:/media/mxme/Linux1/RaspberryPi4B/src/gdb/gdb-14.2/build-aarch64-gdb# aarch64-gdb --configuration
This GDB was configured as follows:
configure --host=x86_64-pc-linux-gnu --target=aarch64-elf-freebsd
--with-auto-load-dir=$debugdir:$datadir/auto-load
--with-auto-load-safe-path=$debugdir:$datadir/auto-load
--with-expat
--with-gdb-datadir=/usr/local/share/gdb (relocatable)
--with-jit-reader-dir=/usr/local/lib/gdb (relocatable)
--without-libunwind-ia64
--without-lzma
--without-babeltrace
--without-intel-pt
--without-xxhash
--without-python
--without-python-libdir
--without-debuginfod
--without-curses
--without-guile
--without-amd-dbgapi
--disable-source-highlight
--enable-threading
--disable-tui
--without-system-readline
--with-separate-debug-dir=/usr/local/lib/debug (relocatable)
("Relocatable" means the directory can be moved with the GDB installation
tree, and GDB will still find it.)
root@mx16-Klik:/media/mxme/Linux1/RaspberryPi4B/src/gdb/gdb-14.2/build-aarch64-gdb#
# openocd -f interface/ftdi/tigard-jtag.cfg -f target/bcm2711.cfg
aarch64-gdb
CC=aarch64-linux-gnu-
?gcc-XXX-aarch64-linux-gnu-YYY
)?