No description
Find a file
Thiago Jung Bauermann 1ccc3f6a2e GDB: aarch64-linux: Fix build failure on musl systems
(cherry picked from commit 0209006212)

When building against musl (e.g. on Alpine Linux), the following error
happens:

    CXX    linux-aarch64-low.o
  In file included from /home/bauermann/src/binutils-gdb/gdbserver/linux-aarch64-low.cc:42:
  /home/bauermann/src/binutils-gdb/gdbserver/../gdb/arch/aarch64-gcs-linux.h:35:8: error: redefinition of 'struct user_gcs'
     35 | struct user_gcs
        |        ^~~~~~~~
  In file included from /home/bauermann/src/binutils-gdb/gdbserver/linux-aarch64-low.cc:35:
  /usr/include/asm/ptrace.h:329:8: note: previous definition of 'struct user_gcs'
    329 | struct user_gcs {
        |        ^~~~~~~~
  make[2]: *** [Makefile:565: linux-aarch64-low.o] Error 1

aarch64-linux-tdep.c fails to build in the same way.  This happens because
aarch64-gcs-linux.h uses GCS_MAGIC to see whether the system headers
have GCS-related definitions.  The problem is that GCS_MAGIC is defined in
<asm/sigcontext.h> while struct gcs_user is defined in <asm/ptrace.h>.
It's fine on glibc systems because in the set of system headers that
linux-aarch64-low.cc and aarch64-linux-tdep.c include, <asm/sigcontext.h>
ends up being included implicitly as well.  This doesn't happen when using
musl's headers though.

There isn't a macro in <asm/ptrace.h> whose presence is correlated with
the presence of the struct user_gcs definition, so a configure check is
needed to detect it and conditionally define the struct.

Also, this change requires aarch64-linux-tdep.c to stop using
struct user_gcs because target-dependent code can't include <asm/ptrace.h>
and thus even if HAVE_STRUCT_USER_GCS is set, the file won't have the
struct definition available. To fix this problem, also backport the
definition of AARCH64_LINUX_SIZEOF_GCS_REGSET and use it there.

Note that there's another build issue with musl, described in
PR gdb/33747 affecting compilation of gdb/ser-unix.c.  In order to be
able to test this patch, I applied the patch in comment 11 there.

Tested with a native build on an Alpine Linux aarch64 system, and also
verified that all gdb.arch/aarch64-gcs*.exp tests pass on it.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33926
Co-authored-by: Chris Packham <judge.packham@gmail.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
2026-03-19 14:24:45 -03:00
bfd Automatic date update in version.in 2026-03-19 00:00:21 +00:00
binutils Re: tekhex test for commit bf0f85df12 2025-09-06 10:33:16 +09:30
config config: Update obsolete autoconf macro 2025-08-14 17:40:37 -04:00
contrib contrib: sync dg-extract-results.{sh,py} with GCC 2025-07-05 11:20:44 +01:00
cpu Add markers for 2.45 branch 2025-07-13 08:35:45 +01:00
elfcpp Add markers for 2.45 branch 2025-07-13 08:35:45 +01:00
etc Update year range in copyright notice of binutils files 2025-01-01 18:29:57 +10:30
gas x86: check reloc types for relaxable branches 2025-09-05 08:33:27 +02:00
gdb GDB: aarch64-linux: Fix build failure on musl systems 2026-03-19 14:24:45 -03:00
gdbserver GDB, gdbserver: aarch64-linux: Initial Guarded Control Stack support 2025-08-29 18:35:58 -03:00
gdbsupport GDB: aarch64-linux: Fix build failure on musl systems 2026-03-19 14:24:45 -03:00
gnulib gnulib: Update obsolete autoconf macros 2025-08-12 21:12:50 -04:00
gold gold: configury: fix obsolete macros 2025-07-23 19:49:50 -04:00
gprof Update obsolete autoconf macros 2025-08-07 22:14:49 +09:30
gprofng gprofng: do not skip weak symbols 2025-07-19 12:54:32 -07:00
include PR 33302, Symbols truncated on i386pep target 2025-08-25 08:28:38 +09:30
ld Update x86: Add GLIBC_ABI_GNU2_TLS version dependency 2025-09-06 06:19:25 -07:00
libbacktrace autoupdate: regen after replacing obsolete macros 2024-06-10 08:25:56 +09:30
libctf Update obsolete autoconf macros 2025-08-07 22:14:49 +09:30
libdecnumber regen config 2023-08-12 10:27:57 +09:30
libiberty libiberty: sync with gcc 2025-08-07 10:33:44 +01:00
libsframe libsframe: use offsets to FDE and FRE sub-sections 2025-08-23 12:10:31 -07:00
opcodes csky disassembler leak 2025-09-03 10:12:01 +09:30
readline readline/tcap.h: Update definitions for C23 2025-05-02 12:00:05 -06:00
sim sim: riscv: Fix build issue due to INSN_CLASS_C was changed to INSN_CLASS_ZCA 2025-07-10 21:50:19 +08:00
texinfo
zlib zlib: import zlib-1.3.1 [PR32933] 2025-07-31 14:45:21 +01:00
.cvsignore
.editorconfig Add top-level .editorconfig file 2022-01-28 08:25:42 -05:00
.gitattributes binutils-gdb/git: highlight whitespace errors in source files 2022-07-25 14:35:41 +01:00
.gitignore Add Vim swap files to .gitignore 2025-02-28 16:06:25 +00:00
.pre-commit-config.yaml Bump flake8 version 2025-08-28 09:01:33 -06:00
ar-lib
ChangeLog Add markers for 2.45 branch 2025-07-13 08:35:45 +01:00
compile
config-ml.in MSP430: Add -fno-exceptions multilib 2023-08-12 10:24:26 +09:30
config.guess Sync config.guess and config.sub with latest versions from the config project. 2025-01-17 10:18:30 +00:00
config.rpath
config.sub Sync config.guess and config.sub with latest versions from the config project. 2025-01-17 10:18:30 +00:00
configure nios2: Remove binutils support for Nios II target. 2024-11-26 19:13:07 +00:00
configure.ac nios2: Remove binutils support for Nios II target. 2024-11-26 19:13:07 +00:00
COPYING
COPYING.LIB
COPYING.LIBGLOSS
COPYING.NEWLIB
COPYING3
COPYING3.LIB
depcomp
djunpack.bat
install-sh
libtool.m4 FDPIC: Handle arm*-*-uclinuxfdpiceabi in configure scripts 2023-08-12 10:25:06 +09:30
ltgcc.m4
ltmain.sh ltmain.sh: allow more flags at link-time 2024-09-25 19:06:10 +01:00
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
MAINTAINERS Fix compiling bfd/vms-lib.c for a 32-bit host. 2024-03-18 10:26:16 +00:00
Makefile.def Fix 64-bit BFD detection causing build failures 2025-04-28 18:53:30 +01:00
Makefile.in Fix 64-bit BFD detection causing build failures 2025-04-28 18:53:30 +01:00
Makefile.tpl Revert "Pass GUILE down to subdirectories" 2024-03-22 11:07:28 -06:00
makefile.vms
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
README-maintainer-mode Note that at least dejagnu version 1.5.3 is required in order to be ale to run the testsuites. 2022-10-04 10:54:19 +01:00
SECURITY.txt Add a SECURITY.txt file describing the GNU Binutils' project's stance on security related bugs. 2023-04-20 16:52:11 +01:00
setup.com
src-release.sh Rename 'binutils' to 'binutils_with_gold'. Rename 'bin_no_gold' to 'binutils'. Add 'gold' 2025-02-04 11:50:02 +00:00
symlink-tree
test-driver
ylwrap

		   README for GNU development tools

This directory contains various GNU compilers, assemblers, linkers, 
debuggers, etc., plus their support routines, definitions, and documentation.

If you are receiving this as part of a GDB release, see the file gdb/README.
If with a binutils release, see binutils/README;  if with a libg++ release,
see libg++/README, etc.  That'll give you info about this
package -- supported targets, how to use it, how to report bugs, etc.

It is now possible to automatically configure and build a variety of
tools with one command.  To build all of the tools contained herein,
run the ``configure'' script here, e.g.:

	./configure 
	make

To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
	make install

(If the configure script can't determine your type of computer, give it
the name as an argument, for instance ``./configure sun4''.  You can
use the script ``config.sub'' to test whether a name is recognized; if
it is, config.sub translates it to a triplet specifying CPU, vendor,
and OS.)

If you have more than one compiler on your system, it is often best to
explicitly set CC in the environment before running configure, and to
also set CC when running make.  For example (assuming sh/bash/ksh):

	CC=gcc ./configure
	make

A similar example using csh:

	setenv CC gcc
	./configure
	make

Much of the code and documentation enclosed is copyright by
the Free Software Foundation, Inc.  See the file COPYING or
COPYING.LIB in the various directories, for a description of the
GNU General Public License terms under which you can copy the files.

REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info
on where and how to report problems.