From c8115e43580e517a04ba742f242cef44cd02bfcb Mon Sep 17 00:00:00 2001 From: Zhao Hang Date: Thu, 1 Jun 2023 16:40:39 +0800 Subject: [PATCH 1/6] update to annobin-10.94-1.el8 Signed-off-by: Zhao Hang --- annobin.spec | 69 ++++++++++++++++++++++++++++++++++++++++++++++------ download | 2 +- 2 files changed, 62 insertions(+), 9 deletions(-) diff --git a/annobin.spec b/annobin.spec index 9a94eeb..4402628 100644 --- a/annobin.spec +++ b/annobin.spec @@ -1,8 +1,8 @@ -%define anolis_release .0.1 + Name: annobin Summary: Annotate and examine compiled binary files -Version: 10.67 -Release: 3%{anolis_release}%{?dist} +Version: 10.94 +Release: 1%{?dist} License: GPLv3+ # Maintainer: nickc@redhat.com # Web Page: https://sourceware.org/annobin/ @@ -56,7 +56,6 @@ License: GPLv3+ %global annobin_sources annobin-%{version}.tar.xz Source: https://nickc.fedorapeople.org/%{annobin_sources} -# Source: %%{annobin_sources} # For the latest sources use: git clone git://sourceware.org/git/annobin.git # This is where a copy of the sources will be installed. @@ -103,7 +102,7 @@ Patch02: annobin-annocheck-no-debuginfod.patch # # The following implements the above: -%global gcc_vr %(gcc --version | head -n 1 | sed -e 's|.*(Anolis\ ||g' -e 's|)$||g') +%global gcc_vr %(gcc --version | head -n 1 | sed -e 's|.*(Red\ Hat\ ||g' -e 's|)$||g') # We need the major version of gcc. %global gcc_major %(echo "%{gcc_vr}" | cut -f1 -d".") @@ -157,6 +156,12 @@ Summary: Test scripts and binaries for checking the behaviour and output of the Provides a means to test the generation of annotated binaries and the parsing of the resulting files. +BuildRequires: make + +%if %{with debuginfod} +BuildRequires: elfutils-debuginfod-client-devel +%endif + %endif #--------------------------------------------------------------------------------- @@ -166,9 +171,11 @@ of the resulting files. Summary: A tool for checking the security hardening status of binaries BuildRequires: gcc elfutils elfutils-devel elfutils-libelf-devel rpm-devel binutils-devel make + %if %{with debuginfod} BuildRequires: elfutils-debuginfod-client-devel %endif + Requires: cpio rpm %description annocheck @@ -219,6 +226,12 @@ CONFIG_ARGS="--quiet --with-gcc-plugin-dir=%{ANNOBIN_GCC_PLUGIN_DIR}" %if %{with debuginfod} CONFIG_ARGS="$CONFIG_ARGS --with-debuginfod" %else +# Note - we explicitly disable debuginfod support if it was not configured. +# This is because by default annobin's configue script will assume --with-debuginfod=auto +# and then run a build time test to see if debugingfod is available. It +# may well be, but the build time environment may not match the run time +# environment, and the rpm will not have a Requirement on the debuginfod +# client. CONFIG_ARGS="$CONFIG_ARGS --without-debuginfod" %endif @@ -238,11 +251,18 @@ CONFIG_ARGS="$CONFIG_ARGS --with-llvm" CONFIG_ARGS="$CONFIG_ARGS --without-tests" %endif +%if %{without annocheck} +CONFIG_ARGS="$CONFIG_ARGS --without-annocheck" +%endif + %set_build_flags +export CFLAGS="$CFLAGS $RPM_OPT_FLAGS %build_cflags" +export LDFLAGS="$LDFLAGS %build_ldflags" + # Fedora supports AArch64's -mbranch-protection=bti, RHEL does not. %if 0%{?fedora} != 0 -export CFLAGS="$CFLAGS -DAARCh64_BRANCH_PROTECTION_SUPPORTED=1" +export CFLAGS="$CFLAGS -DAARCH64_BRANCH_PROTECTION_SUPPORTED=1" %endif CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" CXXFLAGS="$CFLAGS" %configure ${CONFIG_ARGS} || cat config.log @@ -293,6 +313,7 @@ make -C llvm-plugin all CXXFLAGS="$OPTS $BUILD_FLAGS" # PLUGIN_INSTALL_DIR is used by the Clang and LLVM makefiles... %install + %make_install PLUGIN_INSTALL_DIR=%{buildroot}/%{llvm_plugin_dir} %if %{with clangplugin} @@ -364,13 +385,45 @@ fi %{_libdir}/libannocheck.* %{_bindir}/annocheck %doc %{_mandir}/man1/annocheck.1.gz +%{_libdir}/pkgconfig/libannocheck.pc %endif #--------------------------------------------------------------------------------- %changelog -* Fri Nov 18 2022 Liwei Ge - 10.67-3.0.1 -- Parse Anolis GCC version +* Wed Dec 07 2022 Nick Clifton - 10.94-1 +- Rebase to 10.94. (#2151312) +- Annocheck: Better detection of binaries which do not contain code. (#2144533) +- Annocheck: Provide more information when a test is skipped because the file being tested was not compiled. +- Annocheck: Try harder not to run mutually exclusive tests. +- Tests: Fix future-test so that it properly handles the situation where the compiler does not support the new options. +- Libannocheck: Actually set result fields after tests are run. +- Libannocheck: Replace libannocheck_version variable with LIBANNOCHECK_VERSION define. +- Libannocheck: Remove 'Requires binutils-devel' from libannocheck.pc. +- Libannocheck: Move into separate sub-package. +- Libannocheck: Add libannocheck.pc pkgconfig file. +- Libannocheck: Add libannocheck_reinit(). +- GCC Plugin: Record -ftrivial-auto-var-init and -fzero-call-used-regs. +- Annocheck: Add future tests for -ftrivial-auto-var-init and -fzero-call-used-regs. +- Clang Plugin: Fix for building with Clang-15. (#2125875) +- Annocheck: Add a test for the inconsistent use of -Ofast. (#1248744) +- Plugin: Fix top level configuration support for RiscV. +- Annocheck: Improvements to the size tool. +- Annocheck: Fixes for libannocheck.h. +- Annocheck: Add automatic profile selection. +- Annocheck: Improve gap detection and reporting. +- Annocheck: Check build-id of separate debuginfo files. +- Annocheck: Add GAPS test replacing --ignore-gaps. +- Annocheck: Fix covscan detected race condition between stat() and open(). +- Annocheck: Handle binaries created by Rust 1.18. (#2094420) +- Annocheck: Add optional function name to --skip arguments. (PR 29229) +- Annocheck: Fix handling of command line options that take arguments. (#2086850) +- Annocheck: Do not complain about unenabled -mbranch-protection option in AArch64 binaries. (#2078909) +- gcc-plugin: Fix typo in configure.ac. +- Add support for RISC-V. +- Annocheck: Add another special case for glibc rpms. (#2083070) +- Annocheck: Do not complain about unenabled -mbranch-protection option in AArch64 binaries if compiled using LTO. (#2082146) +- Annocheck: Add more glibc exceptions + check PT_TLS segments. (#2081131) * Thu Jul 21 2022 Florian Weimer - 10.67-3 - Rebuild to switch back to system annobin (#2108721) diff --git a/download b/download index e069a9c..c70a92f 100644 --- a/download +++ b/download @@ -1 +1 @@ -54c13f3f7622d515b9e5247ecb0ebdc8 annobin-10.67.tar.xz +5df1f3bc1a69cdbe39e70618227f91b1 annobin-10.94.tar.xz -- Gitee From 820851037f32d0b2a273a10101ecb1cd4cf3366a Mon Sep 17 00:00:00 2001 From: pangqing Date: Wed, 20 Apr 2022 14:23:53 +0800 Subject: [PATCH 2/6] rebrand: parse Anolis gcc version Signed-off-by: Liwei Ge --- annobin.spec | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/annobin.spec b/annobin.spec index 4402628..95c7b02 100644 --- a/annobin.spec +++ b/annobin.spec @@ -1,8 +1,8 @@ - +%define anolis_release .0.1 Name: annobin Summary: Annotate and examine compiled binary files Version: 10.94 -Release: 1%{?dist} +Release: 1%{anolis_release}%{?dist} License: GPLv3+ # Maintainer: nickc@redhat.com # Web Page: https://sourceware.org/annobin/ @@ -102,7 +102,7 @@ Patch02: annobin-annocheck-no-debuginfod.patch # # The following implements the above: -%global gcc_vr %(gcc --version | head -n 1 | sed -e 's|.*(Red\ Hat\ ||g' -e 's|)$||g') +%global gcc_vr %(gcc --version | head -n 1 | sed -e 's|.*(Anolis\ ||g' -e 's|)$||g') # We need the major version of gcc. %global gcc_major %(echo "%{gcc_vr}" | cut -f1 -d".") @@ -391,6 +391,9 @@ fi #--------------------------------------------------------------------------------- %changelog +* Thu Jun 01 2023 Liwei Ge - 10.94-1.0.1 +- Parse Anolis GCC version + * Wed Dec 07 2022 Nick Clifton - 10.94-1 - Rebase to 10.94. (#2151312) - Annocheck: Better detection of binaries which do not contain code. (#2144533) -- Gitee From 241ce57612fa85e6c796ba0aee3136d2f35adf0d Mon Sep 17 00:00:00 2001 From: wb-zh951434 Date: Fri, 30 Jun 2023 11:26:26 +0800 Subject: [PATCH 3/6] Remove loongarch64 arch Signed-off-by: wb-zh951434 --- annobin.spec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/annobin.spec b/annobin.spec index 95c7b02..2bdce12 100644 --- a/annobin.spec +++ b/annobin.spec @@ -9,7 +9,7 @@ License: GPLv3+ # Watermark Protocol: https://fedoraproject.org/wiki/Toolchain/Watermark #--------------------------------------------------------------------------------- - +Excludearch: loongarch64 # Use "--without tests" to disable the testsuite. %bcond_without tests @@ -393,6 +393,7 @@ fi %changelog * Thu Jun 01 2023 Liwei Ge - 10.94-1.0.1 - Parse Anolis GCC version +- Remove loongarch64 arch (Zhao Hang) * Wed Dec 07 2022 Nick Clifton - 10.94-1 - Rebase to 10.94. (#2151312) -- Gitee From 9aa6fa7403a946e47cca6f6520e5228026837442 Mon Sep 17 00:00:00 2001 From: Zhao Hang Date: Tue, 5 Dec 2023 14:11:43 +0800 Subject: [PATCH 4/6] update to annobin-11.13-2.src.rpm Signed-off-by: Zhao Hang --- annobin-annocheck-no-debuginfod.patch | 9 ++-- annobin.spec | 64 +++++++++++++++++++-------- download | 2 +- 3 files changed, 51 insertions(+), 24 deletions(-) diff --git a/annobin-annocheck-no-debuginfod.patch b/annobin-annocheck-no-debuginfod.patch index 19f0d39..4483df3 100644 --- a/annobin-annocheck-no-debuginfod.patch +++ b/annobin-annocheck-no-debuginfod.patch @@ -1,11 +1,12 @@ ---- annobin.orig/annocheck/annocheck.c 2022-03-24 11:58:57.549279537 +0000 -+++ annobin-10.58/annocheck/annocheck.c 2022-03-24 11:59:09.574237612 +0000 -@@ -21,6 +21,8 @@ +diff -rup annobin.orig/annocheck/annocheck.c annobin-11.12/annocheck/annocheck.c +--- annobin.orig/annocheck/annocheck.c 2023-03-03 16:09:24.659603476 +0000 ++++ annobin-11.12/annocheck/annocheck.c 2023-03-03 16:09:57.249530355 +0000 +@@ -20,6 +20,8 @@ #include #include #include +#undef HAVE_LIBDEBUGINFOD +#define HAVE_LIBDEBUGINFOD 0 #ifndef LIBANNOCHECK + #include #if HAVE_LIBDEBUGINFOD - #include diff --git a/annobin.spec b/annobin.spec index 2bdce12..4e73308 100644 --- a/annobin.spec +++ b/annobin.spec @@ -1,22 +1,22 @@ -%define anolis_release .0.1 + Name: annobin Summary: Annotate and examine compiled binary files -Version: 10.94 -Release: 1%{anolis_release}%{?dist} +Version: 11.13 +Release: 2%{?dist} License: GPLv3+ # Maintainer: nickc@redhat.com # Web Page: https://sourceware.org/annobin/ # Watermark Protocol: https://fedoraproject.org/wiki/Toolchain/Watermark #--------------------------------------------------------------------------------- -Excludearch: loongarch64 + # Use "--without tests" to disable the testsuite. %bcond_without tests # Use "--without annocheck" to disable the installation of the annocheck program. %bcond_without annocheck -# Use "--with debuginfod" to add support for debuginfod to be compiled into +# Use "--with debuginfod" to force support for debuginfod to be compiled into # the annocheck program. By default the configure script will check for # availablilty at build time, but this might not match the run time situation. # FIXME: Add a --without debuginfod option to forcefully disable the configure @@ -62,8 +62,6 @@ Source: https://nickc.fedorapeople.org/%{annobin_sources} %global annobin_source_dir %{_usrsrc}/annobin # Insert patches here, if needed. Eg: -# Patch01: annobin-foo.patch -# Insert patches here, if needed. Patch01: annobin-nop.patch Patch02: annobin-annocheck-no-debuginfod.patch @@ -102,7 +100,7 @@ Patch02: annobin-annocheck-no-debuginfod.patch # # The following implements the above: -%global gcc_vr %(gcc --version | head -n 1 | sed -e 's|.*(Anolis\ ||g' -e 's|)$||g') +%global gcc_vr %(gcc --version | head -n 1 | sed -e 's|.*(Red\ Hat\ ||g' -e 's|)$||g') # We need the major version of gcc. %global gcc_major %(echo "%{gcc_vr}" | cut -f1 -d".") @@ -121,7 +119,7 @@ Requires: (gcc >= %{gcc_major} with gcc < %{gcc_next}) Requires: gcc %endif -BuildRequires: gcc gcc-plugin-devel gcc-c++ +BuildRequires: gcc gcc-plugin-devel gcc-c++ sharutils # The documentation uses pod2man... BuildRequires: perl perl-podlators %if %{with clangplugin} @@ -156,7 +154,7 @@ Summary: Test scripts and binaries for checking the behaviour and output of the Provides a means to test the generation of annotated binaries and the parsing of the resulting files. -BuildRequires: make +BuildRequires: make sharutils %if %{with debuginfod} BuildRequires: elfutils-debuginfod-client-devel @@ -340,13 +338,17 @@ rm -f %{buildroot}%{_infodir}/dir %if %{with tests} %check -# Change the following line to "make check || :" on RHEL7 or if you need to see the -# test suite logs in order to diagnose a test failure. -make -k check CLANG_TESTS="check-pre-clang-13" - +# The first "make check" is run with "|| :" so that we can capture any logs +# from failed tests. The second "make check" is there so that the build +# will fail if any of the tests fail. +make check CLANG_TESTS="check-pre-clang-13" || : if [ -f tests/test-suite.log ]; then - cat tests/*.log + cat tests/test-suite.log fi +# If necessary use uuencode to preserve test binaries here. For example: +uuencode tests/tmp_atexit/atexit.strip atexit.strip +make check CLANG_TESTS="check-pre-clang-13" + %endif #--------------------------------------------------------------------------------- @@ -383,17 +385,41 @@ fi %files annocheck %{_includedir}/libannocheck.h %{_libdir}/libannocheck.* +%{_libdir}/pkgconfig/libannocheck.pc %{_bindir}/annocheck %doc %{_mandir}/man1/annocheck.1.gz -%{_libdir}/pkgconfig/libannocheck.pc %endif #--------------------------------------------------------------------------------- %changelog -* Thu Jun 01 2023 Liwei Ge - 10.94-1.0.1 -- Parse Anolis GCC version -- Remove loongarch64 arch (Zhao Hang) +* Mon Jul 10 2023 Marek Polacek - 11.13-2 +- NVR bump to allow rebuilding. (#2218984) + +* Thu Mar 09 2023 Nick Clifton - 11.13-1 +- NVR bump to allow rebuilding. (#2162746) + +* Fri Mar 03 2023 Nick Clifton - 11.12-1 +- Rebase to 11.12. Brings in: +- GCC Plugin: Do not run if other plugins are active. (#2162746) +- Annocheck: Add code to handle glibc functions built without LTO. +- Libannocheck: Fix thinko in debugging code. +- Annocheck: Fix LTO test. +- Notes: Display notes held in separate debuginfo files. +- Annocheck: Fix atexit test. Fix recording of version numbers. (#2165528) +- LLVM & Clang Plugins: Build with branch protection on AArch64. (#2164364) +- Libannocheck: Fix bug causing infinite looping when running tests. +- Annocheck: Fix handling of file built by multiple versions of gcc. (#2160700) +- Annocheck: Fix handling of empty files. (#2159292) +- Annocheck: Add crti.o and crtn.o to the list of known glibc special files. (#2158740) +- Annocheck: Fix memory leaks. +- Annocheck: Do not treat object files as if they did not contain any code. (#2158182) +- Annocheck: Add more special glibc filenames. +- Annocheck: Improve handling of tool versions. +- GCC plugin: Fix building with gcc-13. +- Annocheck: Add test for binaries built by cross compilers. +- Annocheck: Improve heuristic used to detect binaries without code. (#2144533) +- Annocheck: Avoid using debug filename when parsing notes in a debuginfo file. (#2152280) * Wed Dec 07 2022 Nick Clifton - 10.94-1 - Rebase to 10.94. (#2151312) diff --git a/download b/download index c70a92f..e26122c 100644 --- a/download +++ b/download @@ -1 +1 @@ -5df1f3bc1a69cdbe39e70618227f91b1 annobin-10.94.tar.xz +26303b30aacfcf69521bb48a760b88a0 annobin-11.13.tar.xz -- Gitee From f4d54172f2dac30d6412f03043d90cca5dcb432e Mon Sep 17 00:00:00 2001 From: pangqing Date: Wed, 20 Apr 2022 14:23:53 +0800 Subject: [PATCH 5/6] rebrand: parse Anolis gcc version Signed-off-by: Liwei Ge --- annobin.spec | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/annobin.spec b/annobin.spec index 4e73308..4337899 100644 --- a/annobin.spec +++ b/annobin.spec @@ -1,8 +1,8 @@ - +%define anolis_release .0.1 Name: annobin Summary: Annotate and examine compiled binary files Version: 11.13 -Release: 2%{?dist} +Release: 2%{anolis_release}%{?dist} License: GPLv3+ # Maintainer: nickc@redhat.com # Web Page: https://sourceware.org/annobin/ @@ -100,7 +100,7 @@ Patch02: annobin-annocheck-no-debuginfod.patch # # The following implements the above: -%global gcc_vr %(gcc --version | head -n 1 | sed -e 's|.*(Red\ Hat\ ||g' -e 's|)$||g') +%global gcc_vr %(gcc --version | head -n 1 | sed -e 's|.*(Anolis\ ||g' -e 's|)$||g') # We need the major version of gcc. %global gcc_major %(echo "%{gcc_vr}" | cut -f1 -d".") @@ -393,6 +393,9 @@ make check CLANG_TESTS="check-pre-clang-13" #--------------------------------------------------------------------------------- %changelog +* Wed Dec 06 2023 Liwei Ge - 11.13-2.0.1 +- Parse Anolis GCC version + * Mon Jul 10 2023 Marek Polacek - 11.13-2 - NVR bump to allow rebuilding. (#2218984) -- Gitee From e67bde6735da0c27c0c8872dce2daa9554acd748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=B7=E5=90=8E=E9=93=B6?= <@kanghou-silver> Date: Mon, 29 Jul 2024 14:59:23 +0800 Subject: [PATCH 6/6] add sw arch --- annobin-11.13-sw.patch | 944 +++++++++++++++++++++++++++++++++++++++++ annobin.spec | 12 +- 2 files changed, 952 insertions(+), 4 deletions(-) create mode 100644 annobin-11.13-sw.patch diff --git a/annobin-11.13-sw.patch b/annobin-11.13-sw.patch new file mode 100644 index 0000000..f557f8d --- /dev/null +++ b/annobin-11.13-sw.patch @@ -0,0 +1,944 @@ +diff -Nuar annobin-11.13.org/annocheck/annocheck.c annobin-11.13.sw/annocheck/annocheck.c +--- annobin-11.13.org/annocheck/annocheck.c 2024-07-17 16:23:59.451184963 +0800 ++++ annobin-11.13.sw/annocheck/annocheck.c 2024-07-17 16:25:00.440296496 +0800 +@@ -20,8 +20,6 @@ + #include + #include + #include +-#undef HAVE_LIBDEBUGINFOD +-#define HAVE_LIBDEBUGINFOD 0 + #ifndef LIBANNOCHECK + #include + #if HAVE_LIBDEBUGINFOD +diff -Nuar annobin-11.13.org/annocheck/demangle.h annobin-11.13.sw/annocheck/demangle.h +--- annobin-11.13.org/annocheck/demangle.h 1970-01-01 08:00:00.000000000 +0800 ++++ annobin-11.13.sw/annocheck/demangle.h 2024-07-17 16:25:00.439296461 +0800 +@@ -0,0 +1,724 @@ ++/* Defs for interface to demanglers. ++ Copyright (C) 1992-2024 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Library General Public License ++ as published by the Free Software Foundation; either version 2, or ++ (at your option) any later version. ++ ++ In addition to the permissions in the GNU Library General Public ++ License, the Free Software Foundation gives you unlimited ++ permission to link the compiled version of this file into ++ combinations with other programs, and to distribute those ++ combinations without any restriction coming from the use of this ++ file. (The Library Public License restrictions do apply in other ++ respects; for example, they cover modification of the file, and ++ distribution when not linked into a combined executable.) ++ ++ This program is distributed in the hope that it will be useful, but ++ WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Library General Public License for more details. ++ ++ You should have received a copy of the GNU Library General Public ++ License along with this program; if not, write to the Free Software ++ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA ++ 02110-1301, USA. */ ++ ++ ++#if !defined (DEMANGLE_H) ++#define DEMANGLE_H ++ ++#include "libiberty.h" ++ ++#ifdef __cplusplus ++extern "C" { ++#endif /* __cplusplus */ ++ ++/* Options passed to cplus_demangle (in 2nd parameter). */ ++ ++#define DMGL_NO_OPTS 0 /* For readability... */ ++#define DMGL_PARAMS (1 << 0) /* Include function args */ ++#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ ++#define DMGL_JAVA (1 << 2) /* Demangle as Java rather than C++. */ ++#define DMGL_VERBOSE (1 << 3) /* Include implementation details. */ ++#define DMGL_TYPES (1 << 4) /* Also try to demangle type encodings. */ ++#define DMGL_RET_POSTFIX (1 << 5) /* Print function return types (when ++ present) after function signature. ++ It applies only to the toplevel ++ function type. */ ++#define DMGL_RET_DROP (1 << 6) /* Suppress printing function return ++ types, even if present. It applies ++ only to the toplevel function type. ++ */ ++ ++#define DMGL_AUTO (1 << 8) ++#define DMGL_GNU_V3 (1 << 14) ++#define DMGL_GNAT (1 << 15) ++#define DMGL_DLANG (1 << 16) ++#define DMGL_RUST (1 << 17) /* Rust wraps GNU_V3 style mangling. */ ++ ++/* If none of these are set, use 'current_demangling_style' as the default. */ ++#define DMGL_STYLE_MASK (DMGL_AUTO|DMGL_GNU_V3|DMGL_JAVA|DMGL_GNAT|DMGL_DLANG|DMGL_RUST) ++ ++/* Disable a limit on the depth of recursion in mangled strings. ++ Note if this limit is disabled then stack exhaustion is possible when ++ demangling pathologically complicated strings. Bug reports about stack ++ exhaustion when the option is enabled will be rejected. */ ++#define DMGL_NO_RECURSE_LIMIT (1 << 18) ++ ++/* If DMGL_NO_RECURSE_LIMIT is not enabled, then this is the value used as ++ the maximum depth of recursion allowed. It should be enough for any ++ real-world mangled name. */ ++#define DEMANGLE_RECURSION_LIMIT 2048 ++ ++/* Enumeration of possible demangling styles. ++ ++ Lucid and ARM styles are still kept logically distinct, even though ++ they now both behave identically. The resulting style is actual the ++ union of both. I.E. either style recognizes both "__pt__" and "__rf__" ++ for operator "->", even though the first is lucid style and the second ++ is ARM style. (FIXME?) */ ++ ++extern enum demangling_styles ++{ ++ no_demangling = -1, ++ unknown_demangling = 0, ++ auto_demangling = DMGL_AUTO, ++ gnu_v3_demangling = DMGL_GNU_V3, ++ java_demangling = DMGL_JAVA, ++ gnat_demangling = DMGL_GNAT, ++ dlang_demangling = DMGL_DLANG, ++ rust_demangling = DMGL_RUST ++} current_demangling_style; ++ ++/* Define string names for the various demangling styles. */ ++ ++#define NO_DEMANGLING_STYLE_STRING "none" ++#define AUTO_DEMANGLING_STYLE_STRING "auto" ++#define GNU_V3_DEMANGLING_STYLE_STRING "gnu-v3" ++#define JAVA_DEMANGLING_STYLE_STRING "java" ++#define GNAT_DEMANGLING_STYLE_STRING "gnat" ++#define DLANG_DEMANGLING_STYLE_STRING "dlang" ++#define RUST_DEMANGLING_STYLE_STRING "rust" ++ ++/* Some macros to test what demangling style is active. */ ++ ++#define CURRENT_DEMANGLING_STYLE current_demangling_style ++#define AUTO_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_AUTO) ++#define GNU_V3_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU_V3) ++#define JAVA_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_JAVA) ++#define GNAT_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNAT) ++#define DLANG_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_DLANG) ++#define RUST_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_RUST) ++ ++/* Provide information about the available demangle styles. This code is ++ pulled from gdb into libiberty because it is useful to binutils also. */ ++ ++extern const struct demangler_engine ++{ ++ const char *const demangling_style_name; ++ const enum demangling_styles demangling_style; ++ const char *const demangling_style_doc; ++} libiberty_demanglers[]; ++ ++extern char * ++cplus_demangle (const char *mangled, int options); ++ ++/* Note: This sets global state. FIXME if you care about multi-threading. */ ++ ++extern enum demangling_styles ++cplus_demangle_set_style (enum demangling_styles style); ++ ++extern enum demangling_styles ++cplus_demangle_name_to_style (const char *name); ++ ++/* Callback typedef for allocation-less demangler interfaces. */ ++typedef void (*demangle_callbackref) (const char *, size_t, void *); ++ ++/* V3 ABI demangling entry points, defined in cp-demangle.c. Callback ++ variants return non-zero on success, zero on error. char* variants ++ return a string allocated by malloc on success, NULL on error. */ ++extern int ++cplus_demangle_v3_callback (const char *mangled, int options, ++ demangle_callbackref callback, void *opaque); ++ ++extern char* ++cplus_demangle_v3 (const char *mangled, int options); ++ ++extern int ++java_demangle_v3_callback (const char *mangled, ++ demangle_callbackref callback, void *opaque); ++ ++extern char* ++java_demangle_v3 (const char *mangled); ++ ++char * ++ada_demangle (const char *mangled, int options); ++ ++extern char * ++dlang_demangle (const char *mangled, int options); ++ ++extern int ++rust_demangle_callback (const char *mangled, int options, ++ demangle_callbackref callback, void *opaque); ++ ++ ++extern char * ++rust_demangle (const char *mangled, int options); ++ ++enum gnu_v3_ctor_kinds { ++ gnu_v3_complete_object_ctor = 1, ++ gnu_v3_base_object_ctor, ++ gnu_v3_complete_object_allocating_ctor, ++ /* These are not part of the V3 ABI. Unified constructors are generated ++ as a speed-for-space optimization when the -fdeclone-ctor-dtor option ++ is used, and are always internal symbols. */ ++ gnu_v3_unified_ctor, ++ gnu_v3_object_ctor_group ++}; ++ ++/* Return non-zero iff NAME is the mangled form of a constructor name ++ in the G++ V3 ABI demangling style. Specifically, return an `enum ++ gnu_v3_ctor_kinds' value indicating what kind of constructor ++ it is. */ ++extern enum gnu_v3_ctor_kinds ++ is_gnu_v3_mangled_ctor (const char *name); ++ ++ ++enum gnu_v3_dtor_kinds { ++ gnu_v3_deleting_dtor = 1, ++ gnu_v3_complete_object_dtor, ++ gnu_v3_base_object_dtor, ++ /* These are not part of the V3 ABI. Unified destructors are generated ++ as a speed-for-space optimization when the -fdeclone-ctor-dtor option ++ is used, and are always internal symbols. */ ++ gnu_v3_unified_dtor, ++ gnu_v3_object_dtor_group ++}; ++ ++/* Return non-zero iff NAME is the mangled form of a destructor name ++ in the G++ V3 ABI demangling style. Specifically, return an `enum ++ gnu_v3_dtor_kinds' value, indicating what kind of destructor ++ it is. */ ++extern enum gnu_v3_dtor_kinds ++ is_gnu_v3_mangled_dtor (const char *name); ++ ++/* The V3 demangler works in two passes. The first pass builds a tree ++ representation of the mangled name, and the second pass turns the ++ tree representation into a demangled string. Here we define an ++ interface to permit a caller to build their own tree ++ representation, which they can pass to the demangler to get a ++ demangled string. This can be used to canonicalize user input into ++ something which the demangler might output. It could also be used ++ by other demanglers in the future. */ ++ ++/* These are the component types which may be found in the tree. Many ++ component types have one or two subtrees, referred to as left and ++ right (a component type with only one subtree puts it in the left ++ subtree). */ ++ ++enum demangle_component_type ++{ ++ /* A name, with a length and a pointer to a string. */ ++ DEMANGLE_COMPONENT_NAME, ++ /* A qualified name. The left subtree is a class or namespace or ++ some such thing, and the right subtree is a name qualified by ++ that class. */ ++ DEMANGLE_COMPONENT_QUAL_NAME, ++ /* A local name. The left subtree describes a function, and the ++ right subtree is a name which is local to that function. */ ++ DEMANGLE_COMPONENT_LOCAL_NAME, ++ /* A typed name. The left subtree is a name, and the right subtree ++ describes that name as a function. */ ++ DEMANGLE_COMPONENT_TYPED_NAME, ++ /* A template. The left subtree is a template name, and the right ++ subtree is a template argument list. */ ++ DEMANGLE_COMPONENT_TEMPLATE, ++ /* A template parameter. This holds a number, which is the template ++ parameter index. */ ++ DEMANGLE_COMPONENT_TEMPLATE_PARAM, ++ /* A function parameter. This holds a number, which is the index. */ ++ DEMANGLE_COMPONENT_FUNCTION_PARAM, ++ /* A constructor. This holds a name and the kind of ++ constructor. */ ++ DEMANGLE_COMPONENT_CTOR, ++ /* A destructor. This holds a name and the kind of destructor. */ ++ DEMANGLE_COMPONENT_DTOR, ++ /* A vtable. This has one subtree, the type for which this is a ++ vtable. */ ++ DEMANGLE_COMPONENT_VTABLE, ++ /* A VTT structure. This has one subtree, the type for which this ++ is a VTT. */ ++ DEMANGLE_COMPONENT_VTT, ++ /* A construction vtable. The left subtree is the type for which ++ this is a vtable, and the right subtree is the derived type for ++ which this vtable is built. */ ++ DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE, ++ /* A typeinfo structure. This has one subtree, the type for which ++ this is the tpeinfo structure. */ ++ DEMANGLE_COMPONENT_TYPEINFO, ++ /* A typeinfo name. This has one subtree, the type for which this ++ is the typeinfo name. */ ++ DEMANGLE_COMPONENT_TYPEINFO_NAME, ++ /* A typeinfo function. This has one subtree, the type for which ++ this is the tpyeinfo function. */ ++ DEMANGLE_COMPONENT_TYPEINFO_FN, ++ /* A thunk. This has one subtree, the name for which this is a ++ thunk. */ ++ DEMANGLE_COMPONENT_THUNK, ++ /* A virtual thunk. This has one subtree, the name for which this ++ is a virtual thunk. */ ++ DEMANGLE_COMPONENT_VIRTUAL_THUNK, ++ /* A covariant thunk. This has one subtree, the name for which this ++ is a covariant thunk. */ ++ DEMANGLE_COMPONENT_COVARIANT_THUNK, ++ /* A Java class. This has one subtree, the type. */ ++ DEMANGLE_COMPONENT_JAVA_CLASS, ++ /* A guard variable. This has one subtree, the name for which this ++ is a guard variable. */ ++ DEMANGLE_COMPONENT_GUARD, ++ /* The init and wrapper functions for C++11 thread_local variables. */ ++ DEMANGLE_COMPONENT_TLS_INIT, ++ DEMANGLE_COMPONENT_TLS_WRAPPER, ++ /* A reference temporary. This has one subtree, the name for which ++ this is a temporary. */ ++ DEMANGLE_COMPONENT_REFTEMP, ++ /* A hidden alias. This has one subtree, the encoding for which it ++ is providing alternative linkage. */ ++ DEMANGLE_COMPONENT_HIDDEN_ALIAS, ++ /* A standard substitution. This holds the name of the ++ substitution. */ ++ DEMANGLE_COMPONENT_SUB_STD, ++ /* The restrict qualifier. The one subtree is the type which is ++ being qualified. */ ++ DEMANGLE_COMPONENT_RESTRICT, ++ /* The volatile qualifier. The one subtree is the type which is ++ being qualified. */ ++ DEMANGLE_COMPONENT_VOLATILE, ++ /* The const qualifier. The one subtree is the type which is being ++ qualified. */ ++ DEMANGLE_COMPONENT_CONST, ++ /* The restrict qualifier modifying a member function. The one ++ subtree is the type which is being qualified. */ ++ DEMANGLE_COMPONENT_RESTRICT_THIS, ++ /* The volatile qualifier modifying a member function. The one ++ subtree is the type which is being qualified. */ ++ DEMANGLE_COMPONENT_VOLATILE_THIS, ++ /* The const qualifier modifying a member function. The one subtree ++ is the type which is being qualified. */ ++ DEMANGLE_COMPONENT_CONST_THIS, ++ /* C++11 A reference modifying a member function. The one subtree is the ++ type which is being referenced. */ ++ DEMANGLE_COMPONENT_REFERENCE_THIS, ++ /* C++11: An rvalue reference modifying a member function. The one ++ subtree is the type which is being referenced. */ ++ DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS, ++ /* A vendor qualifier. The left subtree is the type which is being ++ qualified, and the right subtree is the name of the ++ qualifier. */ ++ DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL, ++ /* A pointer. The one subtree is the type which is being pointed ++ to. */ ++ DEMANGLE_COMPONENT_POINTER, ++ /* A reference. The one subtree is the type which is being ++ referenced. */ ++ DEMANGLE_COMPONENT_REFERENCE, ++ /* C++0x: An rvalue reference. The one subtree is the type which is ++ being referenced. */ ++ DEMANGLE_COMPONENT_RVALUE_REFERENCE, ++ /* A complex type. The one subtree is the base type. */ ++ DEMANGLE_COMPONENT_COMPLEX, ++ /* An imaginary type. The one subtree is the base type. */ ++ DEMANGLE_COMPONENT_IMAGINARY, ++ /* A builtin type. This holds the builtin type information. */ ++ DEMANGLE_COMPONENT_BUILTIN_TYPE, ++ /* A vendor's builtin type. This holds the name of the type. */ ++ DEMANGLE_COMPONENT_VENDOR_TYPE, ++ /* A function type. The left subtree is the return type. The right ++ subtree is a list of ARGLIST nodes. Either or both may be ++ NULL. */ ++ DEMANGLE_COMPONENT_FUNCTION_TYPE, ++ /* An array type. The left subtree is the dimension, which may be ++ NULL, or a string (represented as DEMANGLE_COMPONENT_NAME), or an ++ expression. The right subtree is the element type. */ ++ DEMANGLE_COMPONENT_ARRAY_TYPE, ++ /* A pointer to member type. The left subtree is the class type, ++ and the right subtree is the member type. CV-qualifiers appear ++ on the latter. */ ++ DEMANGLE_COMPONENT_PTRMEM_TYPE, ++ /* A fixed-point type. */ ++ DEMANGLE_COMPONENT_FIXED_TYPE, ++ /* A vector type. The left subtree is the number of elements, ++ the right subtree is the element type. */ ++ DEMANGLE_COMPONENT_VECTOR_TYPE, ++ /* An argument list. The left subtree is the current argument, and ++ the right subtree is either NULL or another ARGLIST node. */ ++ DEMANGLE_COMPONENT_ARGLIST, ++ /* A template argument list. The left subtree is the current ++ template argument, and the right subtree is either NULL or ++ another TEMPLATE_ARGLIST node. */ ++ DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, ++ /* A template parameter object (C++20). The left subtree is the ++ corresponding template argument. */ ++ DEMANGLE_COMPONENT_TPARM_OBJ, ++ /* An initializer list. The left subtree is either an explicit type or ++ NULL, and the right subtree is a DEMANGLE_COMPONENT_ARGLIST. */ ++ DEMANGLE_COMPONENT_INITIALIZER_LIST, ++ /* An operator. This holds information about a standard ++ operator. */ ++ DEMANGLE_COMPONENT_OPERATOR, ++ /* An extended operator. This holds the number of arguments, and ++ the name of the extended operator. */ ++ DEMANGLE_COMPONENT_EXTENDED_OPERATOR, ++ /* A typecast, represented as a unary operator. The one subtree is ++ the type to which the argument should be cast. */ ++ DEMANGLE_COMPONENT_CAST, ++ /* A conversion operator, represented as a unary operator. The one ++ subtree is the type to which the argument should be converted ++ to. */ ++ DEMANGLE_COMPONENT_CONVERSION, ++ /* A nullary expression. The left subtree is the operator. */ ++ DEMANGLE_COMPONENT_NULLARY, ++ /* A unary expression. The left subtree is the operator, and the ++ right subtree is the single argument. */ ++ DEMANGLE_COMPONENT_UNARY, ++ /* A binary expression. The left subtree is the operator, and the ++ right subtree is a BINARY_ARGS. */ ++ DEMANGLE_COMPONENT_BINARY, ++ /* Arguments to a binary expression. The left subtree is the first ++ argument, and the right subtree is the second argument. */ ++ DEMANGLE_COMPONENT_BINARY_ARGS, ++ /* A trinary expression. The left subtree is the operator, and the ++ right subtree is a TRINARY_ARG1. */ ++ DEMANGLE_COMPONENT_TRINARY, ++ /* Arguments to a trinary expression. The left subtree is the first ++ argument, and the right subtree is a TRINARY_ARG2. */ ++ DEMANGLE_COMPONENT_TRINARY_ARG1, ++ /* More arguments to a trinary expression. The left subtree is the ++ second argument, and the right subtree is the third argument. */ ++ DEMANGLE_COMPONENT_TRINARY_ARG2, ++ /* A literal. The left subtree is the type, and the right subtree ++ is the value, represented as a DEMANGLE_COMPONENT_NAME. */ ++ DEMANGLE_COMPONENT_LITERAL, ++ /* A negative literal. Like LITERAL, but the value is negated. ++ This is a minor hack: the NAME used for LITERAL points directly ++ to the mangled string, but since negative numbers are mangled ++ using 'n' instead of '-', we want a way to indicate a negative ++ number which involves neither modifying the mangled string nor ++ allocating a new copy of the literal in memory. */ ++ DEMANGLE_COMPONENT_LITERAL_NEG, ++ /* A vendor's builtin expression. The left subtree holds the ++ expression's name, and the right subtree is a argument list. */ ++ DEMANGLE_COMPONENT_VENDOR_EXPR, ++ /* A libgcj compiled resource. The left subtree is the name of the ++ resource. */ ++ DEMANGLE_COMPONENT_JAVA_RESOURCE, ++ /* A name formed by the concatenation of two parts. The left ++ subtree is the first part and the right subtree the second. */ ++ DEMANGLE_COMPONENT_COMPOUND_NAME, ++ /* A name formed by a single character. */ ++ DEMANGLE_COMPONENT_CHARACTER, ++ /* A number. */ ++ DEMANGLE_COMPONENT_NUMBER, ++ /* A decltype type. */ ++ DEMANGLE_COMPONENT_DECLTYPE, ++ /* Global constructors keyed to name. */ ++ DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS, ++ /* Global destructors keyed to name. */ ++ DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS, ++ /* A lambda closure type. */ ++ DEMANGLE_COMPONENT_LAMBDA, ++ /* A default argument scope. */ ++ DEMANGLE_COMPONENT_DEFAULT_ARG, ++ /* An unnamed type. */ ++ DEMANGLE_COMPONENT_UNNAMED_TYPE, ++ /* A transactional clone. This has one subtree, the encoding for ++ which it is providing alternative linkage. */ ++ DEMANGLE_COMPONENT_TRANSACTION_CLONE, ++ /* A non-transactional clone entry point. In the i386/x86_64 abi, ++ the unmangled symbol of a tm_callable becomes a thunk and the ++ non-transactional function version is mangled thus. */ ++ DEMANGLE_COMPONENT_NONTRANSACTION_CLONE, ++ /* A pack expansion. */ ++ DEMANGLE_COMPONENT_PACK_EXPANSION, ++ /* A name with an ABI tag. */ ++ DEMANGLE_COMPONENT_TAGGED_NAME, ++ /* A transaction-safe function type. */ ++ DEMANGLE_COMPONENT_TRANSACTION_SAFE, ++ /* A cloned function. */ ++ DEMANGLE_COMPONENT_CLONE, ++ DEMANGLE_COMPONENT_NOEXCEPT, ++ DEMANGLE_COMPONENT_THROW_SPEC, ++ ++ DEMANGLE_COMPONENT_STRUCTURED_BINDING, ++ ++ DEMANGLE_COMPONENT_MODULE_NAME, ++ DEMANGLE_COMPONENT_MODULE_PARTITION, ++ DEMANGLE_COMPONENT_MODULE_ENTITY, ++ DEMANGLE_COMPONENT_MODULE_INIT, ++ ++ DEMANGLE_COMPONENT_TEMPLATE_HEAD, ++ DEMANGLE_COMPONENT_TEMPLATE_TYPE_PARM, ++ DEMANGLE_COMPONENT_TEMPLATE_NON_TYPE_PARM, ++ DEMANGLE_COMPONENT_TEMPLATE_TEMPLATE_PARM, ++ DEMANGLE_COMPONENT_TEMPLATE_PACK_PARM, ++ ++ /* A builtin type with argument. This holds the builtin type ++ information. */ ++ DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE ++ ++}; ++ ++/* Types which are only used internally. */ ++ ++struct demangle_operator_info; ++struct demangle_builtin_type_info; ++ ++/* A node in the tree representation is an instance of a struct ++ demangle_component. Note that the field names of the struct are ++ not well protected against macros defined by the file including ++ this one. We can fix this if it ever becomes a problem. */ ++ ++struct demangle_component ++{ ++ /* The type of this component. */ ++ enum demangle_component_type type; ++ ++ /* Guard against recursive component printing. ++ Initialize to zero. Private to d_print_comp. ++ All other fields are final after initialization. */ ++ int d_printing; ++ int d_counting; ++ ++ union ++ { ++ /* For DEMANGLE_COMPONENT_NAME. */ ++ struct ++ { ++ /* A pointer to the name (which need not NULL terminated) and ++ its length. */ ++ const char *s; ++ int len; ++ } s_name; ++ ++ /* For DEMANGLE_COMPONENT_OPERATOR. */ ++ struct ++ { ++ /* Operator. */ ++ const struct demangle_operator_info *op; ++ } s_operator; ++ ++ /* For DEMANGLE_COMPONENT_EXTENDED_OPERATOR. */ ++ struct ++ { ++ /* Number of arguments. */ ++ int args; ++ /* Name. */ ++ struct demangle_component *name; ++ } s_extended_operator; ++ ++ /* For DEMANGLE_COMPONENT_FIXED_TYPE. */ ++ struct ++ { ++ /* The length, indicated by a C integer type name. */ ++ struct demangle_component *length; ++ /* _Accum or _Fract? */ ++ short accum; ++ /* Saturating or not? */ ++ short sat; ++ } s_fixed; ++ ++ /* For DEMANGLE_COMPONENT_CTOR. */ ++ struct ++ { ++ /* Kind of constructor. */ ++ enum gnu_v3_ctor_kinds kind; ++ /* Name. */ ++ struct demangle_component *name; ++ } s_ctor; ++ ++ /* For DEMANGLE_COMPONENT_DTOR. */ ++ struct ++ { ++ /* Kind of destructor. */ ++ enum gnu_v3_dtor_kinds kind; ++ /* Name. */ ++ struct demangle_component *name; ++ } s_dtor; ++ ++ /* For DEMANGLE_COMPONENT_BUILTIN_TYPE. */ ++ struct ++ { ++ /* Builtin type. */ ++ const struct demangle_builtin_type_info *type; ++ } s_builtin; ++ ++ /* For DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE. */ ++ struct ++ { ++ /* Builtin type. */ ++ const struct demangle_builtin_type_info *type; ++ short arg; ++ char suffix; ++ } s_extended_builtin; ++ ++ /* For DEMANGLE_COMPONENT_SUB_STD. */ ++ struct ++ { ++ /* Standard substitution string. */ ++ const char* string; ++ /* Length of string. */ ++ int len; ++ } s_string; ++ ++ /* For DEMANGLE_COMPONENT_*_PARAM. */ ++ struct ++ { ++ /* Parameter index. */ ++ long number; ++ } s_number; ++ ++ /* For DEMANGLE_COMPONENT_CHARACTER. */ ++ struct ++ { ++ int character; ++ } s_character; ++ ++ /* For other types. */ ++ struct ++ { ++ /* Left (or only) subtree. */ ++ struct demangle_component *left; ++ /* Right subtree. */ ++ struct demangle_component *right; ++ } s_binary; ++ ++ struct ++ { ++ /* subtree, same place as d_left. */ ++ struct demangle_component *sub; ++ /* integer. */ ++ int num; ++ } s_unary_num; ++ ++ } u; ++}; ++ ++/* People building mangled trees are expected to allocate instances of ++ struct demangle_component themselves. They can then call one of ++ the following functions to fill them in. */ ++ ++/* Fill in most component types with a left subtree and a right ++ subtree. Returns non-zero on success, zero on failure, such as an ++ unrecognized or inappropriate component type. */ ++ ++extern int ++cplus_demangle_fill_component (struct demangle_component *fill, ++ enum demangle_component_type, ++ struct demangle_component *left, ++ struct demangle_component *right); ++ ++/* Fill in a DEMANGLE_COMPONENT_NAME. Returns non-zero on success, ++ zero for bad arguments. */ ++ ++extern int ++cplus_demangle_fill_name (struct demangle_component *fill, ++ const char *, int); ++ ++/* Fill in a DEMANGLE_COMPONENT_BUILTIN_TYPE, using the name of the ++ builtin type (e.g., "int", etc.). Returns non-zero on success, ++ zero if the type is not recognized. */ ++ ++extern int ++cplus_demangle_fill_builtin_type (struct demangle_component *fill, ++ const char *type_name); ++ ++/* Fill in a DEMANGLE_COMPONENT_OPERATOR, using the name of the ++ operator and the number of arguments which it takes (the latter is ++ used to disambiguate operators which can be both binary and unary, ++ such as '-'). Returns non-zero on success, zero if the operator is ++ not recognized. */ ++ ++extern int ++cplus_demangle_fill_operator (struct demangle_component *fill, ++ const char *opname, int args); ++ ++/* Fill in a DEMANGLE_COMPONENT_EXTENDED_OPERATOR, providing the ++ number of arguments and the name. Returns non-zero on success, ++ zero for bad arguments. */ ++ ++extern int ++cplus_demangle_fill_extended_operator (struct demangle_component *fill, ++ int numargs, ++ struct demangle_component *nm); ++ ++/* Fill in a DEMANGLE_COMPONENT_CTOR. Returns non-zero on success, ++ zero for bad arguments. */ ++ ++extern int ++cplus_demangle_fill_ctor (struct demangle_component *fill, ++ enum gnu_v3_ctor_kinds kind, ++ struct demangle_component *name); ++ ++/* Fill in a DEMANGLE_COMPONENT_DTOR. Returns non-zero on success, ++ zero for bad arguments. */ ++ ++extern int ++cplus_demangle_fill_dtor (struct demangle_component *fill, ++ enum gnu_v3_dtor_kinds kind, ++ struct demangle_component *name); ++ ++/* This function translates a mangled name into a struct ++ demangle_component tree. The first argument is the mangled name. ++ The second argument is DMGL_* options. This returns a pointer to a ++ tree on success, or NULL on failure. On success, the third ++ argument is set to a block of memory allocated by malloc. This ++ block should be passed to free when the tree is no longer ++ needed. */ ++ ++extern struct demangle_component * ++cplus_demangle_v3_components (const char *mangled, int options, void **mem); ++ ++/* This function takes a struct demangle_component tree and returns ++ the corresponding demangled string. The first argument is DMGL_* ++ options. The second is the tree to demangle. The third is a guess ++ at the length of the demangled string, used to initially allocate ++ the return buffer. The fourth is a pointer to a size_t. On ++ success, this function returns a buffer allocated by malloc(), and ++ sets the size_t pointed to by the fourth argument to the size of ++ the allocated buffer (not the length of the returned string). On ++ failure, this function returns NULL, and sets the size_t pointed to ++ by the fourth argument to 0 for an invalid tree, or to 1 for a ++ memory allocation error. */ ++ ++extern char * ++cplus_demangle_print (int options, ++ struct demangle_component *tree, ++ int estimated_length, ++ size_t *p_allocated_size); ++ ++/* This function takes a struct demangle_component tree and passes back ++ a demangled string in one or more calls to a callback function. ++ The first argument is DMGL_* options. The second is the tree to ++ demangle. The third is a pointer to a callback function; on each call ++ this receives an element of the demangled string, its length, and an ++ opaque value. The fourth is the opaque value passed to the callback. ++ The callback is called once or more to return the full demangled ++ string. The demangled element string is always nul-terminated, though ++ its length is also provided for convenience. In contrast to ++ cplus_demangle_print(), this function does not allocate heap memory ++ to grow output strings (except perhaps where alloca() is implemented ++ by malloc()), and so is normally safe for use where the heap has been ++ corrupted. On success, this function returns 1; on failure, 0. */ ++ ++extern int ++cplus_demangle_print_callback (int options, ++ struct demangle_component *tree, ++ demangle_callbackref callback, void *opaque); ++ ++#ifdef __cplusplus ++} ++#endif /* __cplusplus */ ++ ++#endif /* DEMANGLE_H */ +diff -Nuar annobin-11.13.org/config/config.guess annobin-11.13.sw/config/config.guess +--- annobin-11.13.org/config/config.guess 2023-03-08 15:33:10.000000000 +0800 ++++ annobin-11.13.sw/config/config.guess 2024-07-17 16:25:00.435296322 +0800 +@@ -933,6 +933,17 @@ + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; ++ sw_64:Linux:*:*) ++ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in ++ SW6) UNAME_MACHINE=sw_64sw6 ;; ++ SW6A) UNAME_MACHINE=sw_64sw6a ;; ++ SW6B) UNAME_MACHINE=sw_64sw6b ;; ++ SW8A) UNAME_MACHINE=sw_64sw8a ;; ++ esac ++ objdump --private-headers /bin/sh | grep -q ld.so.1 ++ if test "$?" = 0 ; then LIBC=gnulibc1 ; fi ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; +@@ -1405,6 +1416,7 @@ + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; ++ S*) echo sw_64-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; +diff -Nuar annobin-11.13.org/config/config.sub annobin-11.13.sw/config/config.sub +--- annobin-11.13.org/config/config.sub 2023-03-08 15:33:10.000000000 +0800 ++++ annobin-11.13.sw/config/config.sub 2024-07-17 16:25:00.435296322 +0800 +@@ -250,6 +250,7 @@ + | aarch64 | aarch64_be \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ ++ | sw_64 | sw_64sw6a | sw_64sw6b | sw_64sw8a \ + | am33_2.0 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ +@@ -376,6 +377,7 @@ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ ++ | sw_64-* | sw_64sw6a-* | sw_64sw6b-* | sw_64sw8a-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | ba-* \ +diff -Nuar annobin-11.13.org/configure annobin-11.13.sw/configure +--- annobin-11.13.org/configure 2024-07-17 16:23:59.453185032 +0800 ++++ annobin-11.13.sw/configure 2024-07-17 16:25:00.434296288 +0800 +@@ -17830,6 +17830,10 @@ + s390*-*-*) + target_plugin="s390.annobin.lo" + ;; ++ sw_64*-*-*) ++ target_plugin="sw_64.annobin.lo" ++ ;; ++ + x86_64-*-*) + target_plugin="x86_64.annobin.lo" + ;; +diff -Nuar annobin-11.13.org/configure.ac annobin-11.13.sw/configure.ac +--- annobin-11.13.org/configure.ac 2023-03-08 15:33:10.000000000 +0800 ++++ annobin-11.13.sw/configure.ac 2024-07-17 16:25:00.435296322 +0800 +@@ -48,6 +48,9 @@ + s390*-*-*) + target_plugin="s390.annobin.lo" + ;; ++ sw_64*-*-*) ++ target_plugin="sw_64.annobin.lo" ++ ;; + x86_64-*-*) + target_plugin="x86_64.annobin.lo" + ;; +diff -Nuar annobin-11.13.org/gcc-plugin/annobin.cc annobin-11.13.sw/gcc-plugin/annobin.cc +--- annobin-11.13.org/gcc-plugin/annobin.cc 2024-07-17 16:23:59.449184893 +0800 ++++ annobin-11.13.sw/gcc-plugin/annobin.cc 2024-07-17 16:25:00.437296392 +0800 +@@ -1904,7 +1904,7 @@ + Ensure that we do not have empty special text sections so that the + annobin start symbols are never beyond the end of the sections. */ + #ifndef ANNOBIN_NOP_INSN +-#define ANNOBIN_NOP_INSN "nop" ++#define ANNOBIN_NOP_INSN ".nop" + #endif + if (* suffix && enable_ppc64_nops) + annobin_emit_asm (ANNOBIN_NOP_INSN, +diff -Nuar annobin-11.13.org/gcc-plugin/config.guess annobin-11.13.sw/gcc-plugin/config.guess +--- annobin-11.13.org/gcc-plugin/config.guess 2023-03-08 15:33:10.000000000 +0800 ++++ annobin-11.13.sw/gcc-plugin/config.guess 2024-07-17 16:25:00.437296392 +0800 +@@ -930,6 +930,17 @@ + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; ++ sw_64:Linux:*:*) ++ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in ++ SW6) UNAME_MACHINE=sw_64sw6 ;; ++ SW6A) UNAME_MACHINE=sw_64sw6a ;; ++ SW6B) UNAME_MACHINE=sw_64sw6b ;; ++ SW8A) UNAME_MACHINE=sw_64sw8a ;; ++ esac ++ objdump --private-headers /bin/sh | grep -q ld.so.1 ++ if test "$?" = 0 ; then LIBC=gnulibc1 ; fi ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; +@@ -1395,6 +1406,7 @@ + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; ++ S*) echo sw_64-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; +diff -Nuar annobin-11.13.org/gcc-plugin/config.sub annobin-11.13.sw/gcc-plugin/config.sub +--- annobin-11.13.org/gcc-plugin/config.sub 2023-03-08 15:33:10.000000000 +0800 ++++ annobin-11.13.sw/gcc-plugin/config.sub 2024-07-17 16:25:00.436296357 +0800 +@@ -250,6 +250,7 @@ + | aarch64 | aarch64_be \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ ++ | sw_64 | sw_64sw6a | sw_64sw6b | sw_64sw8a \ + | am33_2.0 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ +@@ -375,6 +376,7 @@ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ ++ | sw_64 | sw_64sw6a | sw_64sw6b | sw_64sw8a \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | ba-* \ +diff -Nuar annobin-11.13.org/gcc-plugin/Makefile.in annobin-11.13.sw/gcc-plugin/Makefile.in +--- annobin-11.13.org/gcc-plugin/Makefile.in 2024-07-17 16:23:59.453185032 +0800 ++++ annobin-11.13.sw/gcc-plugin/Makefile.in 2024-07-17 16:25:00.437296392 +0800 +@@ -354,7 +354,7 @@ + AM_CPPFLAGS = -I'$(top_builddir)' -I'$(top_srcdir)' + AUTOMAKE_OPTIONS = no-dependencies + annobin_la_SOURCES = annobin.cc +-EXTRA_annobin_la_SOURCES = aarch64.annobin.cc arm.annobin.cc dummy.annobin.cc powerpc.annobin.cc s390.annobin.cc x86_64.annobin.cc i686.annobin.cc riscv.annobin.cc ++EXTRA_annobin_la_SOURCES = aarch64.annobin.cc arm.annobin.cc dummy.annobin.cc powerpc.annobin.cc s390.annobin.cc sw_64.annobin.cc x86_64.annobin.cc i686.annobin.cc riscv.annobin.cc + annobin_la_LIBADD = @target_plugin@ + annobin_la_DEPENDENCIES = @target_plugin@ + annobin_la_LDFLAGS = -module +diff -Nuar annobin-11.13.org/gcc-plugin/sw_64.annobin.cc annobin-11.13.sw/gcc-plugin/sw_64.annobin.cc +--- annobin-11.13.org/gcc-plugin/sw_64.annobin.cc 1970-01-01 08:00:00.000000000 +0800 ++++ annobin-11.13.sw/gcc-plugin/sw_64.annobin.cc 2024-07-17 16:25:00.437296392 +0800 +@@ -0,0 +1,53 @@ ++/* dummy.annobin - Empty target specific parts of the annobin plugin. ++ Copyright (c) 2019-2024 Red Hat. ++ Created by Nick Clifton. ++ ++ This is free software; you can redistribute it and/or modify it ++ under the terms of the GNU General Public License as published ++ by the Free Software Foundation; either version 3, or (at your ++ option) any later version. ++ ++ It is distributed in the hope that it will be useful, but ++ WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. */ ++ ++#include "annobin-global.h" ++#include "annobin.h" ++ ++signed int ++annobin_target_start_symbol_bias (void) ++{ ++ /* Disable the use of section groups (by default) for the ARM. ++ The problem is that the ARM gcc backend can create unwind sections ++ that are associated with code sections, but which do not get put ++ into the section groups. So a relocateable link will combine these ++ unwind sections together, but not the associated code sections (since ++ they are part of a group) and so the unwind info becomes corrupt. */ ++ annobin_attach_type = none; ++ return 0; ++} ++ ++unsigned int ++annobin_get_target_pointer_size (void) ++{ ++ return 64; ++} ++ ++int ++annobin_save_target_specific_information (void) ++{ ++ return 0; ++} ++ ++void ++annobin_record_global_target_notes (annobin_function_info * info ATTRIBUTE_UNUSED) ++{ ++} ++ ++void ++annobin_target_specific_function_notes (annobin_function_info * info ATTRIBUTE_UNUSED, ++ bool force ATTRIBUTE_UNUSED) ++{ ++} ++ diff --git a/annobin.spec b/annobin.spec index 4337899..f752733 100644 --- a/annobin.spec +++ b/annobin.spec @@ -1,4 +1,4 @@ -%define anolis_release .0.1 +%define anolis_release .0.2 Name: annobin Summary: Annotate and examine compiled binary files Version: 11.13 @@ -64,6 +64,7 @@ Source: https://nickc.fedorapeople.org/%{annobin_sources} # Insert patches here, if needed. Eg: Patch01: annobin-nop.patch Patch02: annobin-annocheck-no-debuginfod.patch +Patch03: annobin-11.13-sw.patch #--------------------------------------------------------------------------------- @@ -100,7 +101,7 @@ Patch02: annobin-annocheck-no-debuginfod.patch # # The following implements the above: -%global gcc_vr %(gcc --version | head -n 1 | sed -e 's|.*(Anolis\ ||g' -e 's|)$||g') +%global gcc_vr %(gcc --version | head -n 1 | awk '{ print $NF}' | sed -e 's|.*(Anolis\ ||g' -e 's|)$||g') # We need the major version of gcc. %global gcc_major %(echo "%{gcc_vr}" | cut -f1 -d".") @@ -341,9 +342,9 @@ rm -f %{buildroot}%{_infodir}/dir # The first "make check" is run with "|| :" so that we can capture any logs # from failed tests. The second "make check" is there so that the build # will fail if any of the tests fail. -make check CLANG_TESTS="check-pre-clang-13" || : +make -k check CLANG_TESTS="check-pre-clang-13" || : if [ -f tests/test-suite.log ]; then - cat tests/test-suite.log + cat tests/*.log fi # If necessary use uuencode to preserve test binaries here. For example: uuencode tests/tmp_atexit/atexit.strip atexit.strip @@ -393,6 +394,9 @@ make check CLANG_TESTS="check-pre-clang-13" #--------------------------------------------------------------------------------- %changelog +* Wed Jul 17 2024 wxiat - 11.13-2.0.2 +- add sw arch + * Wed Dec 06 2023 Liwei Ge - 11.13-2.0.1 - Parse Anolis GCC version -- Gitee