From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id hSvGGM1A42rTDAcAWB0awg (envelope-from ) for ; Thu, 29 Oct 2026 08:49:17 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=TgsM0Vq1; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4CDE71E023; Thu, 29 Oct 2026 08:49:17 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-4.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HK_RANDOM_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 1B37C1E023 for ; Thu, 29 Oct 2026 08:49:16 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6B02D4BA23FA for ; Thu, 29 Oct 2026 12:49:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B02D4BA23FA Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=TgsM0Vq1 Received: from mail-dl1-x1234.google.com (mail-dl1-x1234.google.com [IPv6:2607:f8b0:4864:20::1234]) by sourceware.org (Postfix) with ESMTPS id 489894BA23E4 for ; Thu, 29 Oct 2026 12:43:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 489894BA23E4 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 489894BA23E4 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1234 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793277830; cv=none; b=IJCXF9LDQwbCxJbn1EMn4PCyAd8rrc8MSQIH94g76dyJushUYkXjoRudS4VT07vqFISexGfQyKf5fDX/WGEfK1bt1ebS33Vq2rmm7NteSiTuCZZJW40T6hgNnvLfdCEeG5mOQy9kWoYGwNc27NGDgaWAho+77jgSHFZ8Atifd4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793277830; c=relaxed/simple; bh=ZD0oCSx21Fp0HCdSnH6vA9vpTVBC8bIwESfUEL3A2TU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=k7ADlEJTA/LAEru5InliF8SWBR0ADbLZk+fWIETEE5y+mNpLQ0sRzpCVIasp0A+j8M/ooo5MtDI++sIYKIOIuAKo+jsZfDZ6OganHNFo0Jm84u3m27ZW4K3Npb641Rfd/bECffh3OTYrMqSNi9iXdMtV/dshQv60m59PSCiYqS8= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=TgsM0Vq1 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 489894BA23E4 Received: by mail-dl1-x1234.google.com with SMTP id a92af1059eb24-1931ff67a29so1267700c88.1 for ; Thu, 29 Oct 2026 05:43:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793277829; x=1793882629; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=8cAICDXVbsGS6wbaXs3gdjEVnoqC8ocmcUK18yxJKpU=; b=TgsM0Vq153Y5W0TmGLgcAMEfKw7UhPT9tFhkCbRDYgq+85Nb6FPVL2ODxgN34N3jYX n8RY7aiJvJnNqM09jupcWnbItpuSJjZgME8he8eDPQ/3zCs50eM7ouM4ZvomDWCipsAM IfpenBPRqIOZigsaa6sTMbumVgtpVEpohKFXzrojFauxqCxyYBoYE2CT6vWhSYZ1qaN4 HCj526WeDiqeosIQyge8Lp8aPnNuFUPo80vww8G+cAlzRklKxO4nAD/mBzKWKQdz1wry P/o3OxlLfdr4nzUDbT5dcYnKOfdiGLpZgJe7uu2LjPNUTu4JSeNy8RZ5eFUDglj3UOQR oGdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793277829; x=1793882629; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=8cAICDXVbsGS6wbaXs3gdjEVnoqC8ocmcUK18yxJKpU=; b=a7Q6TI/G/VaMmFSkQK4jezV34NrBhhL6ewFe+avJvvSHjq8XsUL9e8wWhfvPRpxKzB BDhO+3GvvyS73fx/LhjKela2ZTEJgboMlMBPoMWkT5QKmWF9KdenLain7awyVmtnvhHh SEWEhgh8LZBqgoMvO1FYdPoywiklH49DT28PmJjuymv/u1sf3nIcj57W7cTkYaApp2hj MHIEMirICMI1/KUPh6fuTxsQmVH1bUFqtiO6rKCa2EMlHMejTgI0dGdCWzMqvRH1G/jQ +4WKlAwTnN1WpJF4f8eQAg7ciRRVx66T2oxfQqDsCNHAY2KsYb2Z+bapu8kO2Q/jzNbq IQHg== X-Gm-Message-State: AFq9FYKqnkANP2hzTJkW9yzYtTW2K222WfN+LaV6f/bEXQUSj+MtVUVx mskSis02uskaSR7N1ChlRCSbPEY10Rl8qUGID5b3AAo8IVnPy4M0yzGBUwCfkQ== X-Gm-Gg: AYBFou2jzrvIo+6DGy5WFYJSfW5JJU/kESIe9iVBH+FvYMhhdzTWCD8a6diCOqgBJ01 OUPpsG+aAMBlkACY637MybG/6rQoUzv5ojZ6YSDqlB9mkYUFB4UtMY0yBe9UjO1Y1tB6hW/E9db +BUmJU+zEsqSOhMXwAPrXtKsii6kIUs8TLeFL9nJzldotuC+NvvBBxM8Wpb9SRl0AqEFKTlEDRO uuBUU8RJCnQu9AZfQ3qkXU8RphEIWZHlCwCHH3qn/lCTMCNjkbgc363fHT4neN/BOE9lPGk9b7F O7WDzH5k/IFADkDuBEfWfQfOwt0HsX6qeyBqD1b1DlFXAWOxo2bc8qwKAqA/FpuD6a8sO8dof3J W2q/jN47hYZzJADKYQIwJ2zlfubsn7RYHHBChDyol5qYsFiLv6c/4SvTFaAxNIe9U5QyJxAee/+ KjrP2QFYgg4vCExP4R4bySZ0WY3NUdq2uLqo8HcZ1G/tgYEZQMBIaX9yWqxVFHfsABEOFx9R4qX tRabOMpluESJJmE3aXM+UE3pTZUGFsPiFQMIXI+Dm1vYQw4NnS1HqKvzSmVaA6Vlerp0tLTb7Hj NbPcZhwkhwZN2879C6Ji0h4iAYKKn/29TG3VK/cBLbpLJQqH6ggHEZyGoOXDVmRdbeqsWhUq4n9 pHkBrWyyt+oA34TulPLiJQvqwjFvfLeKWuQAWtLrDVec5jJEylGHn9ZKOs7Z5VA== X-Received: by 2002:a05:701b:260d:b0:190:8f72:445e with SMTP id a92af1059eb24-1a6cbe7e41emr7673165c88.11.1793277829079; Thu, 29 Oct 2026 05:43:49 -0700 (PDT) Received: from DESKTOP-9B705LH (173-230-145-212.ip.linodeusercontent.com. [173.230.145.212]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1a75fdc1031sm15185607c88.19.2026.10.29.05.43.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2026 05:43:48 -0700 (PDT) From: trcrsired To: binutils@sourceware.org Cc: gdb-patches@sourceware.org Subject: [PATCH 1/1] Support building binutils-gdb for an Android (bionic) host Date: Thu, 29 Oct 2026 20:41:17 +0800 Message-ID: <20261029124117.13519-2-oyzawqgcfc@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261029124117.13519-1-oyzawqgcfc@gmail.com> References: <20261029124117.13519-1-oyzawqgcfc@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Building with --host=aarch64-linux-android30 failed because bionic is not glibc: - The compiler's does not expose PATH_MAX (bionic defines it in ), while defines MAXPATHLEN as PATH_MAX. Make PATH_MAX available from libiberty.h and gnulib's pathmax.h for __ANDROID__. - bionic's defines UINTPTR_WIDTH in terms of __UINTPTR_WIDTH__, which GCC does not predefine. Derive the width from the type in rawmemchr.c. - bionic's fortify headers do not compile from C++ with the Android GCC port, so do not define _FORTIFY_SOURCE for __ANDROID__. - Modern NDKs provide Elf32_auxv_t/Elf64_auxv_t, so stop assuming Android lacks them in gdbserver; linux-low.cc otherwise defines conflicting struct tags. - gprofng needs glibc facilities (pthread cancellation, dlinfo), so do not build it for android targets. / * configure.ac (enable_gprofng): Do not build gprofng for android targets. * configure: Regenerate. include/ChangeLog: * libiberty.h: Include on Android when PATH_MAX is not defined. --- configure | 2 +- configure.ac | 2 +- gdbserver/configure | 17 +---------------- gdbserver/configure.ac | 23 ++++++----------------- gdbsupport/common-defs.h | 2 +- gnulib/import/pathmax.h | 8 ++++++++ gnulib/import/rawmemchr.c | 8 +++++++- include/libiberty.h | 8 ++++++++ 8 files changed, 33 insertions(+), 37 deletions(-) diff --git a/configure b/configure index 2861694673e..1648f8f60c1 100755 --- a/configure +++ b/configure @@ -3203,7 +3203,7 @@ fi if test "$enable_gprofng" = "yes"; then case "${target}" in - *-musl*) + *-musl* | *-android*) ;; x86_64-*-linux* | i?86-*-linux* | aarch64-*-linux* | riscv64-*-linux*) configdirs="$configdirs gprofng" diff --git a/configure.ac b/configure.ac index cae0042411b..4a7a9e4916d 100644 --- a/configure.ac +++ b/configure.ac @@ -415,7 +415,7 @@ enable_gprofng=$enableval, enable_gprofng=yes) if test "$enable_gprofng" = "yes"; then case "${target}" in - *-musl*) + *-musl* | *-android*) ;; x86_64-*-linux* | i?86-*-linux* | aarch64-*-linux* | riscv64-*-linux*) configdirs="$configdirs gprofng" diff --git a/gdbserver/configure b/gdbserver/configure index e00e1e1c1c5..acb0eea610c 100755 --- a/gdbserver/configure +++ b/gdbserver/configure @@ -13269,20 +13269,7 @@ _ACEOF fi -case "${target}" in - *-android*) - # Starting with NDK version 9, actually includes definitions - # of Elf32_auxv_t and Elf64_auxv_t. But sadly, includes - # which defines some of the ELF types incorrectly, - # leading to conflicts with the definitions from . - # This makes it impossible for us to include both and - # , which means that, in practice, we do not have - # access to Elf32_auxv_t and Elf64_auxv_t on this platform. - # Therefore, do not try to auto-detect availability, as it would - # get it wrong on this platform. - ;; - *) - ac_fn_c_check_type "$LINENO" "Elf32_auxv_t" "ac_cv_type_Elf32_auxv_t" "#include +ac_fn_c_check_type "$LINENO" "Elf32_auxv_t" "ac_cv_type_Elf32_auxv_t" "#include " if test "x$ac_cv_type_Elf32_auxv_t" = xyes; then : @@ -13305,8 +13292,6 @@ _ACEOF fi -esac - # Check whether --with-pkgversion was given. diff --git a/gdbserver/configure.ac b/gdbserver/configure.ac index 16a2520baf4..cc73c22a580 100644 --- a/gdbserver/configure.ac +++ b/gdbserver/configure.ac @@ -109,23 +109,12 @@ AC_CHECK_TYPES(socklen_t, [], [], #endif ]) -case "${target}" in - *-android*) - # Starting with NDK version 9, actually includes definitions - # of Elf32_auxv_t and Elf64_auxv_t. But sadly, includes - # which defines some of the ELF types incorrectly, - # leading to conflicts with the definitions from . - # This makes it impossible for us to include both and - # , which means that, in practice, we do not have - # access to Elf32_auxv_t and Elf64_auxv_t on this platform. - # Therefore, do not try to auto-detect availability, as it would - # get it wrong on this platform. - ;; - *) - AC_CHECK_TYPES([Elf32_auxv_t, Elf64_auxv_t], [], [], - #include - ) -esac +# Modern NDKs expose Elf32_auxv_t/Elf64_auxv_t as typedefs in ; +# auto-detect them instead of assuming Android lacks them (the old NDK 9 +# conflict no longer exists). +AC_CHECK_TYPES([Elf32_auxv_t, Elf64_auxv_t], [], [], +#include +) ACX_PKGVERSION([GDB]) ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/]) diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h index 1c0ae0ad9d1..b29a81ada40 100644 --- a/gdbsupport/common-defs.h +++ b/gdbsupport/common-defs.h @@ -79,7 +79,7 @@ _FORTIFY_SOURCE there. */ #if (!defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__ > 0 \ - && !defined(__MINGW32__)) + && !defined(__MINGW32__) && !defined(__ANDROID__)) #define _FORTIFY_SOURCE 2 #endif diff --git a/gnulib/import/pathmax.h b/gnulib/import/pathmax.h index 19b93d7eab1..6749e699e94 100644 --- a/gnulib/import/pathmax.h +++ b/gnulib/import/pathmax.h @@ -47,6 +47,14 @@ # define _POSIX_PATH_MAX 256 # endif +# if defined __ANDROID__ && !defined PATH_MAX +/* bionic's defines MAXPATHLEN as PATH_MAX, but PATH_MAX + comes from and may not be exposed by the compiler's + . Include it here so that the MAXPATHLEN fallback below does + not define PATH_MAX in terms of itself. */ +# include +# endif + /* Don't include sys/param.h if it already has been. */ # if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN # include diff --git a/gnulib/import/rawmemchr.c b/gnulib/import/rawmemchr.c index ea68c1bfc6a..50d5918ba07 100644 --- a/gnulib/import/rawmemchr.c +++ b/gnulib/import/rawmemchr.c @@ -35,7 +35,13 @@ rawmemchr (const void *s, int c_in) /* Change this typedef to experiment with performance. */ typedef uintptr_t longword; /* If you change the "uintptr_t", you should change UINTPTR_WIDTH to match. - This verifies that the type does not have padding bits. */ + This verifies that the type does not have padding bits. bionic's + defines UINTPTR_WIDTH in terms of __UINTPTR_WIDTH__, which GCC + does not predefine, so derive the width from the type in that case. */ +#ifndef __UINTPTR_WIDTH__ +# undef UINTPTR_WIDTH +# define UINTPTR_WIDTH (sizeof (uintptr_t) * CHAR_BIT) +#endif verify (UINTPTR_WIDTH == UCHAR_WIDTH * sizeof (longword)); const unsigned char *char_ptr; diff --git a/include/libiberty.h b/include/libiberty.h index bdb491b9b37..6c1f31aa4f7 100644 --- a/include/libiberty.h +++ b/include/libiberty.h @@ -48,6 +48,14 @@ extern "C" { #include +/* bionic's defines MAXPATHLEN in terms of PATH_MAX, but + PATH_MAX lives in and is not exposed by every + compiler's . Make it available before any PATH_MAX or + MAXPATHLEN use. */ +#if defined (__ANDROID__) && !defined PATH_MAX +# include +#endif + /* If the OS supports it, ensure that the supplied stream is setup to avoid any multi-threaded locking. Otherwise leave the FILE pointer unchanged. If the stream is NULL do nothing. */ -- 2.56.0