diff options
Diffstat (limited to 'tools')
60 files changed, 4872 insertions, 359 deletions
diff --git a/tools/Makefile b/tools/Makefile index f60a458f98..009778a495 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -82,7 +82,7 @@ tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_TARGET_ath79),y) += lzma-old s tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_TARGET_mxs),y) += elftosb sdimage tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_TARGET_realtek),y) += 7z tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_TARGET_tegra),y) += cbootimage cbootimage-configs -tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_USES_MINOR),y) += kernel2minor +tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_USES_MINOR),y) += yafut tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_USE_SPARSE),y) += sparse tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_USE_LLVM_BUILD),y) += llvm-bpf tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(CONFIG_USE_MOLD),y) += mold @@ -130,6 +130,7 @@ $(curdir)/sdcc/compile := $(curdir)/bison/compile $(curdir)/squashfs3-lzma/compile := $(curdir)/lzma-old/compile $(curdir)/squashfs4/compile := $(curdir)/xz/compile $(curdir)/zlib/compile $(curdir)/util-linux/compile := $(curdir)/bison/compile +$(curdir)/yafut/compile := $(curdir)/cmake/compile ifneq ($(HOST_OS),Linux) $(curdir)/coreutils/compile += $(curdir)/automake/compile $(curdir)/bison/compile $(curdir)/gnulib/compile diff --git a/tools/bison/patches/000-relocatable.patch b/tools/bison/patches/000-relocatable.patch new file mode 100644 index 0000000000..b98d7a86dc --- /dev/null +++ b/tools/bison/patches/000-relocatable.patch @@ -0,0 +1,43 @@ +--- a/src/files.c ++++ b/src/files.c +@@ -560,9 +560,9 @@ pkgdatadir (void) + char const * + m4path (void) + { +- char const *m4 = getenv ("M4"); ++ char const *m4 = getenv ("STAGING_DIR_HOST"); + if (m4) +- return m4; ++ return strcat(getenv ("STAGING_DIR_HOST"), "/bin/m4"); + + /* We don't use relocate2() to store the temporary buffer and re-use + it, because m4path() is only called once. */ +--- a/src/getargs.c ++++ b/src/getargs.c +@@ -373,11 +373,13 @@ usage (int status) + A --long option is required. + Otherwise, add exceptions to ../build-aux/cross-options.pl. */ + +- printf (_("Usage: %s [OPTION]... FILE\n"), program_name); ++ printf (_("Usage: STAGING_DIR_HOST=... %s [OPTION]... FILE\n"), program_name); + fputs (_("\ + Generate a deterministic LR or generalized LR (GLR) parser employing\n\ + LALR(1), IELR(1), or canonical LR(1) parser tables.\n\ + \n\ ++Environment Variable STAGING_DIR_HOST controls path to m4\n\ ++\n\ + "), stdout); + + fputs (_("\ +@@ -450,6 +452,11 @@ Output Files:\n\ + -M, --file-prefix-map=OLD=NEW replace prefix OLD with NEW when writing file paths\n\ + in output files\n\ + "), stdout); ++ ++ fputs (_("\ ++Environment Variables:\n\ ++ STAGING_DIR_HOST Path to m4 is [STAGING_DIR_HOST]/bin/m4\n\ ++"), stdout); + putc ('\n', stdout); + + argmatch_report_usage (stdout); diff --git a/tools/ccache/Makefile b/tools/ccache/Makefile index cd2c6d27d5..47c24a5c98 100644 --- a/tools/ccache/Makefile +++ b/tools/ccache/Makefile @@ -7,11 +7,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ccache -PKG_VERSION:=4.9.1 +PKG_VERSION:=4.10 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://github.com/ccache/ccache/releases/download/v$(PKG_VERSION) -PKG_HASH:=12834ecaaaf2db069dda1d1d991f91c19e3274cc04a471af5b64195def17e90f +PKG_HASH:=16972ba62c8499045edc3ae7d7b8a0b419a961567f5ff0f01bf5a44194204775 include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/cmake.mk diff --git a/tools/ccache/patches/100-honour-copts.patch b/tools/ccache/patches/100-honour-copts.patch index 8f1c426501..a40665ea25 100644 --- a/tools/ccache/patches/100-honour-copts.patch +++ b/tools/ccache/patches/100-honour-copts.patch @@ -1,6 +1,6 @@ ---- a/src/ccache.cpp -+++ b/src/ccache.cpp -@@ -1841,6 +1841,7 @@ get_manifest_key(Context& ctx, Hash& has +--- a/src/ccache/ccache.cpp ++++ b/src/ccache/ccache.cpp +@@ -1906,6 +1906,7 @@ get_manifest_key(Context& ctx, Hash& has "OBJCPLUS_INCLUDE_PATH", // Clang "CLANG_CONFIG_FILE_SYSTEM_DIR", // Clang "CLANG_CONFIG_FILE_USER_DIR", // Clang diff --git a/tools/cmake/Makefile b/tools/cmake/Makefile index 1027b671bd..89194ac5d7 100644 --- a/tools/cmake/Makefile +++ b/tools/cmake/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=cmake -PKG_VERSION:=3.29.0 +PKG_VERSION:=3.29.5 PKG_VERSION_MAJOR:=$(word 1,$(subst ., ,$(PKG_VERSION))).$(word 2,$(subst ., ,$(PKG_VERSION))) PKG_RELEASE:=1 PKG_CPE_ID:=cpe:/a:kitware:cmake @@ -15,7 +15,7 @@ PKG_CPE_ID:=cpe:/a:kitware:cmake PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://github.com/Kitware/CMake/releases/download/v$(PKG_VERSION)/ \ https://cmake.org/files/v$(PKG_VERSION_MAJOR)/ -PKG_HASH:=a0669630aae7baa4a8228048bf30b622f9e9fd8ee8cedb941754e9e38686c778 +PKG_HASH:=dd63da7d763c0db455ca232f2c443f5234fe0b11f8bd6958a81d29cc987dfd6e HOST_BUILD_PARALLEL:=1 HOST_CONFIGURE_PARALLEL:=1 diff --git a/tools/coreutils/Makefile b/tools/coreutils/Makefile index 69d1dcbd37..f55fdcc1b2 100644 --- a/tools/coreutils/Makefile +++ b/tools/coreutils/Makefile @@ -8,11 +8,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=coreutils PKG_CPE_ID:=cpe:/a:gnu:coreutils -PKG_VERSION:=9.3 +PKG_VERSION:=9.5 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@GNU/coreutils -PKG_HASH:=a33d2c0bc49be3c79a4794944dcd87103bf497b53a14bafcd431c8ca53975252 +PKG_HASH:=767ae6a22950ec42f3ba5f7c1de79dd27800ee8e9b8642da5dedb5974a1741e5 HOST_BUILD_PARALLEL := 1 @@ -22,7 +22,13 @@ include $(INCLUDE_DIR)/host-build.mk export GNULIB_SRCDIR:=$(HOST_GNULIB_SRCDIR) +HOST_GNULIB_SKIP := \ + lib/nstrftime.c \ + lib/fprintftime.c \ + lib/locale.in.h + HOST_CONFIGURE_ARGS += \ + --disable-year2038 \ --enable-install-program=$(subst $(space),$(comma),$(strip $(PKG_PROGRAMS))) HOST_MAKE_FLAGS += \ @@ -50,7 +56,7 @@ endef define Host/Configure $(if $(QUILT),$(call Host/Bootstrap)) - -$(CP) $(HOST_BUILD_DIR)/lib/time.in.h~ $(HOST_BUILD_DIR)/lib/time.in.h # @GNULIB_TIME@ not defined + $(foreach src,$(HOST_GNULIB_SKIP),mv -f $(HOST_BUILD_DIR)/$(src)~ $(HOST_BUILD_DIR)/$(src) || true; ) $(call Host/Configure/Default) endef diff --git a/tools/coreutils/patches/000-bootstrap.patch b/tools/coreutils/patches/000-bootstrap.patch index 91be9d338a..68db19084f 100644 --- a/tools/coreutils/patches/000-bootstrap.patch +++ b/tools/coreutils/patches/000-bootstrap.patch @@ -1,6 +1,6 @@ --- a/bootstrap +++ b/bootstrap -@@ -278,7 +278,7 @@ check_exists() { +@@ -244,7 +244,7 @@ check_exists() { ($2 --version </dev/null) fi else @@ -9,7 +9,7 @@ fi test $? -lt 126 -@@ -563,7 +563,7 @@ p +@@ -309,7 +309,7 @@ p q' get_version() { @@ -18,7 +18,7 @@ $app --version >/dev/null 2>&1 || { $app --version; return 1; } -@@ -620,13 +620,13 @@ check_versions() { +@@ -366,13 +366,13 @@ check_versions() { if [ "$req_ver" = "-" ]; then # Merely require app to exist; not all prereq apps are well-behaved # so we have to rely on $? rather than get_version. @@ -34,12 +34,12 @@ if [ ! "$inst_ver" ]; then warn_ "Error: '$app' not found" ret=1 -@@ -923,7 +923,7 @@ version_controlled_file() { - # two just-pre-run programs. +@@ -1157,7 +1157,7 @@ autogen() + # two just-pre-run programs. - # Import from gettext. --with_gettext=yes -+with_gettext=no - grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \ - with_gettext=no + # Import from gettext. +- with_gettext=yes ++ with_gettext=no + grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \ + with_gettext=no diff --git a/tools/dwarves/Makefile b/tools/dwarves/Makefile index 16dc765f58..bcb16dd3da 100644 --- a/tools/dwarves/Makefile +++ b/tools/dwarves/Makefile @@ -3,12 +3,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=dwarves -PKG_VERSION:=1.26 +PKG_VERSION:=1.27 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://fedorapeople.org/~acme/dwarves/ -PKG_HASH:=1d8c9a1c2d42e06cc121a70a39c4f621fd28f15c476ed1b7c7b226f41fdd32df +PKG_HASH:=ef7f21f1c6016896d03a01f05cab225151f9068e19cc8cddc6e754b2b5cbe279 PKG_MAINTAINER:=Tony Ambardar <itugrok@yahoo.com> PKG_LICENSE:=GPL-2.0-only diff --git a/tools/dwarves/patches/100-reproducible-builds.patch b/tools/dwarves/patches/100-reproducible-builds.patch new file mode 100644 index 0000000000..15bddd5645 --- /dev/null +++ b/tools/dwarves/patches/100-reproducible-builds.patch @@ -0,0 +1,12 @@ +--- a/pahole.c ++++ b/pahole.c +@@ -3723,6 +3723,9 @@ int main(int argc, char *argv[]) + goto out; + } + ++ if (getenv("SOURCE_DATE_EPOCH") || getenv("KBUILD_BUILD_TIMESTAMP")) ++ conf_load.reproducible_build = true; ++ + if (dwarves__init()) { + fputs("pahole: insufficient memory\n", stderr); + goto out; diff --git a/tools/elftosb/patches/001-libm.patch b/tools/elftosb/patches/001-libm.patch index 02705d24bb..6b49ac1af2 100644 --- a/tools/elftosb/patches/001-libm.patch +++ b/tools/elftosb/patches/001-libm.patch @@ -1,6 +1,6 @@ ---- elftosb-10.12.01/makefile.rules 2012-03-15 11:01:44.979020178 -0400 -+++ elftosb-10.12.01/makefile.rules 2012-03-15 11:01:16.332761989 -0400 -@@ -101,7 +101,7 @@ +--- a/makefile.rules ++++ b/makefile.rules +@@ -101,7 +101,7 @@ OBJ_FILES_KEYGEN = \ keygen.o diff --git a/tools/elftosb/patches/002-fix-header-path.patch b/tools/elftosb/patches/002-fix-header-path.patch index 5e3b5091b9..5099b29644 100644 --- a/tools/elftosb/patches/002-fix-header-path.patch +++ b/tools/elftosb/patches/002-fix-header-path.patch @@ -5,9 +5,8 @@ others once multiarch becomes more common. This patch makes the types a relative path, and allows the system to use whatever include paths it feels are correct. -diff -Naurp elftosb-10.12.01-orig/common/stdafx.h elftosb-10.12.01/common/stdafx.h ---- elftosb-10.12.01-orig/common/stdafx.h 2012-07-12 13:30:10.990249396 -0400 -+++ elftosb-10.12.01/common/stdafx.h 2012-07-12 13:30:06.858249391 -0400 +--- a/common/stdafx.h ++++ b/common/stdafx.h @@ -27,7 +27,7 @@ // For Linux systems only, types.h only defines the signed // integer types. This is not professional code. diff --git a/tools/elfutils/Makefile b/tools/elfutils/Makefile index a701827248..0fbf1aedad 100644 --- a/tools/elfutils/Makefile +++ b/tools/elfutils/Makefile @@ -3,12 +3,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=elfutils -PKG_VERSION:=0.189 -PKG_RELEASE:=1 +PKG_VERSION:=0.191 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://sourceware.org/$(PKG_NAME)/ftp/$(PKG_VERSION) -PKG_HASH:=39bd8f1a338e2b7cd4abc3ff11a0eddc6e690f69578a57478d8179b4148708c8 +PKG_HASH:=df76db71366d1d708365fc7a6c60ca48398f14367eb2b8954efc8897147ad871 PKG_LICENSE:=GPL-3.0-or-later PKG_LICENSE_FILES:=COPYING COPYING-GPLV2 COPYING-LGPLV3 @@ -17,13 +17,58 @@ PKG_CPE_ID:=cpe:/a:elfutils_project:elfutils PKG_FIXUP:=autoreconf PKG_INSTALL:=1 +PKG_PROGRAMS:=elflint findtextrel elfcmp unstrip stack elfcompress elfclassify srcfiles + +PKG_SUBDIRS := \ + libgnu \ + config \ + lib \ + libelf \ + libcpu \ + backends \ + libebl \ + libdwelf \ + libdwfl \ + libdw \ + src + +PKG_GNULIB_BASE:=libgnu + +PKG_GNULIB_ARGS = \ + --dir=$(HOST_BUILD_DIR) \ + --local-dir=$(STAGING_DIR_HOST)/share/gnulib \ + --source-base=$(PKG_GNULIB_BASE) \ + --libtool \ + --avoid=reallocarray \ + --import + +PKG_GNULIB_MODS = \ + argp \ + fnmatch-gnu \ + fts \ + obstack \ + progname \ + strchrnul \ + tsearch + include $(INCLUDE_DIR)/host-build.mk +export $(PKG_GNULIB_BASE)=$(HOST_BUILD_DIR)/$(PKG_GNULIB_BASE)/$(PKG_GNULIB_BASE).la +export $(PKG_GNULIB_BASE)_tsearch=$(HOST_BUILD_DIR)/$(PKG_GNULIB_BASE)/$(PKG_GNULIB_BASE)_la-tsearch.lo + +HOST_MAKE_FLAGS += \ + AM_LDFLAGS='$$$$(STACK_USAGE_NO_ERROR)' \ + LIBS+='$$$$(if $$$$(findstring $(lastword $(PKG_SUBDIRS)),$$$$(subdir)), $$$$($(PKG_GNULIB_BASE)))' \ + LIBS+='$$$$(wildcard $$$$($(PKG_GNULIB_BASE)_tsearch))' \ + REPLACE_FCNTL=0 REPLACE_FREE=0 REPLACE_FSTAT=0 REPLACE_OPEN=0 \ + bin_PROGRAMS='$(PKG_PROGRAMS)' EXEEXT= + ifeq ($(HOST_OS),Darwin) HOST_CFLAGS += -I/opt/homebrew/include endif HOST_CFLAGS += -Wno-error -fPIC +HOST_CXXFLAGS += -O2 HOST_CONFIGURE_ARGS += \ --without-libintl-prefix \ @@ -43,10 +88,18 @@ endif Hooks/HostConfigure/Pre := Host/Gnulib $(Hooks/HostConfigure/Pre) define Host/Gnulib - cd $(HOST_BUILD_DIR); $(STAGING_DIR_HOST)/bin/gnulib-tool --libtool --source-base=libgnu --import argp obstack fts strchrnul progname tsearch; + $(STAGING_DIR_HOST)/bin/gnulib-tool $(PKG_GNULIB_ARGS) $(PKG_GNULIB_MODS); ln -sf ../lib/eu-config.h $(HOST_BUILD_DIR)/libgnu/; endef +define Host/Compile + $(call Host/Compile/Default,SUBDIRS='$$$$(wildcard $(PKG_SUBDIRS))') +endef + +define Host/Install + $(call Host/Compile/Default,install SUBDIRS='$$$$(wildcard $(PKG_SUBDIRS))') +endef + define Host/Uninstall -$(call Host/Compile/Default,uninstall) endef diff --git a/tools/elfutils/patches/010-backport-mips-support-reloc.patch b/tools/elfutils/patches/010-backport-mips-support-reloc.patch new file mode 100644 index 0000000000..8a65e4e464 --- /dev/null +++ b/tools/elfutils/patches/010-backport-mips-support-reloc.patch @@ -0,0 +1,2525 @@ +From 8d3bb7db9d6f07decfc59d83988cda54e5a8b0cd Mon Sep 17 00:00:00 2001 +From: Ying Huang <ying.huang@oss.cipunited.com> +Date: Tue, 5 Mar 2024 17:51:17 +0800 +Subject: [PATCH 1/7] Support Mips architecture + + * backends/Makefile.am (modules): Add mips. + (mips_SRCS): New var for mips_init.c mips_symbol.c. + (libebl_backends_a_SOURCES): Add mips_SRCS. + * backends/mips_init.c: New file. + * backends/mips_reloc.def: Likewise. + * backends/mips_symbol.c: Likewise. + * libebl/eblopenbackend.c (mips_init): Declare. + (machines): Add mips. + * libelf/libelfP.h: Add ELF64_MIPS_R_TYPE{1,2,3} + +Signed-off-by: Ying Huang <ying.huang@oss.cipunited.com> +--- + backends/Makefile.am | 6 ++- + backends/mips_init.c | 52 +++++++++++++++++++++++ + backends/mips_reloc.def | 93 +++++++++++++++++++++++++++++++++++++++++ + backends/mips_symbol.c | 63 ++++++++++++++++++++++++++++ + libebl/eblopenbackend.c | 2 + + libelf/libelfP.h | 3 ++ + 6 files changed, 217 insertions(+), 2 deletions(-) + create mode 100644 backends/mips_init.c + create mode 100644 backends/mips_reloc.def + create mode 100644 backends/mips_symbol.c + +--- a/backends/Makefile.am ++++ b/backends/Makefile.am +@@ -37,7 +37,7 @@ AM_CPPFLAGS += -I$(top_srcdir)/libebl -I + noinst_LIBRARIES = libebl_backends.a libebl_backends_pic.a + + modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \ +- m68k bpf riscv csky loongarch arc ++ m68k bpf riscv csky loongarch arc mips + + i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \ + i386_retval.c i386_regs.c i386_auxv.c \ +@@ -102,12 +102,16 @@ loongarch_SRCS = loongarch_init.c loonga + + arc_SRCS = arc_init.c arc_symbol.c + ++mips_SRCS = mips_init.c mips_symbol.c mips_attrs.c mips_initreg.c \ ++ mips_cfi.c mips_unwind.c mips_regs.c mips_retval.c \ ++ mips_corenote.c mips64_corenote.c ++ + libebl_backends_a_SOURCES = $(i386_SRCS) $(sh_SRCS) $(x86_64_SRCS) \ + $(ia64_SRCS) $(alpha_SRCS) $(arm_SRCS) \ + $(aarch64_SRCS) $(sparc_SRCS) $(ppc_SRCS) \ + $(ppc64_SRCS) $(s390_SRCS) \ + $(m68k_SRCS) $(bpf_SRCS) $(riscv_SRCS) $(csky_SRCS) \ +- $(loongarch_SRCS) $(arc_SRCS) ++ $(loongarch_SRCS) $(arc_SRCS) $(mips_SRCS) + + libebl_backends_pic_a_SOURCES = + am_libebl_backends_pic_a_OBJECTS = $(libebl_backends_a_SOURCES:.c=.os) +--- /dev/null ++++ b/backends/mips_init.c +@@ -0,0 +1,74 @@ ++/* Initialization of MIPS specific backend library. ++ Copyright (C) 2024 CIP United Inc. ++ This file is part of elfutils. ++ ++ This file is free software; you can redistribute it and/or modify ++ it under the terms of either ++ ++ * the GNU Lesser General Public License as published by the Free ++ Software Foundation; either version 3 of the License, or (at ++ your option) any later version ++ ++ or ++ ++ * the GNU General Public License as published by the Free ++ Software Foundation; either version 2 of the License, or (at ++ your option) any later version ++ ++ or both in parallel, as here. ++ ++ elfutils 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. ++ ++ You should have received copies of the GNU General Public License and ++ the GNU Lesser General Public License along with this program. If ++ not, see <http://www.gnu.org/licenses/>. */ ++ ++#ifdef HAVE_CONFIG_H ++# include <config.h> ++#endif ++ ++#define BACKEND mips_ ++#define RELOC_PREFIX R_MIPS_ ++#include "libebl_CPU.h" ++#include "libelfP.h" ++ ++#define RELOC_TYPE_ID(type) ((type) & 0xff) ++ ++/* This defines the common reloc hooks based on mips_reloc.def. */ ++#include "common-reloc.c" ++ ++extern __typeof (EBLHOOK (core_note)) mips64_core_note attribute_hidden; ++ ++Ebl * ++mips_init (Elf *elf __attribute__ ((unused)), ++ GElf_Half machine __attribute__ ((unused)), ++ Ebl *eh) ++{ ++ /* We handle it. */ ++ mips_init_reloc (eh); ++ HOOK (eh, reloc_simple_type); ++ HOOK (eh, section_type_name); ++ HOOK (eh, machine_flag_check); ++ HOOK (eh, machine_flag_name); ++ HOOK (eh, machine_section_flag_check); ++ HOOK (eh, segment_type_name); ++ HOOK (eh, dynamic_tag_check); ++ HOOK (eh, dynamic_tag_name); ++ HOOK (eh, check_object_attribute); ++ HOOK (eh, check_special_symbol); ++ HOOK (eh, check_reloc_target_type); ++ HOOK (eh, set_initial_registers_tid); ++ HOOK (eh, abi_cfi); ++ HOOK (eh, unwind); ++ HOOK (eh, register_info); ++ HOOK (eh, return_value_location); ++ if (eh->class == ELFCLASS64) ++ eh->core_note = mips64_core_note; ++ else ++ HOOK (eh, core_note); ++ eh->frame_nregs = 71; ++ return eh; ++} +--- /dev/null ++++ b/backends/mips_reloc.def +@@ -0,0 +1,93 @@ ++/* List the relocation types for MIPS. -*- C -*- ++ Copyright (C) 2024 CIP United Inc. ++ This file is part of elfutils. ++ ++ This file is free software; you can redistribute it and/or modify ++ it under the terms of either ++ ++ * the GNU Lesser General Public License as published by the Free ++ Software Foundation; either version 3 of the License, or (at ++ your option) any later version ++ ++ or ++ ++ * the GNU General Public License as published by the Free ++ Software Foundation; either version 2 of the License, or (at ++ your option) any later version ++ ++ or both in parallel, as here. ++ ++ elfutils 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. ++ ++ You should have received copies of the GNU General Public License and ++ the GNU Lesser General Public License along with this program. If ++ not, see <http://www.gnu.org/licenses/>. */ ++ ++/* NAME, REL|EXEC|DYN */ ++ ++ ++RELOC_TYPE (NONE, REL|EXEC|DYN) ++RELOC_TYPE (16, REL|EXEC|DYN) ++RELOC_TYPE (32, REL) ++RELOC_TYPE (REL32, REL|EXEC|DYN) ++RELOC_TYPE (26, REL|DYN) ++RELOC_TYPE (HI16, REL) ++RELOC_TYPE (LO16, REL|EXEC|DYN) ++RELOC_TYPE (GPREL16, REL|EXEC|DYN) ++RELOC_TYPE (LITERAL, REL|EXEC|DYN) ++RELOC_TYPE (GOT16, REL|EXEC|DYN) ++RELOC_TYPE (PC16, REL) ++RELOC_TYPE (CALL16, REL) ++RELOC_TYPE (GPREL32, REL) ++RELOC_TYPE (SHIFT5, REL) ++RELOC_TYPE (SHIFT6, REL) ++RELOC_TYPE (64, REL) ++RELOC_TYPE (GOT_DISP, REL) ++RELOC_TYPE (GOT_PAGE, REL) ++RELOC_TYPE (GOT_OFST, REL) ++RELOC_TYPE (GOT_HI16, REL) ++RELOC_TYPE (GOT_LO16, REL) ++RELOC_TYPE (SUB, REL) ++RELOC_TYPE (INSERT_A, REL) ++RELOC_TYPE (INSERT_B, REL) ++RELOC_TYPE (DELETE, REL) ++RELOC_TYPE (HIGHER, REL) ++RELOC_TYPE (HIGHEST, REL) ++RELOC_TYPE (CALL_HI16, REL) ++RELOC_TYPE (CALL_LO16, REL) ++RELOC_TYPE (SCN_DISP, REL) ++RELOC_TYPE (REL16, REL) ++RELOC_TYPE (ADD_IMMEDIATE, REL) ++RELOC_TYPE (PJUMP, REL) ++RELOC_TYPE (RELGOT, REL) ++RELOC_TYPE (JALR, REL) ++RELOC_TYPE (TLS_DTPMOD32, DYN) ++RELOC_TYPE (TLS_DTPREL32, REL) ++RELOC_TYPE (TLS_DTPMOD64, DYN) ++RELOC_TYPE (TLS_DTPREL64, REL) ++RELOC_TYPE (TLS_GD, REL) ++RELOC_TYPE (TLS_LDM, REL) ++RELOC_TYPE (TLS_DTPREL_HI16, REL) ++RELOC_TYPE (TLS_DTPREL_LO16, REL) ++RELOC_TYPE (TLS_GOTTPREL, REL) ++RELOC_TYPE (TLS_TPREL32, REL) ++RELOC_TYPE (TLS_TPREL64, REL) ++RELOC_TYPE (TLS_TPREL_HI16, REL) ++RELOC_TYPE (TLS_TPREL_LO16, REL) ++RELOC_TYPE (GLOB_DAT, REL) ++RELOC_TYPE (PC21_S2, REL) ++RELOC_TYPE (PC26_S2, REL) ++RELOC_TYPE (PC18_S3, REL) ++RELOC_TYPE (PC19_S2, REL) ++RELOC_TYPE (PCHI16, REL) ++RELOC_TYPE (PCLO16, REL) ++RELOC_TYPE (COPY, REL) ++RELOC_TYPE (JUMP_SLOT, REL) ++RELOC_TYPE (PC32, REL) ++RELOC_TYPE (EH, REL) ++RELOC_TYPE (GNU_REL16_S2, REL) ++RELOC_TYPE (GNU_VTINHERIT, REL) ++RELOC_TYPE (GNU_VTENTRY, REL) +--- /dev/null ++++ b/backends/mips_symbol.c +@@ -0,0 +1,671 @@ ++/* MIPS specific symbolic name handling. ++ Copyright (C) 2024 CIP United Inc. ++ This file is part of elfutils. ++ ++ This file is free software; you can redistribute it and/or modify ++ it under the terms of either ++ ++ * the GNU Lesser General Public License as published by the Free ++ Software Foundation; either version 3 of the License, or (at ++ your option) any later version ++ ++ or ++ ++ * the GNU General Public License as published by the Free ++ Software Foundation; either version 2 of the License, or (at ++ your option) any later version ++ ++ or both in parallel, as here. ++ ++ elfutils 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. ++ ++ You should have received copies of the GNU General Public License and ++ the GNU Lesser General Public License along with this program. If ++ not, see <http://www.gnu.org/licenses/>. */ ++ ++#ifdef HAVE_CONFIG_H ++# include <config.h> ++#endif ++ ++#include <system.h> ++ ++#include <elf.h> ++#include <stddef.h> ++#include <string.h> ++#include <stdio.h> ++#define BACKEND mips_ ++#include "libebl_CPU.h" ++#include "libelfP.h" ++ ++/* Check for the simple reloc types. */ ++Elf_Type ++mips_reloc_simple_type (Ebl *ebl, int type, ++ int *addsub __attribute__ ((unused))) ++{ ++ int typeNew = type; ++ if(ebl->elf->class == ELFCLASS64) ++ typeNew = ELF64_MIPS_R_TYPE1(type); ++ switch (typeNew) ++ { ++ case R_MIPS_64: ++ return ELF_T_XWORD; ++ case R_MIPS_32: ++ return ELF_T_WORD; ++ case R_MIPS_16: ++ return ELF_T_HALF; ++ ++ default: ++ return ELF_T_NUM; ++ } ++} ++ ++/* copy binutils-2.34/binutils/readelf.c get_mips_section_type_name */ ++const char * ++mips_section_type_name (int type, ++ char *buf __attribute__ ((unused)), ++ size_t len __attribute__ ((unused))) ++{ ++ switch (type) ++ { ++ case SHT_MIPS_LIBLIST: ++ return "MIPS_LIBLIST"; ++ case SHT_MIPS_MSYM: ++ return "MIPS_MSYM"; ++ case SHT_MIPS_CONFLICT: ++ return "MIPS_CONFLICT"; ++ case SHT_MIPS_GPTAB: ++ return "MIPS_GPTAB"; ++ case SHT_MIPS_UCODE: ++ return "MIPS_UCODE"; ++ case SHT_MIPS_DEBUG: ++ return "MIPS_DEBUG"; ++ case SHT_MIPS_REGINFO: ++ return "MIPS_REGINFO"; ++ case SHT_MIPS_PACKAGE: ++ return "MIPS_PACKAGE"; ++ case SHT_MIPS_PACKSYM: ++ return "MIPS_PACKSYM"; ++ case SHT_MIPS_RELD: ++ return "MIPS_RELD"; ++ case SHT_MIPS_IFACE: ++ return "MIPS_IFACE"; ++ case SHT_MIPS_CONTENT: ++ return "MIPS_CONTENT"; ++ case SHT_MIPS_OPTIONS: ++ return "MIPS_OPTIONS"; ++ case SHT_MIPS_SHDR: ++ return "MIPS_SHDR"; ++ case SHT_MIPS_FDESC: ++ return "MIPS_FDESC"; ++ case SHT_MIPS_EXTSYM: ++ return "MIPS_EXTSYM"; ++ case SHT_MIPS_DENSE: ++ return "MIPS_DENSE"; ++ case SHT_MIPS_PDESC: ++ return "MIPS_PDESC"; ++ case SHT_MIPS_LOCSYM: ++ return "MIPS_LOCSYM"; ++ case SHT_MIPS_AUXSYM: ++ return "MIPS_AUXSYM"; ++ case SHT_MIPS_OPTSYM: ++ return "MIPS_OPTSYM"; ++ case SHT_MIPS_LOCSTR: ++ return "MIPS_LOCSTR"; ++ case SHT_MIPS_LINE: ++ return "MIPS_LINE"; ++ case SHT_MIPS_RFDESC: ++ return "MIPS_RFDESC"; ++ case SHT_MIPS_DELTASYM: ++ return "MIPS_DELTASYM"; ++ case SHT_MIPS_DELTAINST: ++ return "MIPS_DELTAINST"; ++ case SHT_MIPS_DELTACLASS: ++ return "MIPS_DELTACLASS"; ++ case SHT_MIPS_DWARF: ++ return "MIPS_DWARF"; ++ case SHT_MIPS_DELTADECL: ++ return "MIPS_DELTADECL"; ++ case SHT_MIPS_SYMBOL_LIB: ++ return "MIPS_SYMBOL_LIB"; ++ case SHT_MIPS_EVENTS: ++ return "MIPS_EVENTS"; ++ case SHT_MIPS_TRANSLATE: ++ return "MIPS_TRANSLATE"; ++ case SHT_MIPS_PIXIE: ++ return "MIPS_PIXIE"; ++ case SHT_MIPS_XLATE: ++ return "MIPS_XLATE"; ++ case SHT_MIPS_XLATE_DEBUG: ++ return "MIPS_XLATE_DEBUG"; ++ case SHT_MIPS_WHIRL: ++ return "MIPS_WHIRL"; ++ case SHT_MIPS_EH_REGION: ++ return "MIPS_EH_REGION"; ++ case SHT_MIPS_XLATE_OLD: ++ return "MIPS_XLATE_OLD"; ++ case SHT_MIPS_PDR_EXCEPTION: ++ return "MIPS_PDR_EXCEPTION"; ++ case SHT_MIPS_ABIFLAGS: ++ return "MIPS_ABIFLAGS"; ++ case SHT_MIPS_XHASH: ++ return "MIPS_XHASH"; ++ default: ++ break; ++ } ++ return NULL; ++} ++ ++bool ++mips_check_reloc_target_type (Ebl *ebl __attribute__ ((unused)), Elf64_Word sh_type) ++{ ++ return (sh_type == SHT_MIPS_DWARF); ++} ++ ++/* Check whether given symbol's st_value and st_size are OK despite failing ++ normal checks. */ ++bool ++mips_check_special_symbol (Elf *elf, ++ const GElf_Sym *sym __attribute__ ((unused)), ++ const char *name __attribute__ ((unused)), ++ const GElf_Shdr *destshdr) ++{ ++ size_t shstrndx; ++ if (elf_getshdrstrndx (elf, &shstrndx) != 0) ++ return false; ++ const char *sname = elf_strptr (elf, shstrndx, destshdr->sh_name); ++ if (sname == NULL) ++ return false; ++ return (strcmp (sname, ".got") == 0 || strcmp (sname, ".bss") == 0); ++} ++ ++/* Check whether SHF_MASKPROC flags are valid. */ ++bool ++mips_machine_section_flag_check (GElf_Xword sh_flags) ++{ ++ return ((sh_flags &~ (SHF_MIPS_GPREL | ++ SHF_MIPS_MERGE | ++ SHF_MIPS_ADDR | ++ SHF_MIPS_STRINGS | ++ SHF_MIPS_NOSTRIP | ++ SHF_MIPS_LOCAL | ++ SHF_MIPS_NAMES | ++ SHF_MIPS_NODUPE)) == 0); ++} ++ ++/* Check whether machine flags are valid. */ ++bool ++mips_machine_flag_check (GElf_Word flags) ++{ ++ if ((flags &~ (EF_MIPS_NOREORDER | ++ EF_MIPS_PIC | ++ EF_MIPS_CPIC | ++ EF_MIPS_UCODE | ++ EF_MIPS_ABI2 | ++ EF_MIPS_OPTIONS_FIRST | ++ EF_MIPS_32BITMODE | ++ EF_MIPS_NAN2008 | ++ EF_MIPS_FP64 | ++ EF_MIPS_ARCH_ASE_MDMX | ++ EF_MIPS_ARCH_ASE_M16 | ++ EF_MIPS_ARCH_ASE_MICROMIPS)) == 0) ++ return false; ++ ++ switch(flags & EF_MIPS_MACH) ++ { ++ case EF_MIPS_MACH_3900: ++ case EF_MIPS_MACH_4010: ++ case EF_MIPS_MACH_4100: ++ case EF_MIPS_MACH_4111: ++ case EF_MIPS_MACH_4120: ++ case EF_MIPS_MACH_4650: ++ case EF_MIPS_MACH_5400: ++ case EF_MIPS_MACH_5500: ++ case EF_MIPS_MACH_5900: ++ case EF_MIPS_MACH_SB1: ++ case EF_MIPS_MACH_9000: ++ case EF_MIPS_MACH_LS2E: ++ case EF_MIPS_MACH_LS2F: ++ case EF_MIPS_MACH_GS464: ++ case EF_MIPS_MACH_GS464E: ++ case EF_MIPS_MACH_GS264E: ++ case EF_MIPS_MACH_OCTEON: ++ case EF_MIPS_MACH_OCTEON2: ++ case EF_MIPS_MACH_OCTEON3: ++ case EF_MIPS_MACH_XLR: ++ case EF_MIPS_MACH_IAMR2: ++ case 0: ++ break; ++ default: ++ return false; ++ } ++ ++ switch ((flags & EF_MIPS_ABI)) ++ { ++ case EF_MIPS_ABI_O32: ++ case EF_MIPS_ABI_O64: ++ case EF_MIPS_ABI_EABI32: ++ case EF_MIPS_ABI_EABI64: ++ case 0: ++ break; ++ default: ++ return false; ++ } ++ ++ switch ((flags & EF_MIPS_ARCH)) ++ { ++ case EF_MIPS_ARCH_1: ++ case EF_MIPS_ARCH_2: ++ case EF_MIPS_ARCH_3: ++ case EF_MIPS_ARCH_4: ++ case EF_MIPS_ARCH_5: ++ case EF_MIPS_ARCH_32: ++ case EF_MIPS_ARCH_32R2: ++ case EF_MIPS_ARCH_32R6: ++ case EF_MIPS_ARCH_64: ++ case EF_MIPS_ARCH_64R2: ++ case EF_MIPS_ARCH_64R6: ++ return true; ++ default: ++ return false; ++ } ++ return false; ++} ++ ++/* copy binutils-2.34/binutils/readelf.c get_machine_flags */ ++const char * ++mips_machine_flag_name (Elf64_Word orig __attribute__ ((unused)), Elf64_Word *flagref) ++{ ++ if (*flagref & EF_MIPS_NOREORDER) ++ { ++ *flagref &= ~((Elf64_Word) EF_MIPS_NOREORDER); ++ return "noreorder"; ++ } ++ ++ if (*flagref & EF_MIPS_PIC) ++ { ++ *flagref &= ~((Elf64_Word) EF_MIPS_PIC); ++ return "pic"; ++ } ++ ++ if (*flagref & EF_MIPS_CPIC) ++ { ++ *flagref &= ~((Elf64_Word) EF_MIPS_CPIC); ++ return "cpic"; ++ } ++ ++ if (*flagref & EF_MIPS_UCODE) ++ { ++ *flagref &= ~((Elf64_Word) EF_MIPS_UCODE); ++ return "ugen_reserved"; ++ } ++ ++ if (*flagref & EF_MIPS_ABI2) ++ { ++ *flagref &= ~((Elf64_Word) EF_MIPS_ABI2); ++ return "abi2"; ++ } ++ ++ if (*flagref & EF_MIPS_OPTIONS_FIRST) ++ { ++ *flagref &= ~((Elf64_Word) EF_MIPS_OPTIONS_FIRST); ++ return "odk first"; ++ } ++ ++ if (*flagref & EF_MIPS_32BITMODE) ++ { ++ *flagref &= ~((Elf64_Word) EF_MIPS_32BITMODE); ++ return "32bitmode"; ++ } ++ ++ if (*flagref & EF_MIPS_NAN2008) ++ { ++ *flagref &= ~((Elf64_Word) EF_MIPS_NAN2008); ++ return "nan2008"; ++ } ++ ++ if (*flagref & EF_MIPS_FP64) ++ { ++ *flagref &= ~((Elf64_Word) EF_MIPS_FP64); ++ return "fp64"; ++ } ++ ++ switch (*flagref & EF_MIPS_MACH) ++ { ++ case EF_MIPS_MACH_3900: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_3900); ++ return "3900"; ++ case EF_MIPS_MACH_4010: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_4010); ++ return "4010"; ++ case EF_MIPS_MACH_4100: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_4100); ++ return "4100"; ++ case EF_MIPS_MACH_4111: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_4111); ++ return "4111"; ++ case EF_MIPS_MACH_4120: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_4120); ++ return "4120"; ++ case EF_MIPS_MACH_4650: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_4650); ++ return "4650"; ++ case EF_MIPS_MACH_5400: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_5400); ++ return "5400"; ++ case EF_MIPS_MACH_5500: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_5500); ++ return "5500"; ++ case EF_MIPS_MACH_5900: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_5900); ++ return "5900"; ++ case EF_MIPS_MACH_SB1: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_SB1); ++ return "sb1"; ++ case EF_MIPS_MACH_9000: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_9000); ++ return "9000"; ++ case EF_MIPS_MACH_LS2E: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_LS2E); ++ return "loongson-2e"; ++ case EF_MIPS_MACH_LS2F: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_LS2F); ++ return "loongson-2f"; ++ case EF_MIPS_MACH_GS464: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_GS464); ++ return "gs464"; ++ case EF_MIPS_MACH_GS464E: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_GS464E); ++ return "gs464e"; ++ case EF_MIPS_MACH_GS264E: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_GS264E); ++ return "gs264e"; ++ case EF_MIPS_MACH_OCTEON: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_OCTEON); ++ return "octeon"; ++ case EF_MIPS_MACH_OCTEON2: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_OCTEON2); ++ return "octeon2"; ++ case EF_MIPS_MACH_OCTEON3: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_OCTEON3); ++ return "octeon3"; ++ case EF_MIPS_MACH_XLR: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_XLR); ++ return "xlr"; ++ case EF_MIPS_MACH_IAMR2: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH_IAMR2); ++ return "interaptiv-mr2"; ++ case 0: ++ /* We simply ignore the field in this case to avoid confusion: ++ MIPS ELF does not specify EF_MIPS_MACH, it is a GNU ++ extension. */ ++ break; ++ default: ++ *flagref &= ~((Elf64_Word) EF_MIPS_MACH); ++ return "unknown CPU"; ++ } ++ switch (*flagref & EF_MIPS_ABI) ++ { ++ case EF_MIPS_ABI_O32: ++ *flagref &= ~((Elf64_Word) EF_MIPS_ABI_O32); ++ return "o32"; ++ case EF_MIPS_ABI_O64: ++ *flagref &= ~((Elf64_Word) EF_MIPS_ABI_O64); ++ return "o64"; ++ case EF_MIPS_ABI_EABI32: ++ *flagref &= ~((Elf64_Word) EF_MIPS_ABI_EABI32); ++ return "eabi32"; ++ case EF_MIPS_ABI_EABI64: ++ *flagref &= ~((Elf64_Word) EF_MIPS_ABI_EABI64); ++ return "eabi64"; ++ case 0: ++ /* We simply ignore the field in this case to avoid confusion: ++ MIPS ELF does not specify EF_MIPS_ABI, it is a GNU extension. ++ This means it is likely to be an o32 file, but not for ++ sure. */ ++ break; ++ default: ++ *flagref &= ~((Elf64_Word) EF_MIPS_ABI); ++ return "unknown ABI"; ++ } ++ ++ if (*flagref & EF_MIPS_ARCH_ASE_MDMX) ++ { ++ *flagref &= ~((Elf64_Word) EF_MIPS_ARCH_ASE_MDMX); ++ return "mdmx"; ++ } ++ ++ if (*flagref & EF_MIPS_ARCH_ASE_M16) ++ { ++ *flagref &= ~((Elf64_Word) EF_MIPS_ARCH_ASE_M16); ++ return "mips16"; ++ } ++ ++ if (*flagref & EF_MIPS_ARCH_ASE_MICROMIPS) ++ { ++ *flagref &= ~((Elf64_Word) EF_MIPS_ARCH_ASE_MICROMIPS); ++ return "micromips"; ++ } ++ ++ switch (*flagref & EF_MIPS_ARCH) ++ { ++ case EF_MIPS_ARCH_1: ++ *flagref &= ~((Elf64_Word) EF_MIPS_ARCH_1); ++ return "mips1"; ++ case EF_MIPS_ARCH_2: ++ *flagref &= ~((Elf64_Word) EF_MIPS_ARCH_2); ++ return "mips2"; ++ case EF_MIPS_ARCH_3: ++ *flagref &= ~((Elf64_Word) EF_MIPS_ARCH_3); ++ return "mips3"; ++ case EF_MIPS_ARCH_4: ++ *flagref &= ~((Elf64_Word) EF_MIPS_ARCH_4); ++ return "mips4"; ++ case EF_MIPS_ARCH_5: ++ *flagref &= ~((Elf64_Word) EF_MIPS_ARCH_5); ++ return "mips5"; ++ case EF_MIPS_ARCH_32: ++ *flagref &= ~((Elf64_Word) EF_MIPS_ARCH_32); ++ return "mips32"; ++ case EF_MIPS_ARCH_32R2: ++ *flagref &= ~((Elf64_Word) EF_MIPS_ARCH_32R2); ++ return "mips32r2"; ++ case EF_MIPS_ARCH_32R6: ++ *flagref &= ~((Elf64_Word) EF_MIPS_ARCH_32R6); ++ return "mips32r6"; ++ case EF_MIPS_ARCH_64: ++ *flagref &= ~((Elf64_Word) EF_MIPS_ARCH_64); ++ return "mips64"; ++ case EF_MIPS_ARCH_64R2: ++ *flagref &= ~((Elf64_Word) EF_MIPS_ARCH_64R2); ++ return "mips64r2"; ++ case EF_MIPS_ARCH_64R6: ++ *flagref &= ~((Elf64_Word) EF_MIPS_ARCH_64R6); ++ return "mips64r6"; ++ default: ++ *flagref &= ~((Elf64_Word) EF_MIPS_ARCH); ++ return "unknown ISA"; ++ } ++ return NULL; ++} ++ ++/* copy binutils-2.34/binutils/readelf.c get_mips_segment_type */ ++const char * ++mips_segment_type_name (int segment, char *buf __attribute__ ((unused)), ++ size_t len __attribute__ ((unused))) ++{ ++ switch (segment) ++ { ++ case PT_MIPS_REGINFO: ++ return "REGINFO"; ++ case PT_MIPS_RTPROC: ++ return "RTPROC"; ++ case PT_MIPS_OPTIONS: ++ return "OPTIONS"; ++ case PT_MIPS_ABIFLAGS: ++ return "ABIFLAGS"; ++ default: ++ return NULL; ++ } ++} ++ ++bool ++mips_dynamic_tag_check (int64_t tag) ++{ ++ return ((tag &~ (DT_MIPS_RLD_VERSION ++ | DT_MIPS_TIME_STAMP ++ | DT_MIPS_ICHECKSUM ++ | DT_MIPS_IVERSION ++ | DT_MIPS_FLAGS ++ | DT_MIPS_BASE_ADDRESS ++ | DT_MIPS_MSYM ++ | DT_MIPS_CONFLICT ++ | DT_MIPS_LIBLIST ++ | DT_MIPS_LOCAL_GOTNO ++ | DT_MIPS_CONFLICTNO ++ | DT_MIPS_LIBLISTNO ++ | DT_MIPS_SYMTABNO ++ | DT_MIPS_UNREFEXTNO ++ | DT_MIPS_GOTSYM ++ | DT_MIPS_HIPAGENO ++ | DT_MIPS_RLD_MAP ++ | DT_MIPS_DELTA_CLASS ++ | DT_MIPS_DELTA_CLASS_NO ++ | DT_MIPS_DELTA_INSTANCE ++ | DT_MIPS_DELTA_INSTANCE_NO ++ | DT_MIPS_DELTA_RELOC ++ | DT_MIPS_DELTA_RELOC_NO ++ | DT_MIPS_DELTA_SYM ++ | DT_MIPS_DELTA_SYM_NO ++ | DT_MIPS_DELTA_CLASSSYM ++ | DT_MIPS_DELTA_CLASSSYM_NO ++ | DT_MIPS_CXX_FLAGS ++ | DT_MIPS_PIXIE_INIT ++ | DT_MIPS_SYMBOL_LIB ++ | DT_MIPS_LOCALPAGE_GOTIDX ++ | DT_MIPS_LOCAL_GOTIDX ++ | DT_MIPS_HIDDEN_GOTIDX ++ | DT_MIPS_PROTECTED_GOTIDX ++ | DT_MIPS_OPTIONS ++ | DT_MIPS_INTERFACE ++ | DT_MIPS_DYNSTR_ALIGN ++ | DT_MIPS_INTERFACE_SIZE ++ | DT_MIPS_RLD_TEXT_RESOLVE_ADDR ++ | DT_MIPS_PERF_SUFFIX ++ | DT_MIPS_COMPACT_SIZE ++ | DT_MIPS_GP_VALUE ++ | DT_MIPS_AUX_DYNAMIC ++ | DT_MIPS_PLTGOT ++ | DT_MIPS_RWPLT ++ | DT_MIPS_RLD_MAP_REL ++ | DT_MIPS_XHASH)) == 0); ++} ++ ++/* copy binutils-2.34/binutils/readelf.c get_mips_dynamic_type*/ ++const char * ++mips_dynamic_tag_name (int64_t tag, char *buf __attribute__ ((unused)), ++ size_t len __attribute__ ((unused))) ++{ ++ switch (tag) ++ { ++ case DT_MIPS_RLD_VERSION: ++ return "MIPS_RLD_VERSION"; ++ case DT_MIPS_TIME_STAMP: ++ return "MIPS_TIME_STAMP"; ++ case DT_MIPS_ICHECKSUM: ++ return "MIPS_ICHECKSUM"; ++ case DT_MIPS_IVERSION: ++ return "MIPS_IVERSION"; ++ case DT_MIPS_FLAGS: ++ return "MIPS_FLAGS"; ++ case DT_MIPS_BASE_ADDRESS: ++ return "MIPS_BASE_ADDRESS"; ++ case DT_MIPS_MSYM: ++ return "MIPS_MSYM"; ++ case DT_MIPS_CONFLICT: ++ return "MIPS_CONFLICT"; ++ case DT_MIPS_LIBLIST: ++ return "MIPS_LIBLIST"; ++ case DT_MIPS_LOCAL_GOTNO: ++ return "MIPS_LOCAL_GOTNO"; ++ case DT_MIPS_CONFLICTNO: ++ return "MIPS_CONFLICTNO"; ++ case DT_MIPS_LIBLISTNO: ++ return "MIPS_LIBLISTNO"; ++ case DT_MIPS_SYMTABNO: ++ return "MIPS_SYMTABNO"; ++ case DT_MIPS_UNREFEXTNO: ++ return "MIPS_UNREFEXTNO"; ++ case DT_MIPS_GOTSYM: ++ return "MIPS_GOTSYM"; ++ case DT_MIPS_HIPAGENO: ++ return "MIPS_HIPAGENO"; ++ case DT_MIPS_RLD_MAP: ++ return "MIPS_RLD_MAP"; ++ case DT_MIPS_RLD_MAP_REL: ++ return "MIPS_RLD_MAP_REL"; ++ case DT_MIPS_DELTA_CLASS: ++ return "MIPS_DELTA_CLASS"; ++ case DT_MIPS_DELTA_CLASS_NO: ++ return "MIPS_DELTA_CLASS_NO"; ++ case DT_MIPS_DELTA_INSTANCE: ++ return "MIPS_DELTA_INSTANCE"; ++ case DT_MIPS_DELTA_INSTANCE_NO: ++ return "MIPS_DELTA_INSTANCE_NO"; ++ case DT_MIPS_DELTA_RELOC: ++ return "MIPS_DELTA_RELOC"; ++ case DT_MIPS_DELTA_RELOC_NO: ++ return "MIPS_DELTA_RELOC_NO"; ++ case DT_MIPS_DELTA_SYM: ++ return "MIPS_DELTA_SYM"; ++ case DT_MIPS_DELTA_SYM_NO: ++ return "MIPS_DELTA_SYM_NO"; ++ case DT_MIPS_DELTA_CLASSSYM: ++ return "MIPS_DELTA_CLASSSYM"; ++ case DT_MIPS_DELTA_CLASSSYM_NO: ++ return "MIPS_DELTA_CLASSSYM_NO"; ++ case DT_MIPS_CXX_FLAGS: ++ return "MIPS_CXX_FLAGS"; ++ case DT_MIPS_PIXIE_INIT: ++ return "MIPS_PIXIE_INIT"; ++ case DT_MIPS_SYMBOL_LIB: ++ return "MIPS_SYMBOL_LIB"; ++ case DT_MIPS_LOCALPAGE_GOTIDX: ++ return "MIPS_LOCALPAGE_GOTIDX"; ++ case DT_MIPS_LOCAL_GOTIDX: ++ return "MIPS_LOCAL_GOTIDX"; ++ case DT_MIPS_HIDDEN_GOTIDX: ++ return "MIPS_HIDDEN_GOTIDX"; ++ case DT_MIPS_PROTECTED_GOTIDX: ++ return "MIPS_PROTECTED_GOTIDX"; ++ case DT_MIPS_OPTIONS: ++ return "MIPS_OPTIONS"; ++ case DT_MIPS_INTERFACE: ++ return "MIPS_INTERFACE"; ++ case DT_MIPS_DYNSTR_ALIGN: ++ return "MIPS_DYNSTR_ALIGN"; ++ case DT_MIPS_INTERFACE_SIZE: ++ return "MIPS_INTERFACE_SIZE"; ++ case DT_MIPS_RLD_TEXT_RESOLVE_ADDR: ++ return "MIPS_RLD_TEXT_RESOLVE_ADDR"; ++ case DT_MIPS_PERF_SUFFIX: ++ return "MIPS_PERF_SUFFIX"; ++ case DT_MIPS_COMPACT_SIZE: ++ return "MIPS_COMPACT_SIZE"; ++ case DT_MIPS_GP_VALUE: ++ return "MIPS_GP_VALUE"; ++ case DT_MIPS_AUX_DYNAMIC: ++ return "MIPS_AUX_DYNAMIC"; ++ case DT_MIPS_PLTGOT: ++ return "MIPS_PLTGOT"; ++ case DT_MIPS_RWPLT: ++ return "MIPS_RWPLT"; ++ case DT_MIPS_XHASH: ++ return "MIPS_XHASH"; ++ default: ++ return NULL; ++ } ++ return NULL; ++} +--- a/libebl/eblopenbackend.c ++++ b/libebl/eblopenbackend.c +@@ -57,6 +57,7 @@ Ebl *riscv_init (Elf *, GElf_Half, Ebl * + Ebl *csky_init (Elf *, GElf_Half, Ebl *); + Ebl *loongarch_init (Elf *, GElf_Half, Ebl *); + Ebl *arc_init (Elf *, GElf_Half, Ebl *); ++Ebl *mips_init (Elf *, GElf_Half, Ebl *); + + /* This table should contain the complete list of architectures as far + as the ELF specification is concerned. */ +@@ -154,6 +155,7 @@ static const struct + { csky_init, "elf_csky", "csky", 4, EM_CSKY, ELFCLASS32, ELFDATA2LSB }, + { loongarch_init, "elf_loongarch", "loongarch", 9, EM_LOONGARCH, ELFCLASS64, ELFDATA2LSB }, + { arc_init, "elf_arc", "arc", 3, EM_ARCV2, ELFCLASS32, ELFDATA2LSB }, ++ { mips_init, "elf_mips", "mips", 4, EM_MIPS, 0, 0 }, + }; + #define nmachines (sizeof (machines) / sizeof (machines[0])) + +--- a/libelf/libelfP.h ++++ b/libelf/libelfP.h +@@ -617,4 +617,8 @@ extern void __libelf_reset_rawdata (Elf_ + #define INVALID_NDX(ndx, type, data) \ + unlikely ((data)->d_size / sizeof (type) <= (unsigned int) (ndx)) + ++#define ELF64_MIPS_R_TYPE1(i) ((i) & 0xff) ++#define ELF64_MIPS_R_TYPE2(i) (((i) >> 8) & 0xff) ++#define ELF64_MIPS_R_TYPE3(i) (((i) >> 16) & 0xff) ++#define is_debug_section_type(type) (type == SHT_PROGBITS || type == SHT_MIPS_DWARF) + #endif /* libelfP.h */ +--- /dev/null ++++ b/backends/mips_cfi.c +@@ -0,0 +1,68 @@ ++/* MIPS ABI-specified defaults for DWARF CFI. ++ Copyright (C) 2009 Red Hat, Inc. ++ Copyright (C) 2024 CIP United Inc. ++ This file is part of elfutils. ++ ++ This file is free software; you can redistribute it and/or modify ++ it under the terms of either ++ ++ * the GNU Lesser General Public License as published by the Free ++ Software Foundation; either version 3 of the License, or (at ++ your option) any later version ++ ++ or ++ ++ * the GNU General Public License as published by the Free ++ Software Foundation; either version 2 of the License, or (at ++ your option) any later version ++ ++ or both in parallel, as here. ++ ++ elfutils 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. ++ ++ You should have received copies of the GNU General Public License and ++ the GNU Lesser General Public License along with this program. If ++ not, see <http://www.gnu.org/licenses/>. */ ++ ++#ifdef HAVE_CONFIG_H ++# include <config.h> ++#endif ++ ++#include <dwarf.h> ++ ++#define BACKEND mips_ ++#include "libebl_CPU.h" ++ ++int ++mips_abi_cfi (Ebl *ebl __attribute__ ((unused)), Dwarf_CIE *abi_info) ++{ ++ static const uint8_t abi_cfi[] = ++ { ++ DW_CFA_def_cfa, ULEB128_7 (31), ULEB128_7 (0), ++ /* Callee-saved regs. */ ++ DW_CFA_same_value, ULEB128_7 (16), /* s0 */ ++ DW_CFA_same_value, ULEB128_7 (17), /* s1 */ ++ DW_CFA_same_value, ULEB128_7 (18), /* s2 */ ++ DW_CFA_same_value, ULEB128_7 (19), /* s3 */ ++ DW_CFA_same_value, ULEB128_7 (20), /* s4 */ ++ DW_CFA_same_value, ULEB128_7 (21), /* s5 */ ++ DW_CFA_same_value, ULEB128_7 (22), /* s6 */ ++ DW_CFA_same_value, ULEB128_7 (23), /* s7 */ ++ DW_CFA_same_value, ULEB128_7 (28), /* gp */ ++ DW_CFA_same_value, ULEB128_7 (29), /* sp */ ++ DW_CFA_same_value, ULEB128_7 (30), /* fp */ ++ ++ DW_CFA_val_offset, ULEB128_7 (29), ULEB128_7 (0), ++ }; ++ ++ abi_info->initial_instructions = abi_cfi; ++ abi_info->initial_instructions_end = &abi_cfi[sizeof abi_cfi]; ++ abi_info->data_alignment_factor = 8; ++ ++ abi_info->return_address_register = 31; /* %ra */ ++ ++ return 0; ++} +--- /dev/null ++++ b/backends/mips_initreg.c +@@ -0,0 +1,61 @@ ++/* Fetch live process registers from TID. ++ Copyright (C) 2024 CIP United Inc. ++ This file is part of elfutils. ++ ++ This file is free software; you can redistribute it and/or modify ++ it under the terms of either ++ ++ * the GNU Lesser General Public License as published by the Free ++ Software Foundation; either version 3 of the License, or (at ++ your option) any later version ++ ++ or ++ ++ * the GNU General Public License as published by the Free ++ Software Foundation; either version 2 of the License, or (at ++ your option) any later version ++ ++ or both in parallel, as here. ++ ++ elfutils 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. ++ ++ You should have received copies of the GNU General Public License and ++ the GNU Lesser General Public License along with this program. If ++ not, see <http://www.gnu.org/licenses/>. */ ++ ++#ifdef HAVE_CONFIG_H ++# include <config.h> ++#endif ++ ++#include <stdlib.h> ++#if (defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)) && defined(__linux__) ++# include <sys/user.h> ++# include <sys/ptrace.h> ++#include <asm/ptrace.h> ++#endif ++ ++#define BACKEND mips_ ++#include "libebl_CPU.h" ++ ++ ++bool ++mips_set_initial_registers_tid (pid_t tid __attribute__ ((unused)), ++ ebl_tid_registers_t *setfunc __attribute__ ((unused)), ++ void *arg __attribute__ ((unused))) ++{ ++#if (!defined(mips) && !defined(__mips) && !defined(__mips__) && !defined(MIPS) && !defined(__MIPS__)) || !defined(__linux__) ++ return false; ++#else /* __mips__ */ ++/* For PTRACE_GETREGS */ ++ ++ struct pt_regs gregs; ++ if (ptrace (PTRACE_GETREGS, tid, 0, &gregs) != 0) ++ return false; ++ if (! setfunc (-1, 1, (Dwarf_Word *) &gregs.cp0_epc, arg)) ++ return false; ++ return setfunc (0, 32, (Dwarf_Word *) &gregs.regs[0], arg); ++#endif /* __mips__ */ ++} +--- /dev/null ++++ b/backends/mips_unwind.c +@@ -0,0 +1,84 @@ ++/* Get previous frame state for an existing frame state. ++ Copyright (C) 2016 The Qt Company Ltd. ++ Copyright (C) 2024 CIP United Inc. ++ This file is part of elfutils. ++ ++ This file is free software; you can redistribute it and/or modify ++ it under the terms of either ++ ++ * the GNU Lesser General Public License as published by the Free ++ Software Foundation; either version 3 of the License, or (at ++ your option) any later version ++ ++ or ++ ++ * the GNU General Public License as published by the Free ++ Software Foundation; either version 2 of the License, or (at ++ your option) any later version ++ ++ or both in parallel, as here. ++ ++ elfutils 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. ++ ++ You should have received copies of the GNU General Public License and ++ the GNU Lesser General Public License along with this program. If ++ not, see <http://www.gnu.org/licenses/>. */ ++ ++#ifdef HAVE_CONFIG_H ++# include <config.h> ++#endif ++ ++#define BACKEND mips_ ++#define SP_REG 29 ++#define FP_REG 30 ++#define LR_REG 31 ++#define FP_OFFSET 0 ++#define LR_OFFSET 8 ++#define SP_OFFSET 16 ++ ++#include "libebl_CPU.h" ++ ++/* There was no CFI. Maybe we happen to have a frame pointer and can unwind from that? */ ++ ++bool ++EBLHOOK(unwind) (Ebl *ebl __attribute__ ((unused)), Dwarf_Addr pc __attribute__ ((unused)), ++ ebl_tid_registers_t *setfunc, ebl_tid_registers_get_t *getfunc, ++ ebl_pid_memory_read_t *readfunc, void *arg, ++ bool *signal_framep __attribute__ ((unused))) ++{ ++ Dwarf_Word fp, lr, sp; ++ ++ if (!getfunc(LR_REG, 1, &lr, arg)) ++ return false; ++ ++ if (lr == 0 || !setfunc(-1, 1, &lr, arg)) ++ return false; ++ ++ if (!getfunc(FP_REG, 1, &fp, arg)) ++ fp = 0; ++ ++ if (!getfunc(SP_REG, 1, &sp, arg)) ++ sp = 0; ++ ++ Dwarf_Word newLr, newFp, newSp; ++ ++ if (!readfunc(fp + LR_OFFSET, &newLr, arg)) ++ newLr = 0; ++ ++ if (!readfunc(fp + FP_OFFSET, &newFp, arg)) ++ newFp = 0; ++ ++ newSp = fp + SP_OFFSET; ++ ++ // These are not fatal if they don't work. They will just prevent unwinding at the next frame. ++ setfunc(LR_REG, 1, &newLr, arg); ++ setfunc(FP_REG, 1, &newFp, arg); ++ setfunc(SP_REG, 1, &newSp, arg); ++ ++ // If the fp is invalid, we might still have a valid lr. ++ // But if the fp is valid, then the stack should be moving in the right direction. ++ return fp == 0 || newSp > sp; ++} +--- /dev/null ++++ b/backends/mips_corenote.c +@@ -0,0 +1,104 @@ ++/* MIPS specific core note handling. ++ Copyright (C) 2024 CIP United Inc. ++ This file is part of elfutils. ++ ++ This file is free software; you can redistribute it and/or modify ++ it under the terms of either ++ ++ * the GNU Lesser General Public License as published by the Free ++ Software Foundation; either version 3 of the License, or (at ++ your option) any later version ++ ++ or ++ ++ * the GNU General Public License as published by the Free ++ Software Foundation; either version 2 of the License, or (at ++ your option) any later version ++ ++ or both in parallel, as here. ++ ++ elfutils 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. ++ ++ You should have received copies of the GNU General Public License and ++ the GNU Lesser General Public License along with this program. If ++ not, see <http://www.gnu.org/licenses/>. */ ++ ++#ifdef HAVE_CONFIG_H ++# include <config.h> ++#endif ++ ++#include <elf.h> ++#include <inttypes.h> ++#include <stddef.h> ++#include <stdio.h> ++#include <sys/time.h> ++#include "libebl_CPU.h" ++ ++#ifndef BITS ++# define BITS 32 ++#define BACKEND mips_ ++#else ++# define BITS 64 ++# define BACKEND mips64_ ++#endif ++ ++#define PRSTATUS_REGS_SIZE (45 * (BITS / 8)) ++static const Ebl_Register_Location prstatus_regs[] = ++ { ++ { .offset = 0, .regno = 0, .count = (BITS == 32 ? 40 : 34), .bits = BITS }, ++ { .offset = BITS/8 * (BITS == 32 ? 41 : 35), .regno = (BITS == 32 ? 41 : 35), .count = (BITS == 32 ? 4 : 10), .bits = BITS }, ++ }; ++ ++#define PRSTATUS_REGSET_ITEMS \ ++ { \ ++ .name = "pc", .type = ELF_T_ADDR, .format = 'x', \ ++ .offset = offsetof (struct EBLHOOK(prstatus), pr_reg) + ((BITS/8) * (BITS == 32 ? 40 : 34)), \ ++ .group = "register", \ ++ .pc_register = true \ ++ } ++ ++static const Ebl_Register_Location mips_fpregset_regs[] = ++ { ++ { .offset = 0, .regno = 38, .count = 32, .bits = 64 }, /* fp0-fp31 */ ++ }; ++ ++static const Ebl_Core_Item mips_fpregset_items[] = ++ { ++ { ++ .name = "fcs", .type = ELF_T_WORD, .format = 'x', ++ .offset = 32 * 8, .group = "register" ++ }, ++ { ++ .name = "fir", .type = ELF_T_WORD, .format = 'x', ++ .offset = 32 * 8 + 4, .group = "register" ++ } ++ }; ++ ++#if BITS == 32 ++# define ULONG uint32_t ++# define ALIGN_ULONG 4 ++# define TYPE_ULONG ELF_T_WORD ++#define TYPE_LONG ELF_T_SWORD ++#else ++#define ULONG uint64_t ++#define ALIGN_ULONG 8 ++#define TYPE_ULONG ELF_T_XWORD ++#define TYPE_LONG ELF_T_SXWORD ++#endif ++#define PID_T int32_t ++#define UID_T uint32_t ++#define GID_T uint32_t ++#define ALIGN_PID_T 4 ++#define ALIGN_UID_T 4 ++#define ALIGN_GID_T 4 ++#define TYPE_PID_T ELF_T_SWORD ++#define TYPE_UID_T ELF_T_WORD ++#define TYPE_GID_T ELF_T_WORD ++ ++#define EXTRA_NOTES \ ++ EXTRA_REGSET_ITEMS (NT_FPREGSET, 32 * 8 + 4 * 2, mips_fpregset_regs, mips_fpregset_items) ++ ++#include "linux-core-note.c" +--- /dev/null ++++ b/backends/mips_regs.c +@@ -0,0 +1,135 @@ ++/* Register names and numbers for mips DWARF. ++ Copyright (C) 2006 Red Hat, Inc. ++ Copyright (C) 2024 CIP United Inc. ++ This file is part of elfutils. ++ ++ This file is free software; you can redistribute it and/or modify ++ it under the terms of either ++ ++ * the GNU Lesser General Public License as published by the Free ++ Software Foundation; either version 3 of the License, or (at ++ your option) any later version ++ ++ or ++ ++ * the GNU General Public License as published by the Free ++ Software Foundation; either version 2 of the License, or (at ++ your option) any later version ++ ++ or both in parallel, as here. ++ ++ elfutils 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. ++ ++ You should have received copies of the GNU General Public License and ++ the GNU Lesser General Public License along with this program. If ++ not, see <http://www.gnu.org/licenses/>. */ ++ ++#ifdef HAVE_CONFIG_H ++# include <config.h> ++#endif ++ ++#include <assert.h> ++#include <dwarf.h> ++#include <string.h> ++ ++#define BACKEND mips_ ++#include "libebl_CPU.h" ++#include <system.h> ++ssize_t ++mips_register_info (Ebl *ebl __attribute__ ((unused)), ++ int regno, char *name, size_t namelen, ++ const char **prefix, const char **setname, ++ int *bits, int *type) ++{ ++ if (name == NULL) ++ return 72; ++ ++ if (regno < 0 || regno > 71 || namelen < 4) ++ return -1; ++ ++ *prefix = "$"; ++ if (regno < 38) ++ { ++ *setname = "integer"; ++ *type = DW_ATE_signed; ++ *bits = 32; ++ } ++ else ++ { ++ *setname = "FPU"; ++ *type = DW_ATE_float; ++ *bits = 64; ++ } ++ ++ if (regno < 32) ++ { ++ if (regno < 10) ++ { ++ name[0] = regno + '0'; ++ namelen = 1; ++ } ++ else ++ { ++ name[0] = (regno / 10) + '0'; ++ name[1] = (regno % 10) + '0'; ++ namelen = 2; ++ } ++ if (regno == 28 || regno == 29 || regno == 31) ++ *type = DW_ATE_address; ++ } ++ else if (regno == 32) ++ { ++ return stpcpy (name, "lo") + 1 - name; ++ } ++ else if (regno == 33) ++ { ++ return stpcpy (name, "hi") + 1 - name; ++ } ++ else if (regno == 34) ++ { ++ return stpcpy (name, "pc") + 1 - name; ++ } ++ else if (regno == 35) ++ { ++ *type = DW_ATE_address; ++ return stpcpy (name, "bad") + 1 - name; ++ } ++ else if (regno == 36) ++ { ++ return stpcpy (name, "sr") + 1 - name; ++ } ++ else if (regno == 37) ++ { ++ *type = DW_ATE_address; ++ return stpcpy (name, "cause") + 1 - name; ++ } ++ else if (regno < 70) ++ { ++ name[0] = 'f'; ++ if (regno < 38 + 10) ++ { ++ name[1] = (regno - 38) + '0'; ++ namelen = 2; ++ } ++ else ++ { ++ name[1] = (regno - 38) / 10 + '0'; ++ name[2] = (regno - 38) % 10 + '0'; ++ namelen = 3; ++ } ++ } ++ else if (regno == 70) ++ { ++ return stpcpy (name, "fsr") + 1 - name; ++ } ++ else if (regno == 71) ++ { ++ return stpcpy (name, "fir") + 1 - name; ++ } ++ ++ name[namelen++] = '\0'; ++ return namelen; ++} +--- /dev/null ++++ b/backends/mips_retval.c +@@ -0,0 +1,196 @@ ++/* Function return value location for Linux/mips ABI. ++ Copyright (C) 2005 Red Hat, Inc. ++ Copyright (C) 2024 CIP United Inc. ++ This file is part of elfutils. ++ ++ This file is free software; you can redistribute it and/or modify ++ it under the terms of either ++ ++ * the GNU Lesser General Public License as published by the Free ++ Software Foundation; either version 3 of the License, or (at ++ your option) any later version ++ ++ or ++ ++ * the GNU General Public License as published by the Free ++ Software Foundation; either version 2 of the License, or (at ++ your option) any later version ++ ++ or both in parallel, as here. ++ ++ elfutils 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. ++ ++ You should have received copies of the GNU General Public License and ++ the GNU Lesser General Public License along with this program. If ++ not, see <http://www.gnu.org/licenses/>. */ ++ ++#ifdef HAVE_CONFIG_H ++# include <config.h> ++#endif ++ ++#include <assert.h> ++#include <dwarf.h> ++#include <string.h> ++#include <elf.h> ++#include <stdio.h> ++ ++#define BACKEND mips_ ++#include "libebl_CPU.h" ++#include "libdwP.h" ++#include <stdio.h> ++ ++/* $v0 or pair $v0, $v1 */ ++static const Dwarf_Op loc_intreg_o32[] = ++ { ++ { .atom = DW_OP_reg2 }, { .atom = DW_OP_piece, .number = 4 }, ++ { .atom = DW_OP_reg3 }, { .atom = DW_OP_piece, .number = 4 }, ++ }; ++ ++static const Dwarf_Op loc_intreg[] = ++ { ++ { .atom = DW_OP_reg2 }, { .atom = DW_OP_piece, .number = 8 }, ++ { .atom = DW_OP_reg3 }, { .atom = DW_OP_piece, .number = 8 }, ++ }; ++#define nloc_intreg 1 ++#define nloc_intregpair 4 ++ ++/* $f0 (float), or pair $f0, $f1 (double). ++ * f2/f3 are used for COMPLEX (= 2 doubles) returns in Fortran */ ++static const Dwarf_Op loc_fpreg_o32[] = ++ { ++ { .atom = DW_OP_regx, .number = 32 }, { .atom = DW_OP_piece, .number = 4 }, ++ { .atom = DW_OP_regx, .number = 33 }, { .atom = DW_OP_piece, .number = 4 }, ++ { .atom = DW_OP_regx, .number = 34 }, { .atom = DW_OP_piece, .number = 4 }, ++ { .atom = DW_OP_regx, .number = 35 }, { .atom = DW_OP_piece, .number = 4 }, ++ }; ++ ++/* $f0, or pair $f0, $f2. */ ++static const Dwarf_Op loc_fpreg[] = ++ { ++ { .atom = DW_OP_regx, .number = 32 }, { .atom = DW_OP_piece, .number = 8 }, ++ { .atom = DW_OP_regx, .number = 34 }, { .atom = DW_OP_piece, .number = 8 }, ++ }; ++#define nloc_fpreg 1 ++#define nloc_fpregpair 4 ++#define nloc_fpregquad 8 ++ ++/* The return value is a structure and is actually stored in stack space ++ passed in a hidden argument by the caller. But, the compiler ++ helpfully returns the address of that space in $v0. */ ++static const Dwarf_Op loc_aggregate[] = ++ { ++ { .atom = DW_OP_breg2, .number = 0 } ++ }; ++#define nloc_aggregate 1 ++ ++int ++mips_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) ++{ ++ unsigned int regsize = (gelf_getclass (functypedie->cu->dbg->elf) == ELFCLASS32 ) ? 4 : 8; ++ if (!regsize) ++ return -2; ++ ++ /* Start with the function's type, and get the DW_AT_type attribute, ++ which is the type of the return value. */ ++ ++ Dwarf_Attribute attr_mem; ++ Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type, &attr_mem); ++ if (attr == NULL) ++ /* The function has no return value, like a `void' function in C. */ ++ return 0; ++ ++ Dwarf_Die die_mem; ++ Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem); ++ int tag = dwarf_tag (typedie); ++ ++ /* Follow typedefs and qualifiers to get to the actual type. */ ++ while (tag == DW_TAG_typedef ++ || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type ++ || tag == DW_TAG_restrict_type) ++ { ++ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem); ++ typedie = dwarf_formref_die (attr, &die_mem); ++ tag = dwarf_tag (typedie); ++ } ++ ++ switch (tag) ++ { ++ case -1: ++ return -1; ++ ++ case DW_TAG_subrange_type: ++ if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size)) ++ { ++ attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem); ++ typedie = dwarf_formref_die (attr, &die_mem); ++ tag = dwarf_tag (typedie); ++ } ++ /* Fall through. */ ++ FALLTHROUGH; ++ ++ case DW_TAG_base_type: ++ case DW_TAG_enumeration_type: ++ CASE_POINTER: ++ { ++ Dwarf_Word size; ++ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size, ++ &attr_mem), &size) != 0) ++ { ++ if (dwarf_is_pointer (tag)) ++ size = regsize; ++ else ++ return -1; ++ } ++ if (tag == DW_TAG_base_type) ++ { ++ Dwarf_Word encoding; ++ if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_encoding, ++ &attr_mem), &encoding) != 0) ++ return -1; ++ ++#define ARCH_LOC(loc, regsize) ((regsize) == 4 ? (loc ## _o32) : (loc)) ++ ++ if (encoding == DW_ATE_float) ++ { ++ *locp = ARCH_LOC(loc_fpreg, regsize); ++ if (size <= regsize) ++ return nloc_fpreg; ++ ++ if (size <= 2*regsize) ++ return nloc_fpregpair; ++ ++ if (size <= 4*regsize) ++ return nloc_fpregquad; ++ ++ goto aggregate; ++ } ++ } ++ *locp = ARCH_LOC(loc_intreg, regsize); ++ if (size <= regsize) ++ return nloc_intreg; ++ if (size <= 2*regsize) ++ return nloc_intregpair; ++ ++ /* Else fall through. Shouldn't happen though (at least with gcc) */ ++ } ++ FALLTHROUGH; ++ ++ case DW_TAG_structure_type: ++ case DW_TAG_class_type: ++ case DW_TAG_union_type: ++ case DW_TAG_array_type: ++ aggregate: ++ *locp = loc_aggregate; ++ return nloc_aggregate; ++ case DW_TAG_unspecified_type: ++ return 0; ++ } ++ ++ /* XXX We don't have a good way to return specific errors from ebl calls. ++ This value means we do not understand the type, but it is well-formed ++ DWARF and might be valid. */ ++ return -2; ++} +--- a/libelf/elf_getdata.c ++++ b/libelf/elf_getdata.c +@@ -135,6 +135,119 @@ __libelf_data_type (GElf_Ehdr *ehdr, int + + /* Convert the data in the current section. */ + static void ++convert_data_for_mips64el (Elf_Scn *scn, int eclass, ++ int data, size_t size, Elf_Type type) ++{ ++ /* Do we need to convert the data and/or adjust for alignment? */ ++ if (data == MY_ELFDATA || type == ELF_T_BYTE) ++ { ++ /* In order to adapt macro GELF_R_SYM and GELF_R_TYPE on mips64, need to convert ++ relocation info(raw data). Some eu-utils use read-mmap method to map file, so ++ we need to malloc and memcpy raw data to avoid segment fault. After modification, ++ the correct value are saved in the malloced memory not in process address space. */ ++ scn->data_base = malloc (size); ++ if (scn->data_base == NULL) ++ { ++ __libelf_seterrno (ELF_E_NOMEM); ++ return; ++ } ++ ++ /* The copy will be appropriately aligned for direct access. */ ++ memcpy (scn->data_base, scn->rawdata_base, size); ++ } ++ else ++ { ++ xfct_t fp; ++ ++ scn->data_base = malloc (size); ++ if (scn->data_base == NULL) ++ { ++ __libelf_seterrno (ELF_E_NOMEM); ++ return; ++ } ++ ++ /* Make sure the source is correctly aligned for the conversion ++ function to directly access the data elements. */ ++ char *rawdata_source; ++ /* In order to adapt macro GELF_R_SYM and GELF_R_TYPE on mips64, need to convert ++ relocation info(raw data). Some eu-utils use read-mmap method to map file, so ++ we need to malloc and memcpy raw data to avoid segment fault. After modification, ++ the correct value are saved in the malloced memory not in process address space. */ ++ rawdata_source = malloc (size); ++ if (rawdata_source == NULL) ++ { ++ __libelf_seterrno (ELF_E_NOMEM); ++ return; ++ } ++ ++ /* The copy will be appropriately aligned for direct access. */ ++ memcpy (rawdata_source, scn->rawdata_base, size); ++ ++ /* Get the conversion function. */ ++ fp = __elf_xfctstom[eclass - 1][type]; ++ ++ fp (scn->data_base, rawdata_source, size, 0); ++ ++ if (rawdata_source != scn->rawdata_base) ++ free (rawdata_source); ++ } ++ ++ scn->data_list.data.d.d_buf = scn->data_base; ++ scn->data_list.data.d.d_size = size; ++ scn->data_list.data.d.d_type = type; ++ scn->data_list.data.d.d_off = scn->rawdata.d.d_off; ++ scn->data_list.data.d.d_align = scn->rawdata.d.d_align; ++ scn->data_list.data.d.d_version = scn->rawdata.d.d_version; ++ ++ scn->data_list.data.s = scn; ++ ++ /* In mips64 little-endian, r_info consists of four byte fields(contains ++ three reloc types) and a 32-bit symbol index. In order to adapt ++ GELF_R_SYM and GELF_R_TYPE, need to convert r_info to get correct symbol ++ index and type. */ ++ /* references: ++ https://www.linux-mips.org/pub/linux/mips/doc/ABI/elf64-2.4.pdf ++ Page40 && Page41 */ ++ GElf_Shdr shdr_mem; ++ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); ++ if (shdr->sh_type == SHT_REL) ++ { ++ size_t sh_entsize = gelf_fsize (scn->elf, ELF_T_REL, 1, EV_CURRENT); ++ int nentries = shdr->sh_size / sh_entsize; ++ for (int cnt = 0; cnt < nentries; ++cnt) ++ { ++ Elf_Data_Scn *data_scn = (Elf_Data_Scn *) &scn->data_list.data.d; ++ Elf64_Rel *value = &((Elf64_Rel *) data_scn->d.d_buf)[cnt]; ++ Elf64_Xword info = value->r_info; ++ value->r_info = (((info & 0xffffffff) << 32) ++ | ((info >> 56) & 0xff) ++ | ((info >> 40) & 0xff00) ++ | ((info >> 24) & 0xff0000) ++ | ((info >> 8) & 0xff000000)); ++ ((Elf64_Rel *) data_scn->d.d_buf)[cnt] = *value; ++ } ++ } ++ else if (shdr->sh_type == SHT_RELA) ++ { ++ size_t sh_entsize = gelf_fsize (scn->elf, ELF_T_RELA, 1, EV_CURRENT); ++ int nentries = shdr->sh_size / sh_entsize; ++ for (int cnt = 0; cnt < nentries; cnt++) ++ { ++ Elf_Data_Scn *data_scn = (Elf_Data_Scn *) &scn->data_list.data.d; ++ Elf64_Rela *value = &((Elf64_Rela *) data_scn->d.d_buf)[cnt]; ++ Elf64_Xword info = value->r_info; ++ value->r_info = (((info & 0xffffffff) << 32) ++ | ((info >> 56) & 0xff) ++ | ((info >> 40) & 0xff00) ++ | ((info >> 24) & 0xff0000) ++ | ((info >> 8) & 0xff000000)); ++ ((Elf64_Rela *) data_scn->d.d_buf)[cnt] = *value; ++ } ++ } ++} ++ ++/* Convert the data in the current section. */ ++static void + convert_data (Elf_Scn *scn, int eclass, + int data, size_t size, Elf_Type type) + { +@@ -451,8 +564,23 @@ __libelf_set_data_list_rdlock (Elf_Scn * + return; + } + +- /* Convert according to the version and the type. */ +- convert_data (scn, elf->class, ++ GElf_Shdr shdr_mem; ++ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); ++ GElf_Ehdr ehdr_mem; ++ GElf_Ehdr *ehdr = gelf_getehdr (scn->elf, &ehdr_mem); ++ if (shdr != NULL && (shdr->sh_type == SHT_RELA || shdr->sh_type == SHT_REL) && ++ scn->elf->class == ELFCLASS64 && ehdr != NULL && ++ ehdr->e_machine == EM_MIPS && ehdr->e_ident[EI_DATA] == ELFDATA2LSB) ++ convert_data_for_mips64el (scn, elf->class, ++ (elf->class == ELFCLASS32 ++ || (offsetof (struct Elf, state.elf32.ehdr) ++ == offsetof (struct Elf, state.elf64.ehdr)) ++ ? elf->state.elf32.ehdr->e_ident[EI_DATA] ++ : elf->state.elf64.ehdr->e_ident[EI_DATA]), ++ scn->rawdata.d.d_size, scn->rawdata.d.d_type); ++ else ++ /* Convert according to the version and the type. */ ++ convert_data (scn, elf->class, + (elf->class == ELFCLASS32 + || (offsetof (struct Elf, state.elf32.ehdr) + == offsetof (struct Elf, state.elf64.ehdr)) +--- a/libelf/elf_update.c ++++ b/libelf/elf_update.c +@@ -228,7 +228,60 @@ elf_update (Elf *elf, Elf_Cmd cmd) + size = -1; + } + else ++ { ++ /* Because we converted the relocation info in mips order when we call elf_getdata.c, ++ so we need to convert the modified data in original order bits before writing the ++ data to the file. */ ++ Elf_Scn *scn = NULL; ++ while ((scn = elf_nextscn (elf, scn)) != NULL) ++ { ++ GElf_Shdr shdr_mem; ++ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); ++ GElf_Ehdr ehdr_mem; ++ GElf_Ehdr *ehdr = gelf_getehdr (scn->elf, &ehdr_mem); ++ if (shdr != NULL && (shdr->sh_type == SHT_RELA || shdr->sh_type == SHT_REL) && ++ scn->elf->class == ELFCLASS64 && ++ ehdr != NULL && ehdr->e_machine == EM_MIPS && ehdr->e_ident[EI_DATA] == ELFDATA2LSB) ++ { ++ Elf_Data *d = elf_getdata (scn, NULL); ++ if (shdr->sh_type == SHT_REL) ++ { ++ size_t sh_entsize = gelf_fsize (scn->elf, ELF_T_REL, 1, EV_CURRENT); ++ int nentries = shdr->sh_size / sh_entsize; ++ for (int cnt = 0; cnt < nentries; ++cnt) ++ { ++ Elf_Data_Scn *data_scn = (Elf_Data_Scn *) d; ++ Elf64_Rel *value = &((Elf64_Rel *) data_scn->d.d_buf)[cnt]; ++ Elf64_Xword info = value->r_info; ++ value->r_info = (info >> 32 ++ | ((info << 56) & 0xff00000000000000) ++ | ((info << 40) & 0xff000000000000) ++ | ((info << 24) & 0xff0000000000) ++ | ((info << 8) & 0xff00000000)); ++ ((Elf64_Rel *) data_scn->d.d_buf)[cnt] = *value; ++ } ++ } ++ else if (shdr->sh_type == SHT_RELA) ++ { ++ size_t sh_entsize = gelf_fsize (scn->elf, ELF_T_RELA, 1, EV_CURRENT); ++ int nentries = shdr->sh_size / sh_entsize; ++ for (int cnt = 0; cnt < nentries; cnt++) ++ { ++ Elf_Data_Scn *data_scn = (Elf_Data_Scn *) d; ++ Elf64_Rela *value = &((Elf64_Rela *) data_scn->d.d_buf)[cnt]; ++ Elf64_Xword info = value->r_info; ++ value->r_info = (info >> 32 ++ | ((info << 56) & 0xff00000000000000) ++ | ((info << 40) & 0xff000000000000) ++ | ((info << 24) & 0xff0000000000) ++ | ((info << 8) & 0xff00000000)); ++ ((Elf64_Rela *) data_scn->d.d_buf)[cnt] = *value; ++ } ++ } ++ } ++ } + size = write_file (elf, size, change_bo, shnum); ++ } + } + + out: +--- /dev/null ++++ b/backends/mips_attrs.c +@@ -0,0 +1,140 @@ ++/* Object attribute tags for MIPS. ++ Copyright (C) 2024 CIP United Inc. ++ This file is part of elfutils. ++ ++ This file is free software; you can redistribute it and/or modify ++ it under the terms of either ++ ++ * the GNU Lesser General Public License as published by the Free ++ Software Foundation; either version 3 of the License, or (at ++ your option) any later version ++ ++ or ++ ++ * the GNU General Public License as published by the Free ++ Software Foundation; either version 2 of the License, or (at ++ your option) any later version ++ ++ or both in parallel, as here. ++ ++ elfutils 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. ++ ++ You should have received copies of the GNU General Public License and ++ the GNU Lesser General Public License along with this program. If ++ not, see <http://www.gnu.org/licenses/>. */ ++ ++#ifdef HAVE_CONFIG_H ++# include <config.h> ++#endif ++ ++#include <string.h> ++#include <dwarf.h> ++ ++#define BACKEND mips_ ++#include "libebl_CPU.h" ++ ++#define KNOWN_VALUES(...) do \ ++ { \ ++ static const char *table[] = { __VA_ARGS__ }; \ ++ if (value < sizeof table / sizeof table[0]) \ ++ *value_name = table[value]; \ ++ } while (0) ++ ++//copy gnu attr tags from binutils-2.34/elfcpp/mips.h ++/* Object attribute tags. */ ++enum ++{ ++ /* 0-3 are generic. */ ++ ++ /* Floating-point ABI used by this object file. */ ++ Tag_GNU_MIPS_ABI_FP = 4, ++ ++ /* MSA ABI used by this object file. */ ++ Tag_GNU_MIPS_ABI_MSA = 8, ++}; ++ ++/* Object attribute values. */ ++enum ++{ ++ /* Values defined for Tag_GNU_MIPS_ABI_MSA. */ ++ ++ /* Not tagged or not using any ABIs affected by the differences. */ ++ Val_GNU_MIPS_ABI_MSA_ANY = 0, ++ ++ /* Using 128-bit MSA. */ ++ Val_GNU_MIPS_ABI_MSA_128 = 1, ++}; ++ ++/* Object attribute values. */ ++enum ++{ ++ /* This is reserved for backward-compatibility with an earlier ++ implementation of the MIPS NaN2008 functionality. */ ++ Val_GNU_MIPS_ABI_FP_NAN2008 = 8, ++}; ++ ++/* copy binutils-2.34/binutils/readelf.c display_mips_gnu_attribute */ ++bool ++mips_check_object_attribute (Ebl *ebl __attribute__ ((unused)), ++ const char *vendor, int tag, uint64_t value, ++ const char **tag_name, const char **value_name) ++{ ++ if (!strcmp (vendor, "gnu")) ++ switch (tag) ++ { ++ case Tag_GNU_MIPS_ABI_FP: ++ *tag_name = "Tag_GNU_MIPS_ABI_FP"; ++ switch (value) ++ { ++ case Val_GNU_MIPS_ABI_FP_ANY: ++ *value_name = "Hard or soft float"; ++ return true; ++ case Val_GNU_MIPS_ABI_FP_DOUBLE: ++ *value_name = "Hard float (double precision)"; ++ return true; ++ case Val_GNU_MIPS_ABI_FP_SINGLE: ++ *value_name = "Hard float (single precision)"; ++ return true; ++ case Val_GNU_MIPS_ABI_FP_SOFT: ++ *value_name = "Soft float"; ++ return true; ++ case Val_GNU_MIPS_ABI_FP_OLD_64: ++ *value_name = "Hard float (MIPS32r2 64-bit FPU 12 callee-saved)"; ++ return true; ++ case Val_GNU_MIPS_ABI_FP_XX: ++ *value_name = "Hard float (32-bit CPU, Any FPU)"; ++ return true; ++ case Val_GNU_MIPS_ABI_FP_64: ++ *value_name = "Hard float (32-bit CPU, 64-bit FPU)"; ++ return true; ++ case Val_GNU_MIPS_ABI_FP_64A: ++ *value_name = "Hard float compat (32-bit CPU, 64-bit FPU)"; ++ return true; ++ case Val_GNU_MIPS_ABI_FP_NAN2008: ++ *value_name = "NaN 2008 compatibility"; ++ return true; ++ default: ++ return true; ++ } ++ return true; ++ case Tag_GNU_MIPS_ABI_MSA: ++ *tag_name = "Tag_GNU_MIPS_ABI_MSA"; ++ switch (value) ++ { ++ case Val_GNU_MIPS_ABI_MSA_ANY: ++ *value_name = "Any MSA or not"; ++ return true; ++ case Val_GNU_MIPS_ABI_MSA_128: ++ *value_name = "128-bit MSA"; ++ return true; ++ default: ++ return true; ++ } ++ return true; ++ } ++ ++ return false; ++} +--- a/src/readelf.c ++++ b/src/readelf.c +@@ -2219,17 +2219,41 @@ handle_relocs_rel (Ebl *ebl, GElf_Ehdr * + (long int) GELF_R_SYM (rel->r_info)); + } + else if (GELF_ST_TYPE (sym->st_info) != STT_SECTION) +- printf (" %#0*" PRIx64 " %-20s %#0*" PRIx64 " %s\n", +- class == ELFCLASS32 ? 10 : 18, rel->r_offset, +- likely (ebl_reloc_type_check (ebl, +- GELF_R_TYPE (rel->r_info))) +- /* Avoid the leading R_ which isn't carrying any +- information. */ +- ? ebl_reloc_type_name (ebl, GELF_R_TYPE (rel->r_info), +- buf, sizeof (buf)) + 2 +- : _("<INVALID RELOC>"), +- class == ELFCLASS32 ? 10 : 18, sym->st_value, +- elf_strptr (ebl->elf, symshdr->sh_link, sym->st_name)); ++ { ++ unsigned long inf = rel->r_info; ++ printf (" %#0*" PRIx64 " %-20s %#0*" PRIx64 " %s\n", ++ class == ELFCLASS32 ? 10 : 18, rel->r_offset, ++ likely (ebl_reloc_type_check (ebl, ++ GELF_R_TYPE (rel->r_info))) ++ /* Avoid the leading R_ which isn't carrying any ++ information. */ ++ ? ebl_reloc_type_name (ebl, GELF_R_TYPE (rel->r_info), ++ buf, sizeof (buf)) + 2 ++ : _("<INVALID RELOC>"), ++ class == ELFCLASS32 ? 10 : 18, sym->st_value, ++ elf_strptr (ebl->elf, symshdr->sh_link, sym->st_name)); ++ ++ /* copy binutils-2.34/binutils/readelf.c dump_relocations+1753 */ ++ if(ebl->elf->class == ELFCLASS64 && ebl->elf->state.elf64.ehdr->e_machine == EM_MIPS) ++ { ++ unsigned int type2 = ELF64_MIPS_R_TYPE2 (inf); ++ unsigned int type3 = ELF64_MIPS_R_TYPE3 (inf); ++ const char * rtype2 = ebl_reloc_type_name (ebl, type2, buf, sizeof (buf)) + 2; ++ const char * rtype3 = ebl_reloc_type_name (ebl, type3, buf, sizeof (buf)) + 2; ++ printf(" Type2: "); ++ if (rtype2 == NULL) ++ printf (_("unrecognized: %lx"), (unsigned long) type2 & 0xffffffff); ++ else ++ printf ("%s", rtype2); ++ ++ printf ("\n Type3: "); ++ if (rtype3 == NULL) ++ printf (_("unrecognized: %lx"), (unsigned long) type3 & 0xffffffff); ++ else ++ printf ("%s", rtype3); ++ printf("\n"); ++ } ++ } + else + { + /* This is a relocation against a STT_SECTION symbol. */ +@@ -2253,16 +2277,40 @@ handle_relocs_rel (Ebl *ebl, GElf_Ehdr * + (long int) (sym->st_shndx == SHN_XINDEX + ? xndx : sym->st_shndx)); + else +- printf (" %#0*" PRIx64 " %-20s %#0*" PRIx64 " %s\n", +- class == ELFCLASS32 ? 10 : 18, rel->r_offset, +- ebl_reloc_type_check (ebl, GELF_R_TYPE (rel->r_info)) +- /* Avoid the leading R_ which isn't carrying any +- information. */ +- ? ebl_reloc_type_name (ebl, GELF_R_TYPE (rel->r_info), +- buf, sizeof (buf)) + 2 +- : _("<INVALID RELOC>"), +- class == ELFCLASS32 ? 10 : 18, sym->st_value, +- elf_strptr (ebl->elf, shstrndx, secshdr->sh_name)); ++ { ++ unsigned long inf = rel->r_info; ++ printf (" %#0*" PRIx64 " %-20s %#0*" PRIx64 " %s\n", ++ class == ELFCLASS32 ? 10 : 18, rel->r_offset, ++ ebl_reloc_type_check (ebl, GELF_R_TYPE (rel->r_info)) ++ /* Avoid the leading R_ which isn't carrying any ++ information. */ ++ ? ebl_reloc_type_name (ebl, GELF_R_TYPE (rel->r_info), ++ buf, sizeof (buf)) + 2 ++ : _("<INVALID RELOC>"), ++ class == ELFCLASS32 ? 10 : 18, sym->st_value, ++ elf_strptr (ebl->elf, shstrndx, secshdr->sh_name)); ++ ++ /* copy binutils-2.34/binutils/readelf.c dump_relocations+1753 */ ++ if(ebl->elf->class == ELFCLASS64 && ebl->elf->state.elf64.ehdr->e_machine == EM_MIPS) ++ { ++ unsigned int type2 = ELF64_MIPS_R_TYPE2 (inf); ++ unsigned int type3 = ELF64_MIPS_R_TYPE3 (inf); ++ const char * rtype2 = ebl_reloc_type_name (ebl, type2, buf, sizeof (buf)) + 2; ++ const char * rtype3 = ebl_reloc_type_name (ebl, type3, buf, sizeof (buf)) + 2; ++ printf(" Type2: "); ++ if (rtype2 == NULL) ++ printf (_("unrecognized: %lx"), (unsigned long) type2 & 0xffffffff); ++ else ++ printf ("%s", rtype2); ++ ++ printf ("\n Type3: "); ++ if (rtype3 == NULL) ++ printf (_("unrecognized: %lx"), (unsigned long) type3 & 0xffffffff); ++ else ++ printf ("%s", rtype3); ++ printf("\n"); ++ } ++ } + } + } + } +@@ -2410,19 +2458,43 @@ handle_relocs_rela (Ebl *ebl, GElf_Ehdr + (long int) GELF_R_SYM (rel->r_info)); + } + else if (GELF_ST_TYPE (sym->st_info) != STT_SECTION) +- printf ("\ ++ { ++ unsigned long inf = rel->r_info; ++ printf ("\ + %#0*" PRIx64 " %-15s %#0*" PRIx64 " %+6" PRId64 " %s\n", +- class == ELFCLASS32 ? 10 : 18, rel->r_offset, +- likely (ebl_reloc_type_check (ebl, +- GELF_R_TYPE (rel->r_info))) +- /* Avoid the leading R_ which isn't carrying any +- information. */ +- ? ebl_reloc_type_name (ebl, GELF_R_TYPE (rel->r_info), +- buf, sizeof (buf)) + 2 +- : _("<INVALID RELOC>"), +- class == ELFCLASS32 ? 10 : 18, sym->st_value, +- rel->r_addend, +- elf_strptr (ebl->elf, symshdr->sh_link, sym->st_name)); ++ class == ELFCLASS32 ? 10 : 18, rel->r_offset, ++ likely (ebl_reloc_type_check (ebl, ++ GELF_R_TYPE (rel->r_info))) ++ /* Avoid the leading R_ which isn't carrying any ++ information. */ ++ ? ebl_reloc_type_name (ebl, GELF_R_TYPE (rel->r_info), ++ buf, sizeof (buf)) + 2 ++ : _("<INVALID RELOC>"), ++ class == ELFCLASS32 ? 10 : 18, sym->st_value, ++ rel->r_addend, ++ elf_strptr (ebl->elf, symshdr->sh_link, sym->st_name)); ++ ++ /* copy binutils-2.34/binutils/readelf.c dump_relocations+1753 */ ++ if(ebl->elf->class == ELFCLASS64 && ebl->elf->state.elf64.ehdr->e_machine == EM_MIPS) ++ { ++ unsigned int type2 = ELF64_MIPS_R_TYPE2 (inf); ++ unsigned int type3 = ELF64_MIPS_R_TYPE3 (inf); ++ const char * rtype2 = ebl_reloc_type_name (ebl, type2, buf, sizeof (buf)) + 2; ++ const char * rtype3 = ebl_reloc_type_name (ebl, type3, buf, sizeof (buf)) + 2; ++ printf(" Type2: "); ++ if (rtype2 == NULL) ++ printf (_("unrecognized: %lx"), (unsigned long) type2 & 0xffffffff); ++ else ++ printf ("%s", rtype2); ++ ++ printf ("\n Type3: "); ++ if (rtype3 == NULL) ++ printf (_("unrecognized: %lx"), (unsigned long) type3 & 0xffffffff); ++ else ++ printf ("%s", rtype3); ++ printf("\n"); ++ } ++ } + else + { + /* This is a relocation against a STT_SECTION symbol. */ +@@ -2446,18 +2518,42 @@ handle_relocs_rela (Ebl *ebl, GElf_Ehdr + (long int) (sym->st_shndx == SHN_XINDEX + ? xndx : sym->st_shndx)); + else +- printf ("\ ++ { ++ unsigned long inf = rel->r_info; ++ printf ("\ + %#0*" PRIx64 " %-15s %#0*" PRIx64 " %+6" PRId64 " %s\n", +- class == ELFCLASS32 ? 10 : 18, rel->r_offset, +- ebl_reloc_type_check (ebl, GELF_R_TYPE (rel->r_info)) +- /* Avoid the leading R_ which isn't carrying any +- information. */ +- ? ebl_reloc_type_name (ebl, GELF_R_TYPE (rel->r_info), +- buf, sizeof (buf)) + 2 +- : _("<INVALID RELOC>"), +- class == ELFCLASS32 ? 10 : 18, sym->st_value, +- rel->r_addend, +- elf_strptr (ebl->elf, shstrndx, secshdr->sh_name)); ++ class == ELFCLASS32 ? 10 : 18, rel->r_offset, ++ ebl_reloc_type_check (ebl, GELF_R_TYPE (rel->r_info)) ++ /* Avoid the leading R_ which isn't carrying any ++ information. */ ++ ? ebl_reloc_type_name (ebl, GELF_R_TYPE (rel->r_info), ++ buf, sizeof (buf)) + 2 ++ : _("<INVALID RELOC>"), ++ class == ELFCLASS32 ? 10 : 18, sym->st_value, ++ rel->r_addend, ++ elf_strptr (ebl->elf, shstrndx, secshdr->sh_name)); ++ ++ /* copy binutils-2.34/binutils/readelf.c dump_relocations+1753 */ ++ if(ebl->elf->class == ELFCLASS64 && ebl->elf->state.elf64.ehdr->e_machine == EM_MIPS) ++ { ++ unsigned int type2 = ELF64_MIPS_R_TYPE2 (inf); ++ unsigned int type3 = ELF64_MIPS_R_TYPE3 (inf); ++ const char * rtype2 = ebl_reloc_type_name (ebl, type2, buf, sizeof (buf)) + 2; ++ const char * rtype3 = ebl_reloc_type_name (ebl, type3, buf, sizeof (buf)) + 2; ++ printf(" Type2: "); ++ if (rtype2 == NULL) ++ printf (_("unrecognized: %-7lx"), (unsigned long) type2 & 0xffffffff); ++ else ++ printf ("%s", rtype2); ++ ++ printf ("\n Type3: "); ++ if (rtype3 == NULL) ++ printf (_("unrecognized: %lx"), (unsigned long) type3 & 0xffffffff); ++ else ++ printf ("%s", rtype3); ++ printf("\n"); ++ } ++ } + } + } + } +@@ -12043,7 +12139,7 @@ print_debug (Dwfl_Module *dwflmod, Ebl * + GElf_Shdr shdr_mem; + GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); + +- if (shdr != NULL && shdr->sh_type == SHT_PROGBITS) ++ if (shdr != NULL && is_debug_section_type(shdr->sh_type)) + { + const char *name = elf_strptr (ebl->elf, shstrndx, + shdr->sh_name); +@@ -12073,7 +12169,7 @@ print_debug (Dwfl_Module *dwflmod, Ebl * + GElf_Shdr shdr_mem; + GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); + +- if (shdr != NULL && shdr->sh_type == SHT_PROGBITS) ++ if (shdr != NULL && is_debug_section_type(shdr->sh_type)) + { + static const struct + { +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -214,7 +214,7 @@ TESTS = run-arextract.sh run-arsymtest.s + run-nvidia-extended-linemap-libdw.sh run-nvidia-extended-linemap-readelf.sh \ + run-readelf-dw-form-indirect.sh run-strip-largealign.sh \ + run-readelf-Dd.sh run-dwfl-core-noncontig.sh run-cu-dwp-section-info.sh \ +- run-declfiles.sh ++ run-declfiles.sh run-readelf-reloc.sh + + if !BIARCH + export ELFUTILS_DISABLE_BIARCH = 1 +@@ -646,7 +646,8 @@ EXTRA_DIST = run-arextract.sh run-arsymt + testfile-dwp-5-cu-index-overflow.dwp.bz2 \ + testfile-dwp-4-cu-index-overflow.bz2 \ + testfile-dwp-4-cu-index-overflow.dwp.bz2 \ +- testfile-dwp-cu-index-overflow.source ++ testfile-dwp-cu-index-overflow.source \ ++ run-readelf-reloc.sh + + + if USE_VALGRIND +--- /dev/null ++++ b/tests/run-readelf-reloc.sh +@@ -0,0 +1,42 @@ ++#! /bin/bash ++# Copyright (C) 2024 CIP United Inc. ++# This file is part of elfutils. ++# ++# This file 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 of the License, or ++# (at your option) any later version. ++# ++# elfutils 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. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see <http://www.gnu.org/licenses/>. ++ ++. $srcdir/test-subr.sh ++ ++tempfiles test-readelf-h.txt test-readelf-reloc.txt ++testrun ${abs_top_builddir}/src/readelf -h ${abs_top_builddir}/src/strip.o > test-readelf-h.txt ++machine=`cat test-readelf-h.txt | grep Machine` ++class=`cat test-readelf-h.txt | grep Class` ++endian=`cat test-readelf-h.txt | grep Data` ++if [[ "$machine" == *MIPS* && "$class" == *ELF64 && "$endian" == *little* ]]; then ++testrun ${abs_top_builddir}/src/readelf -r ${abs_top_builddir}/src/strip.o | head -n 12 | tail -n 10 > test-readelf-reloc.txt ++ ++testrun_compare cat test-readelf-reloc.txt << EOF ++ Offset Type Value Addend Name ++ 0x0000000000000008 MIPS_GPREL16 000000000000000000 +0 .text ++ Type2: MIPS_SUB ++ Type3: MIPS_HI16 ++ 0x0000000000000010 MIPS_GPREL16 000000000000000000 +0 .text ++ Type2: MIPS_SUB ++ Type3: MIPS_LO16 ++ 0x0000000000000014 MIPS_CALL16 000000000000000000 +0 gelf_getehdr ++ Type2: MIPS_NONE ++ Type3: MIPS_NONE ++EOF ++fi ++ ++exit 0 +--- a/src/elflint.c ++++ b/src/elflint.c +@@ -936,7 +936,9 @@ section [%2d] '%s': symbol %zu (%s): non + } + + if (GELF_ST_TYPE (sym->st_info) == STT_SECTION +- && GELF_ST_BIND (sym->st_info) != STB_LOCAL) ++ && GELF_ST_BIND (sym->st_info) != STB_LOCAL ++ && ehdr->e_machine != EM_MIPS ++ && strcmp (name, "_DYNAMIC_LINKING") != 0) + ERROR (_("\ + section [%2d] '%s': symbol %zu (%s): non-local section symbol\n"), + idx, section_name (ebl, idx), cnt, name); +@@ -3828,6 +3830,10 @@ cannot get section header for section [% + && ebl_bss_plt_p (ebl)) + good_type = SHT_NOBITS; + ++ if (ehdr->e_machine == EM_MIPS ++ && (strstr(special_sections[s].name, ".debug") != NULL)) ++ good_type = SHT_MIPS_DWARF; ++ + /* In a debuginfo file, any normal section can be SHT_NOBITS. + This is only invalid for DWARF sections and .shstrtab. */ + if (shdr->sh_type != good_type +@@ -3988,12 +3994,21 @@ section [%2zu] '%s': size not multiple o + ERROR (_("section [%2zu] '%s'" + " contains invalid processor-specific flag(s)" + " %#" PRIx64 "\n"), +- cnt, section_name (ebl, cnt), sh_flags & SHF_MASKPROC); ++ cnt, section_name (ebl, cnt), sh_flags & SHF_MASKPROC); + sh_flags &= ~(GElf_Xword) SHF_MASKPROC; + } + if (sh_flags & SHF_MASKOS) +- if (gnuld) +- sh_flags &= ~(GElf_Xword) SHF_GNU_RETAIN; ++ { ++ if (gnuld) ++ sh_flags &= ~(GElf_Xword) SHF_GNU_RETAIN; ++ if (!ebl_machine_section_flag_check (ebl, ++ sh_flags & SHF_MASKOS)) ++ ERROR (_("section [%2zu] '%s'" ++ " contains invalid os-specific flag(s)" ++ " %#" PRIx64 "\n"), ++ cnt, section_name (ebl, cnt), sh_flags & SHF_MASKOS); ++ sh_flags &= ~(GElf_Xword) SHF_MASKOS; ++ } + if (sh_flags != 0) + ERROR (_("section [%2zu] '%s' contains unknown flag(s)" + " %#" PRIx64 "\n"), +@@ -4059,6 +4074,7 @@ section [%2zu] '%s': merge flag set but + switch (shdr->sh_type) + { + case SHT_PROGBITS: ++ case SHT_MIPS_DWARF: + break; + + case SHT_NOBITS: +@@ -4716,7 +4732,7 @@ program header offset in ELF header and + if (shdr != NULL + && ((is_debuginfo && shdr->sh_type == SHT_NOBITS) + || (! is_debuginfo +- && (shdr->sh_type == SHT_PROGBITS ++ && (is_debug_section_type(shdr->sh_type) + || shdr->sh_type == SHT_X86_64_UNWIND))) + && elf_strptr (ebl->elf, shstrndx, shdr->sh_name) != NULL + && ! strcmp (".eh_frame_hdr", +--- /dev/null ++++ b/backends/mips64_corenote.c +@@ -0,0 +1,2 @@ ++#define BITS 64 ++#include "mips_corenote.c" +--- a/libebl/eblcorenotetypename.c ++++ b/libebl/eblcorenotetypename.c +@@ -94,6 +94,8 @@ ebl_core_note_type_name (Ebl *ebl, uint3 + KNOWNSTYPE (ARM_SYSTEM_CALL); + KNOWNSTYPE (SIGINFO); + KNOWNSTYPE (FILE); ++ KNOWNSTYPE (MIPS_FP_MODE); ++ KNOWNSTYPE (MIPS_MSA); + #undef KNOWNSTYPE + + default: +--- a/tests/run-allregs.sh ++++ b/tests/run-allregs.sh +@@ -2904,4 +2904,83 @@ FPU registers: + 62: ft10 (ft10), float 64 bits + 63: ft11 (ft11), float 64 bits + EOF ++ ++# See run-readelf-mixed-corenote.sh for instructions to regenerate ++# this core file. ++regs_test testfile-mips64-core <<\EOF ++integer registers: ++ 0: $0 (0), signed 32 bits ++ 1: $1 (1), signed 32 bits ++ 2: $2 (2), signed 32 bits ++ 3: $3 (3), signed 32 bits ++ 4: $4 (4), signed 32 bits ++ 5: $5 (5), signed 32 bits ++ 6: $6 (6), signed 32 bits ++ 7: $7 (7), signed 32 bits ++ 8: $8 (8), signed 32 bits ++ 9: $9 (9), signed 32 bits ++ 10: $10 (10), signed 32 bits ++ 11: $11 (11), signed 32 bits ++ 12: $12 (12), signed 32 bits ++ 13: $13 (13), signed 32 bits ++ 14: $14 (14), signed 32 bits ++ 15: $15 (15), signed 32 bits ++ 16: $16 (16), signed 32 bits ++ 17: $17 (17), signed 32 bits ++ 18: $18 (18), signed 32 bits ++ 19: $19 (19), signed 32 bits ++ 20: $20 (20), signed 32 bits ++ 21: $21 (21), signed 32 bits ++ 22: $22 (22), signed 32 bits ++ 23: $23 (23), signed 32 bits ++ 24: $24 (24), signed 32 bits ++ 25: $25 (25), signed 32 bits ++ 26: $26 (26), signed 32 bits ++ 27: $27 (27), signed 32 bits ++ 28: $28 (28), address 32 bits ++ 29: $29 (29), address 32 bits ++ 30: $30 (30), signed 32 bits ++ 31: $31 (31), address 32 bits ++ 32: $lo (lo), signed 32 bits ++ 33: $hi (hi), signed 32 bits ++ 34: $pc (pc), signed 32 bits ++ 35: $bad (bad), address 32 bits ++ 36: $sr (sr), signed 32 bits ++ 37: $cause (cause), address 32 bits ++FPU registers: ++ 38: $f0 (f0), float 64 bits ++ 39: $f1 (f1), float 64 bits ++ 40: $f2 (f2), float 64 bits ++ 41: $f3 (f3), float 64 bits ++ 42: $f4 (f4), float 64 bits ++ 43: $f5 (f5), float 64 bits ++ 44: $f6 (f6), float 64 bits ++ 45: $f7 (f7), float 64 bits ++ 46: $f8 (f8), float 64 bits ++ 47: $f9 (f9), float 64 bits ++ 48: $f10 (f10), float 64 bits ++ 49: $f11 (f11), float 64 bits ++ 50: $f12 (f12), float 64 bits ++ 51: $f13 (f13), float 64 bits ++ 52: $f14 (f14), float 64 bits ++ 53: $f15 (f15), float 64 bits ++ 54: $f16 (f16), float 64 bits ++ 55: $f17 (f17), float 64 bits ++ 56: $f18 (f18), float 64 bits ++ 57: $f19 (f19), float 64 bits ++ 58: $f20 (f20), float 64 bits ++ 59: $f21 (f21), float 64 bits ++ 60: $f22 (f22), float 64 bits ++ 61: $f23 (f23), float 64 bits ++ 62: $f24 (f24), float 64 bits ++ 63: $f25 (f25), float 64 bits ++ 64: $f26 (f26), float 64 bits ++ 65: $f27 (f27), float 64 bits ++ 66: $f28 (f28), float 64 bits ++ 67: $f29 (f29), float 64 bits ++ 68: $f30 (f30), float 64 bits ++ 69: $f31 (f31), float 64 bits ++ 70: $fsr (fsr), float 64 bits ++ 71: $fir (fir), float 64 bits ++EOF + exit 0 +--- a/tests/run-readelf-mixed-corenote.sh ++++ b/tests/run-readelf-mixed-corenote.sh +@@ -716,4 +716,101 @@ Note segment of 1408 bytes at offset 0x3 + 2000155000-2000157000 00122000 8192 /lib64/libc-2.27.so + EOF + ++# To reproduce this core dump, do this on a mips machine: ++# $ gcc -x c <(echo 'int main () { return *(int *)0x12345678; }') ++# $ ./a.out ++testfiles testfile-mips64-core ++testrun_compare ${abs_top_builddir}/src/readelf -n testfile-mips64-core <<\EOF ++ ++Note segment of 2572 bytes at offset 0x3c0: ++ Owner Data size Type ++ CORE 480 PRSTATUS ++ info.si_signo: 11, info.si_code: 0, info.si_errno: 0, cursig: 11 ++ sigpend: <> ++ sighold: <> ++ pid: 1660204, ppid: 1457483, pgrp: 1660204, sid: 1457483 ++ utime: 0.000000, stime: 0.012000, cutime: 0.000000, cstime: 0.000000 ++ pc: 0x000000aaacce0a64, fpvalid: 1 ++ bad: 0x12345678 sr: 0 cause: 0x0400ccf3 ++ f0: 0x1000000800000000 f1: 0x0000000000000000 f2: 0x0000000000000000 ++ f3: 0x0000000000000000 f4: 0x0000000000000000 f5: 0x0000000000000000 ++ f6: 0x0000000000000000 ++ 0: 0 1: 0 2: 1 ++ 3: 0 4: 305419896 5: 0 ++ 6: -73593800 7: 255 8: 1 ++ 9: 0 10: -73593464 11: 255 ++ 12: -73593448 13: 255 14: 0 ++ 15: 0 16: -244869184 17: 255 ++ 18: -244886336 19: 255 20: -73593472 ++ 21: 255 22: -1 23: -1 ++ 24: 3 25: 0 26: 3167716 ++ 27: 0 28: 0x00000024 29: 0x00000000 ++ 30: 49495 31: 0x00000000 lo: -73593464 ++ hi: 255 bad: 0x12345678 sr: 0 ++ cause: 0x0400ccf3 f0: 0x1000000800000000 ++ f1: 0x0000000000000000 f2: 0x0000000000000000 ++ f3: 0x0000000000000000 f4: 0x0000000000000000 ++ f5: 0x0000000000000000 f6: 0x0000000000000000 ++ CORE 136 PRPSINFO ++ state: 0, sname: R, zomb: 0, nice: 0, flag: 0x0000000000402600 ++ uid: 1014, gid: 100, pid: 1660204, ppid: 1457483, pgrp: 1660204 ++ sid: 1457483 ++ fname: a.out, psargs: ./a.out ++ CORE 128 SIGINFO ++ si_signo: 11, si_errno: 1, si_code: 0 ++ sender PID: 305419896, sender UID: 0 ++ CORE 320 AUXV ++ SYSINFO_EHDR: 0xffff14c000 ++ HWCAP: 0x7806 ++ PAGESZ: 16384 ++ CLKTCK: 100 ++ PHDR: 0xaaacce0040 ++ PHENT: 56 ++ PHNUM: 9 ++ BASE: 0xfff1694000 ++ FLAGS: 0 ++ ENTRY: 0xaaacce08d0 ++ UID: 1014 ++ EUID: 1014 ++ GID: 100 ++ EGID: 100 ++ SECURE: 0 ++ RANDOM: 0xfffb9d0f9c ++ EXECFN: 0xfffb9d3ff0 ++ PLATFORM: 0xfffb9d0fb5 ++ BASE_PLATFORM: 0xfffb9d0fac ++ NULL ++ CORE 549 FILE ++ 9 files: ++ aaacce0000-aaacce4000 00000000 16384 /tmp/a.out ++ aaaccf0000-aaaccf4000 00000000 16384 /tmp/a.out ++ fff1470000-fff165c000 00000000 2015232 /usr/lib/mips64el-linux-gnuabi64/libc.so.6 ++ fff165c000-fff1668000 001ec000 49152 /usr/lib/mips64el-linux-gnuabi64/libc.so.6 ++ fff1668000-fff1670000 001e8000 32768 /usr/lib/mips64el-linux-gnuabi64/libc.so.6 ++ fff1670000-fff1678000 001f0000 32768 /usr/lib/mips64el-linux-gnuabi64/libc.so.6 ++ fff1694000-fff16c4000 00000000 196608 /usr/lib/mips64el-linux-gnuabi64/ld.so.1 ++ fff16d0000-fff16d4000 0002c000 16384 /usr/lib/mips64el-linux-gnuabi64/ld.so.1 ++ fff16d4000-fff16d8000 00030000 16384 /usr/lib/mips64el-linux-gnuabi64/ld.so.1 ++ CORE 264 FPREGSET ++ fcs: 0x000c0000, fir: 0x00f70501 ++ f0: 0xffffffffffffffff f1: 0xffffffffffffffff ++ f2: 0xffffffffffffffff f3: 0xffffffffffffffff ++ f4: 0xffffffffffffffff f5: 0xffffffffffffffff ++ f6: 0xffffffffffffffff f7: 0xffffffffffffffff ++ f8: 0xffffffffffffffff f9: 0xffffffffffffffff ++ f10: 0xffffffffffffffff f11: 0xffffffffffffffff ++ f12: 0xffffffffffffffff f13: 0xffffffffffffffff ++ f14: 0xffffffffffffffff f15: 0xffffffffffffffff ++ f16: 0xffffffffffffffff f17: 0xffffffffffffffff ++ f18: 0xffffffffffffffff f19: 0xffffffffffffffff ++ f20: 0xffffffffffffffff f21: 0xffffffffffffffff ++ f22: 0xffffffffffffffff f23: 0xffffffffffffffff ++ f24: 0xffffffffffffffff f25: 0xffffffffffffffff ++ f26: 0xffffffffffffffff f27: 0xffffffffffffffff ++ f28: 0xffffffffffffffff f29: 0xffffffffffffffff ++ f30: 0xffffffffffffffff f31: 0xffffffffffffffff ++ LINUX 4 MIPS_FP_MODE ++ LINUX 528 MIPS_MSA ++EOF ++ + exit 0 diff --git a/tools/elfutils/patches/100-portability.patch b/tools/elfutils/patches/100-portability.patch index 0d650549ee..fb6f0299ac 100644 --- a/tools/elfutils/patches/100-portability.patch +++ b/tools/elfutils/patches/100-portability.patch @@ -2,7 +2,7 @@ +++ b/configure.ac @@ -20,6 +20,7 @@ dnl You should have received a copy of dnl along with this program. If not, see <http://www.gnu.org/licenses/>. - AC_INIT([elfutils],[0.189],[https://sourceware.org/bugzilla],[elfutils],[http://elfutils.org/]) + AC_INIT([elfutils],[0.191],[https://sourceware.org/bugzilla],[elfutils],[http://elfutils.org/]) +AC_CONFIG_MACRO_DIRS([m4]) dnl Workaround for older autoconf < 2.64 @@ -15,7 +15,7 @@ -AC_CONFIG_FILES([config/Makefile]) +AC_CONFIG_FILES([config/Makefile libgnu/Makefile]) - AC_COPYRIGHT([Copyright (C) 1996-2023 The elfutils developers.]) + AC_COPYRIGHT([Copyright (C) 1996-2024 The elfutils developers.]) -AC_PREREQ(2.63) dnl Minimum Autoconf version required. +AC_PREREQ(2.64) dnl Minimum Autoconf version required. @@ -89,23 +89,6 @@ dnl The directories with content. dnl Documentation. ---- a/Makefile.am -+++ b/Makefile.am -@@ -26,11 +26,11 @@ AM_MAKEFLAGS = --no-print-directory - - pkginclude_HEADERS = version.h - --SUBDIRS = config lib libelf libcpu backends libebl libdwelf libdwfl libdw \ -- libasm debuginfod src po doc tests -+SUBDIRS = libgnu config lib libelf libcpu backends libebl libdwelf libdwfl libdw - - EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \ -- COPYING COPYING-GPLV2 COPYING-LGPLV3 -+ COPYING COPYING-GPLV2 COPYING-LGPLV3 \ -+ m4/gnulib-cache.m4 - - # Make sure the test install uses lib64 when $LIB will yield lib64. - # Make sure the test build uses the same compiler, which on e.g. ppc64 --- a/libelf/elf_update.c +++ b/libelf/elf_update.c @@ -37,6 +37,33 @@ @@ -144,8 +127,8 @@ write_file (Elf *elf, int64_t size, int change_bo, size_t shnum) --- a/lib/eu-config.h +++ b/lib/eu-config.h -@@ -52,14 +52,18 @@ - # define rwlock_unlock(lock) ((void) (lock)) +@@ -59,14 +59,18 @@ + # define once(once_control, init_routine) init_routine() #endif /* USE_LOCKS */ -#include <libintl.h> @@ -164,7 +147,7 @@ #ifdef __i386__ # define internal_function __attribute__ ((regparm (3), stdcall)) -@@ -70,12 +74,7 @@ +@@ -77,12 +81,7 @@ #define internal_strong_alias(name, aliasname) \ extern __typeof (name) aliasname __attribute__ ((alias (#name))) internal_function; @@ -177,7 +160,7 @@ #ifdef HAVE_GCC_STRUCT #define attribute_packed \ -@@ -159,7 +158,7 @@ asm (".section predict_data, \"aw\"; .pr +@@ -166,7 +165,7 @@ asm (".section predict_data, \"aw\"; .pr #endif /* Avoid PLT entries. */ @@ -215,7 +198,7 @@ pkginclude_HEADERS = elf-knowledge.h -libelf_a_SOURCES = elf_version.c elf_hash.c elf_error.c elf_fill.c \ -+libelf_la_LIBADD = ../libgnu/libgnu.la ../lib/libeu.la -lz $(zstd_LIBS) -lpthread ++libelf_la_LIBADD = ../lib/libeu.la -lz $(zstd_LIBS) -lpthread +libelf_la_SOURCES = elf_version.c elf_hash.c elf_error.c \ elf_begin.c elf_next.c elf_rand.c elf_end.c elf_kind.c \ gelf_getclass.c elf_getbase.c elf_getident.c \ @@ -361,28 +344,13 @@ +{ + return ppc_check_object_attribute(ebl, vendor, tag, value, tag_name, value_name); +} ---- a/lib/libeu.h -+++ b/lib/libeu.h -@@ -45,4 +45,11 @@ extern char *xasprintf(const char *fmt, - extern uint32_t crc32 (uint32_t crc, unsigned char *buf, size_t len); - extern int crc32_file (int fd, uint32_t *resp); - -+#ifdef __APPLE__ -+static inline void tdestroy(void *root __attribute__ ((unused)), -+ void (*freekey)(void *) __attribute__ ((unused))) -+{ -+} -+#endif -+ - #endif --- a/libdwfl/libdwflP.h +++ b/libdwfl/libdwflP.h -@@ -31,6 +31,8 @@ +@@ -31,6 +31,7 @@ #include <libdwfl.h> #include <libebl.h> +#include <libeu.h> -+#include <libgen.h> #include <assert.h> #include <dirent.h> #include <errno.h> @@ -397,17 +365,18 @@ +#endif --- a/libdw/libdwP.h +++ b/libdw/libdwP.h -@@ -32,8 +32,10 @@ +@@ -32,10 +32,10 @@ #include <stdbool.h> #include <pthread.h> +#include <libeu.h> #include <libdw.h> #include <dwarf.h> -+#include <libgen.h> - +- /* Known location expressions already decoded. */ + struct loc_s + { --- a/libdw/Makefile.am +++ b/libdw/Makefile.am @@ -34,14 +34,12 @@ endif @@ -596,10 +565,10 @@ +noinst_LTLIBRARIES = libebl_backends.la modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \ - m68k bpf riscv csky loongarch arc -@@ -100,17 +100,13 @@ loongarch_SRCS = loongarch_init.c loonga - - arc_SRCS = arc_init.c arc_symbol.c + m68k bpf riscv csky loongarch arc mips +@@ -106,17 +106,13 @@ mips_SRCS = mips_init.c mips_symbol.c mi + mips_cfi.c mips_unwind.c mips_regs.c mips_retval.c \ + mips_corenote.c mips64_corenote.c -libebl_backends_a_SOURCES = $(i386_SRCS) $(sh_SRCS) $(x86_64_SRCS) \ +libebl_backends_la_SOURCES = $(i386_SRCS) $(sh_SRCS) $(x86_64_SRCS) \ @@ -607,7 +576,7 @@ $(aarch64_SRCS) $(sparc_SRCS) $(ppc_SRCS) \ $(ppc64_SRCS) $(s390_SRCS) \ $(m68k_SRCS) $(bpf_SRCS) $(riscv_SRCS) $(csky_SRCS) \ - $(loongarch_SRCS) $(arc_SRCS) + $(loongarch_SRCS) $(arc_SRCS) $(mips_SRCS) -libebl_backends_pic_a_SOURCES = -am_libebl_backends_pic_a_OBJECTS = $(libebl_backends_a_SOURCES:.c=.os) @@ -779,7 +748,7 @@ +++ b/src/Makefile.am @@ -29,9 +29,9 @@ bin_PROGRAMS = readelf nm size strip elf elfcmp objdump ranlib strings ar unstrip stack elfcompress \ - elfclassify + elfclassify srcfiles -noinst_LIBRARIES = libar.a +noinst_LTLIBRARIES = libar.la @@ -789,30 +758,41 @@ EXTRA_DIST = arlib.h debugpred.h -@@ -39,17 +39,11 @@ bin_SCRIPTS = make-debug-archive +@@ -39,27 +39,16 @@ bin_SCRIPTS = make-debug-archive EXTRA_DIST += make-debug-archive.in CLEANFILES += make-debug-archive -if BUILD_STATIC -libasm = ../libasm/libasm.a -libdw = ../libdw/libdw.a -lz $(zip_LIBS) $(libelf) -ldl -lpthread --libelf = ../libelf/libelf.a -lz +-libelf = ../libelf/libelf.a -lz $(zstd_LIBS) ++libasm = ../libasm/libasm.la ++libdw = ../libdw/libdw.la -lz $(zip_LIBS) $(libelf) -ldl -lpthread ++libelf = ../libelf/libelf.la -lz $(zstd_LIBS) + if LIBDEBUGINFOD +-libdebuginfod = ../debuginfod/libdebuginfod.a -lpthread $(libcurl_LIBS) ++libdebuginfod = ../debuginfod/libdebuginfod.la -lpthread $(libcurl_LIBS) + else + libdebuginfod = + endif -else -libasm = ../libasm/libasm.so -libdw = ../libdw/libdw.so -libelf = ../libelf/libelf.so +-if LIBDEBUGINFOD +-libdebuginfod = ../debuginfod/libdebuginfod.so +-else +-libdebuginfod = +-endif -endif -libebl = ../libebl/libebl.a ../backends/libebl_backends.a ../libcpu/libcpu.a -libeu = ../lib/libeu.a -+libasm = ../libasm/libasm.la -+libdw = ../libdw/libdw.la -lz $(zip_LIBS) $(libelf) -ldl -lpthread -+libelf = ../libelf/libelf.la +libebl = ../libebl/libebl.la ../backends/libebl_backends.la ../libcpu/libcpu.la +libeu = ../lib/libeu.la if DEMANGLE demanglelib = -lstdc++ -@@ -77,9 +71,9 @@ findtextrel_LDADD = $(libdw) $(libelf) $ +@@ -87,9 +76,9 @@ findtextrel_LDADD = $(libdw) $(libelf) $ addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib) elfcmp_LDADD = $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD) objdump_LDADD = $(libasm) $(libebl) $(libdw) $(libelf) $(libeu) $(argp_LDADD) @@ -826,13 +806,13 @@ elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) --- a/tests/Makefile.am +++ b/tests/Makefile.am -@@ -662,17 +662,11 @@ installcheck-local: +@@ -690,17 +690,11 @@ installcheck-local: TESTS_ENVIRONMENT="$(installed_TESTS_ENVIRONMENT)" \ LOG_COMPILER="$(installed_LOG_COMPILER)" check-TESTS -if BUILD_STATIC -libdw = ../libdw/libdw.a -lz $(zip_LIBS) $(libelf) $(libebl) -ldl -lpthread --libelf = ../libelf/libelf.a -lz +-libelf = ../libelf/libelf.a -lz $(zstd_LIBS) -libasm = ../libasm/libasm.a -else -libdw = ../libdw/libdw.so @@ -908,3 +888,56 @@ Cflags: -I${includedir} Requires.private: zlib @LIBZSTD@ +--- a/lib/next_prime.c ++++ b/lib/next_prime.c +@@ -27,6 +27,7 @@ + the GNU Lesser General Public License along with this program. If + not, see <http://www.gnu.org/licenses/>. */ + ++#include <config.h> + #include <stddef.h> + + +--- a/libebl/eblopenbackend.c ++++ b/libebl/eblopenbackend.c +@@ -200,8 +200,6 @@ static bool default_object_note (const c + uint32_t descsz, const char *desc); + static bool default_debugscn_p (const char *name); + static bool default_copy_reloc_p (int reloc); +-static bool default_none_reloc_p (int reloc); +-static bool default_relative_reloc_p (int reloc); + static bool default_check_special_symbol (Elf *elf, + const GElf_Sym *sym, + const char *name, +@@ -253,8 +251,8 @@ fill_defaults (Ebl *result) + result->object_note = default_object_note; + result->debugscn_p = default_debugscn_p; + result->copy_reloc_p = default_copy_reloc_p; +- result->none_reloc_p = default_none_reloc_p; +- result->relative_reloc_p = default_relative_reloc_p; ++ result->none_reloc_p = default_copy_reloc_p; ++ result->relative_reloc_p = default_copy_reloc_p; + result->check_special_symbol = default_check_special_symbol; + result->data_marker_symbol = default_data_marker_symbol; + result->check_st_other_bits = default_check_st_other_bits; +@@ -636,8 +634,6 @@ default_copy_reloc_p (int reloc __attrib + { + return false; + } +-strong_alias (default_copy_reloc_p, default_none_reloc_p) +-strong_alias (default_copy_reloc_p, default_relative_reloc_p) + + static bool + default_check_special_symbol (Elf *elf __attribute__ ((unused)), +--- a/src/srcfiles.cxx ++++ b/src/srcfiles.cxx +@@ -78,7 +78,9 @@ ARGP_PROGRAM_VERSION_HOOK_DEF = print_ve + /* Bug report address. */ + ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT; + ++#ifdef HAVE_LIBARCHIVE + constexpr size_t BUFFER_SIZE = 8192; ++#endif + + /* Definitions of arguments for argp functions. */ + static const struct argp_option options[] = diff --git a/tools/expat/Makefile b/tools/expat/Makefile index 4cd9ef11b2..8c15f98a22 100644 --- a/tools/expat/Makefile +++ b/tools/expat/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=expat -PKG_CPE_ID:=cpe:/a:libexpat:expat +PKG_CPE_ID:=cpe:/a:libexpat:libexpat PKG_VERSION:=2.6.2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz diff --git a/tools/findutils/Makefile b/tools/findutils/Makefile index fd0cde2145..6587c759f8 100644 --- a/tools/findutils/Makefile +++ b/tools/findutils/Makefile @@ -8,11 +8,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=findutils PKG_CPE_ID:=cpe:/a:gnu:findutils -PKG_VERSION:=4.9.0 +PKG_VERSION:=4.10.0 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@GNU/$(PKG_NAME) -PKG_HASH:=a2bfb8c09d436770edc59f50fa483e785b161a3b7b9d547573cb08065fd462fe +PKG_HASH:=1387e0b67ff247d2abde998f90dfbf70c1491391a59ddfecb8ae698789f0a4f5 PKG_PROGRAMS:=find locate updatedb xargs diff --git a/tools/findutils/patches/010-endpwent.patch b/tools/findutils/patches/010-endpwent.patch deleted file mode 100644 index dc346f3f76..0000000000 --- a/tools/findutils/patches/010-endpwent.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/find/parser.c -+++ b/find/parser.c -@@ -67,12 +67,12 @@ - #include "findutils-version.h" - #include "system.h" - -- --#ifndef HAVE_ENDGRENT --# define endgrent () -+#if ! HAVE_ENDGRENT -+# define endgrent() ((void) 0) - #endif --#ifndef HAVE_ENDPWENT --# define endpwent () -+ -+#if ! HAVE_ENDPWENT -+# define endpwent() ((void) 0) - #endif - - static bool parse_accesscheck (const struct parser_table*, char *argv[], int *arg_ptr); diff --git a/tools/flex/Makefile b/tools/flex/Makefile index 86ba5a4415..177136b78c 100644 --- a/tools/flex/Makefile +++ b/tools/flex/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=flex -PKG_CPE_ID:=cpe:/a:flex_project:flex +PKG_CPE_ID:=cpe:/a:westes:flex PKG_VERSION:=2.6.4 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz diff --git a/tools/gengetopt/patches/001-gm_utils.cpp-Call-clear-instead-of-empty.patch b/tools/gengetopt/patches/001-gm_utils.cpp-Call-clear-instead-of-empty.patch new file mode 100644 index 0000000000..6aa3f549da --- /dev/null +++ b/tools/gengetopt/patches/001-gm_utils.cpp-Call-clear-instead-of-empty.patch @@ -0,0 +1,25 @@ +From bfba6445a778007f40af5cbfbe725e12c0fcafc6 Mon Sep 17 00:00:00 2001 +From: Tomas Volf <~@wolfsden.cz> +Date: Tue, 5 Mar 2024 22:25:20 +0100 +Subject: [PATCH] gm_utils.cpp: Call clear instead of empty. + +Since the intention seem to be to erase the next word, I believe calling empty +was a mistake and it should have been clear. Empty does nothing in this +context. + +* src/gm_utils.cpp (wrap_cstr): Call clear. +--- + src/gm_utils.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/src/gm_utils.cpp ++++ b/src/gm_utils.cpp +@@ -311,7 +311,7 @@ void wrap_cstr(string& wrapped, unsigned + // trim leading spaces + std::size_t pos = next_word.find_first_not_of(' '); + if( pos == std::string::npos ) +- next_word.empty(); ++ next_word.clear(); + else if( pos ) + next_word.erase( 0, pos ); + diff --git a/tools/gengetopt/patches/002-gm_utils.h-Drop-std-unary_function.patch b/tools/gengetopt/patches/002-gm_utils.h-Drop-std-unary_function.patch new file mode 100644 index 0000000000..ce997f4505 --- /dev/null +++ b/tools/gengetopt/patches/002-gm_utils.h-Drop-std-unary_function.patch @@ -0,0 +1,33 @@ +From a3d0a0419a35bef9b80a6a12432ab30e2d1e0f5a Mon Sep 17 00:00:00 2001 +From: Tomas Volf <~@wolfsden.cz> +Date: Tue, 5 Mar 2024 22:27:42 +0100 +Subject: [PATCH] gm_utils.h: Drop std::unary_function. + +I am not sure what it does, it is deprecated/removed (depending on C++ version) +and the advice seems to be that is just is not necessary. So just remove it. + +* src/gm_utils.h (print_f, pair_print_f): Drop std::unary_function. +--- + src/gm_utils.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/src/gm_utils.h ++++ b/src/gm_utils.h +@@ -117,7 +117,7 @@ bool string_contains(const char *s, cons + * Function object to print something into a stream (to be used with for_each) + */ + template<class T> +-struct print_f : public std::unary_function<T, void> ++struct print_f + { + print_f(std::ostream& out, const string &s = ", ") : os(out), sep(s) {} + void operator() (T x) { os << x << sep; } +@@ -129,7 +129,7 @@ struct print_f : public std::unary_funct + * Function object to print a pair into two streams (to be used with for_each) + */ + template<class T> +-struct pair_print_f : public std::unary_function<T, void> ++struct pair_print_f + { + pair_print_f(std::ostream& out1, std::ostream& out2, const string &s = ", ") : + os1(out1), os2(out2), sep(s) {} diff --git a/tools/gnulib/Makefile b/tools/gnulib/Makefile index 2ce763f6ab..5119355522 100644 --- a/tools/gnulib/Makefile +++ b/tools/gnulib/Makefile @@ -2,11 +2,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=gnulib PKG_CPE_ID:=cpe:/a:gnu:$(PKG_NAME) -PKG_VERSION:=f9a4ee73c3e7b544f640d0d04b55983d3a7b894e# # master +PKG_VERSION:=c99c8d491850dc3a6e0b8604a2729d8bc5c0eff1# # stable-202401 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://git.savannah.gnu.org/cgit/$(PKG_NAME).git/snapshot -PKG_HASH:=514716d58987a9c0de0d69fb22d42bcd19edf80eed099882a004ff162060f1a8 +PKG_HASH:=8e6f4a907d9677b55fd452e1340a3e030a6f530b138d420c11975da33f086b1e include $(INCLUDE_DIR)/host-build.mk diff --git a/tools/gnulib/patches/000-bootstrap.patch b/tools/gnulib/patches/000-bootstrap.patch index 40ed41125c..120586694e 100644 --- a/tools/gnulib/patches/000-bootstrap.patch +++ b/tools/gnulib/patches/000-bootstrap.patch @@ -43,7 +43,7 @@ if [ ! "$inst_ver" ]; then warn_ "Error: '$app' not found" ret=1 -@@ -1135,7 +1135,7 @@ autogen() +@@ -1157,7 +1157,7 @@ autogen() # two just-pre-run programs. # Import from gettext. diff --git a/tools/gnulib/patches/120-unmangle-darwin-fts-h.patch b/tools/gnulib/patches/120-unmangle-darwin-fts-h.patch new file mode 100644 index 0000000000..19e46b9103 --- /dev/null +++ b/tools/gnulib/patches/120-unmangle-darwin-fts-h.patch @@ -0,0 +1,19 @@ +--- /dev/null ++++ b/lib/fts.h +@@ -0,0 +1,6 @@ ++#ifdef __APPLE__ ++# define _FTS_H_ 1 ++# include <fts_.h> ++#else ++# include_next <fts.h> ++#endif +--- a/modules/fts ++++ b/modules/fts +@@ -2,6 +2,7 @@ Description: + Traverse a file hierarchy. + + Files: ++lib/fts.h + lib/fts_.h + lib/fts.c + lib/fts-cycle.c diff --git a/tools/gnulib/patches/150-portable-tdestroy.patch b/tools/gnulib/patches/150-portable-tdestroy.patch new file mode 100644 index 0000000000..39c291f196 --- /dev/null +++ b/tools/gnulib/patches/150-portable-tdestroy.patch @@ -0,0 +1,193 @@ +--- a/lib/search.in.h ++++ b/lib/search.in.h +@@ -112,6 +112,11 @@ _GL_CXXALIASWARN (lsearch); + # define twalk rpl_twalk + # endif + # endif ++# if @REPLACE_TDESTROY@ ++# if !(defined __cplusplus && defined GNULIB_NAMESPACE) ++# define tdestroy rpl_tdestroy ++# endif ++# endif + + /* See <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/search.h.html> + <https://pubs.opengroup.org/onlinepubs/9699919799/functions/tsearch.html> +@@ -137,6 +142,7 @@ extern "C" { + # if !GNULIB_defined_search_fn_types + typedef int (*_gl_search_compar_fn) (const void *, const void *); + typedef void (*_gl_search_action_fn) (const void *, VISIT, int); ++typedef void (*_gl_search_free_fn) (void *); + # define GNULIB_defined_search_fn_types 1 + # endif + # ifdef __cplusplus +@@ -252,9 +258,36 @@ _GL_CXXALIAS_SYS (twalk, void, + _GL_CXXALIASWARN (twalk); + # endif + ++/* Removes the whole tree pointed to by root, ++ freeing all resources allocated by the tsearch() function. ++ The FREE_NODE function is called: ++ - For the data in each tree node. ++ - Even when no such work is necessary, to a function doing nothing ++ The arguments passed to FREE_NODE are: ++ 1. The pointer to the data. */ ++# if @REPLACE_TDESTROY@ ++_GL_FUNCDECL_RPL (tdestroy, void, ++ (void *vroot, _gl_search_free_fn freefct) ++ _GL_ARG_NONNULL ((2))); ++_GL_CXXALIAS_RPL (tdestroy, void, ++ (void *vroot, _gl_search_free_fn freefct)); ++# else ++# if !@HAVE_TDESTROY@ ++_GL_FUNCDECL_SYS (tdestroy, void, ++ (void *vroot, _gl_search_free_fn freefct) ++ _GL_ARG_NONNULL ((2))); ++# endif ++_GL_CXXALIAS_SYS (tdestroy, void, ++ (void *vroot, _gl_search_free_fn freefct)); ++# endif ++# if __GLIBC__ >= 2 ++_GL_CXXALIASWARN (tdestroy); ++# endif ++ + /* Flags used by tsearch.c. */ + # define GNULIB_defined_tsearch (@REPLACE_TSEARCH@ || !@HAVE_TSEARCH@) + # define GNULIB_defined_twalk (@REPLACE_TWALK@ || !@HAVE_TWALK@) ++# define GNULIB_defined_tdestroy (@REPLACE_TDESTROY@ || !@HAVE_TDESTROY@) + + #elif defined GNULIB_POSIXCHECK + # undef tsearch +@@ -277,6 +310,11 @@ _GL_WARN_ON_USE (tdelete, "tdelete is un + _GL_WARN_ON_USE (twalk, "twalk is unportable - " + "use gnulib module tsearch for portability"); + # endif ++# undef tdestroy ++# if HAVE_RAW_DECL_TDESTROY ++_GL_WARN_ON_USE (tdestroy, "tdestroy is unportable - " ++ "use gnulib module tsearch for portability"); ++# endif + #endif + + +--- a/lib/tsearch.c ++++ b/lib/tsearch.c +@@ -98,12 +98,14 @@ + + typedef int (*__compar_fn_t) (const void *, const void *); + typedef void (*__action_fn_t) (const void *, VISIT, int); ++typedef void (*__free_fn_t) (void *); + + #ifndef weak_alias + # define __tsearch tsearch + # define __tfind tfind + # define __tdelete tdelete + # define __twalk twalk ++# define __tdestroy tdestroy + #endif + + #ifndef internal_function +@@ -656,7 +658,7 @@ weak_alias (__twalk, twalk) + #endif /* GNULIB_defined_twalk */ + + +-#ifdef _LIBC ++#if defined(_LIBC) || GNULIB_defined_tdestroy + + /* The standardized functions miss an important functionality: the + tree cannot be removed easily. We provide a function to do this. */ +@@ -683,6 +685,8 @@ __tdestroy (void *vroot, __free_fn_t fre + if (root != NULL) + tdestroy_recurse (root, freefct); + } ++#ifdef weak_alias + weak_alias (__tdestroy, tdestroy) ++#endif + +-#endif /* _LIBC */ ++#endif /* defined(_LIBC) || GNULIB_defined_tdestroy */ +--- a/m4/search_h.m4 ++++ b/m4/search_h.m4 +@@ -39,7 +39,7 @@ AC_DEFUN_ONCE([gl_SEARCH_H], + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include <search.h> +- ]], [tdelete tfind tsearch twalk]) ++ ]], [tdelete tfind tsearch twalk tdestroy]) + + AC_REQUIRE([AC_C_RESTRICT]) + ]) +@@ -75,8 +75,10 @@ AC_DEFUN([gl_SEARCH_H_DEFAULTS], + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_LFIND], [1]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_LSEARCH], [1]) + dnl Assume proper GNU behavior unless another module says otherwise. +- HAVE_TSEARCH=1; AC_SUBST([HAVE_TSEARCH]) +- HAVE_TWALK=1; AC_SUBST([HAVE_TWALK]) +- REPLACE_TSEARCH=0; AC_SUBST([REPLACE_TSEARCH]) +- REPLACE_TWALK=0; AC_SUBST([REPLACE_TWALK]) ++ HAVE_TSEARCH=1; AC_SUBST([HAVE_TSEARCH]) ++ HAVE_TWALK=1; AC_SUBST([HAVE_TWALK]) ++ HAVE_TDESTROY=1; AC_SUBST([HAVE_TDESTROY]) ++ REPLACE_TSEARCH=0; AC_SUBST([REPLACE_TSEARCH]) ++ REPLACE_TWALK=0; AC_SUBST([REPLACE_TWALK]) ++ REPLACE_TDESTROY=0; AC_SUBST([REPLACE_TDESTROY]) + ]) +--- a/m4/tsearch.m4 ++++ b/m4/tsearch.m4 +@@ -9,6 +9,7 @@ AC_DEFUN([gl_FUNC_TSEARCH], + AC_REQUIRE([gl_SEARCH_H_DEFAULTS]) + gl_CHECK_FUNCS_ANDROID([tsearch], [[#include <search.h>]]) + gl_CHECK_FUNCS_ANDROID([twalk], [[#include <search.h>]]) ++ gl_CHECK_FUNCS_ANDROID([tdestroy], [[#include <search.h>]]) + if test $ac_cv_func_tsearch = yes; then + dnl On OpenBSD 4.0, the return value of tdelete() is incorrect. + AC_REQUIRE([AC_PROG_CC]) +@@ -50,6 +51,7 @@ main () + *no) + REPLACE_TSEARCH=1 + REPLACE_TWALK=1 ++ REPLACE_TDESTROY=1 + ;; + esac + else +@@ -64,6 +66,12 @@ main () + future*) REPLACE_TWALK=1 ;; + esac + fi ++ if test $ac_cv_func_tdestroy != yes; then ++ HAVE_TDESTROY=0 ++ case "$gl_cv_onwards_func_tdestroy" in ++ future*) REPLACE_TDESTROY=1 ;; ++ esac ++ fi + ]) + + # Prerequisites of lib/tsearch.c. +--- a/modules/search ++++ b/modules/search +@@ -37,8 +37,10 @@ search.h: search.in.h $(top_builddir)/co + -e 's/@''GNULIB_MDA_LSEARCH''@/$(GNULIB_MDA_LSEARCH)/g' \ + -e 's|@''HAVE_TSEARCH''@|$(HAVE_TSEARCH)|g' \ + -e 's|@''HAVE_TWALK''@|$(HAVE_TWALK)|g' \ ++ -e 's|@''HAVE_TDESTROY''@|$(HAVE_TDESTROY)|g' \ + -e 's|@''REPLACE_TSEARCH''@|$(REPLACE_TSEARCH)|g' \ + -e 's|@''REPLACE_TWALK''@|$(REPLACE_TWALK)|g' \ ++ -e 's|@''REPLACE_TDESTROY''@|$(REPLACE_TDESTROY)|g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ +--- a/modules/tsearch ++++ b/modules/tsearch +@@ -11,7 +11,12 @@ search + configure.ac: + gl_FUNC_TSEARCH + gl_CONDITIONAL([GL_COND_OBJ_TSEARCH], +- [test $HAVE_TSEARCH = 0 || test $HAVE_TWALK = 0 || test $REPLACE_TSEARCH = 1 || test $REPLACE_TWALK = 1]) ++ [test $HAVE_TSEARCH = 0 || ++ test $HAVE_TWALK = 0 || ++ test $HAVE_TDESTROY = 0 || ++ test $REPLACE_TSEARCH = 1 || ++ test $REPLACE_TWALK = 1 || ++ test $REPLACE_TDESTROY = 1]) + AM_COND_IF([GL_COND_OBJ_TSEARCH], [ + gl_PREREQ_TSEARCH + ]) diff --git a/tools/gnulib/patches/160-flag-reallocarray.patch b/tools/gnulib/patches/160-flag-reallocarray.patch new file mode 100644 index 0000000000..8ffe273e11 --- /dev/null +++ b/tools/gnulib/patches/160-flag-reallocarray.patch @@ -0,0 +1,115 @@ +--- a/lib/ialloc.h ++++ b/lib/ialloc.h +@@ -106,6 +106,8 @@ icalloc (idx_t n, idx_t s) + return calloc (n, s); + } + ++#if GNULIB_REALLOCARRAY ++ + /* ireallocarray (ptr, num, size) is like reallocarray (ptr, num, size). + It returns a non-NULL pointer to num * size bytes of memory. + Upon failure, it returns NULL with errno set. */ +@@ -131,6 +133,8 @@ ireallocarray (void *p, idx_t n, idx_t s + return _gl_alloc_nomem (); + } + ++#endif /* GNULIB_REALLOCARRAY */ ++ + #ifdef __cplusplus + } + #endif +--- a/lib/xmalloc.c ++++ b/lib/xmalloc.c +@@ -51,12 +51,16 @@ ximalloc (idx_t s) + return nonnull (imalloc (s)); + } + ++#if GNULIB_REALLOCARRAY ++ + char * + xcharalloc (size_t n) + { + return XNMALLOC (n, char); + } + ++#endif /* GNULIB_REALLOCARRAY */ ++ + /* Change the size of an allocated block of memory P to S bytes, + with error checking. */ + +@@ -75,6 +79,8 @@ xirealloc (void *p, idx_t s) + return nonnull (irealloc (p, s)); + } + ++#if GNULIB_REALLOCARRAY ++ + /* Change the size of an allocated block of memory P to an array of N + objects each of S bytes, with error checking. */ + +@@ -205,6 +211,8 @@ x2nrealloc (void *p, size_t *pn, size_t + return p; + } + ++#endif /* GNULIB_REALLOCARRAY */ ++ + /* Grow PA, which points to an array of *PN items, and return the + location of the reallocated array, updating *PN to reflect its + new size. The new array will contain at least N_INCR_MIN more +--- a/lib/xalloc.h ++++ b/lib/xalloc.h +@@ -129,6 +129,7 @@ char *xstrdup (char const *str) + # define XCALLOC(n, t) \ + ((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t)))) + ++# if GNULIB_REALLOCARRAY + + /* Allocate an array of N objects, each with S bytes of memory, + dynamically, with error checking. S must be nonzero. */ +@@ -156,6 +157,8 @@ char *xcharalloc (size_t n) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL; + ++# endif /* GNULIB_REALLOCARRAY */ ++ + #endif /* GNULIB_XALLOC */ + + +--- a/lib/safe-alloc.h ++++ b/lib/safe-alloc.h +@@ -36,6 +36,8 @@ _GL_INLINE_HEADER_BEGIN + # define SAFE_ALLOC_INLINE _GL_INLINE + #endif + ++#if GNULIB_REALLOCARRAY ++ + /* Don't call these directly - use the macros below. */ + SAFE_ALLOC_INLINE void * + safe_alloc_realloc_n (void *ptr, size_t count, size_t size) +@@ -51,6 +53,9 @@ safe_alloc_realloc_n (void *ptr, size_t + #endif + return ptr; + } ++ ++#endif /* GNULIB_REALLOCARRAY */ ++ + _GL_ATTRIBUTE_NODISCARD SAFE_ALLOC_INLINE int + safe_alloc_check (void *ptr) + { +@@ -84,6 +89,8 @@ safe_alloc_check (void *ptr) + #define ALLOC_N(ptr, count) \ + safe_alloc_check ((ptr) = calloc (count, sizeof *(ptr))) + ++#if GNULIB_REALLOCARRAY ++ + /** + * ALLOC_N_UNINITIALIZED: + * @ptr: pointer to allocated memory +@@ -112,6 +119,8 @@ safe_alloc_check (void *ptr) + #define REALLOC_N(ptr, count) \ + safe_alloc_check ((ptr) = safe_alloc_realloc_n (ptr, count, sizeof *(ptr))) + ++#endif /* GNULIB_REALLOCARRAY */ ++ + /** + * FREE: + * @ptr: pointer holding address to be freed diff --git a/tools/include/asm/bitsperlong.h b/tools/include/asm/bitsperlong.h new file mode 100644 index 0000000000..75f320fa91 --- /dev/null +++ b/tools/include/asm/bitsperlong.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_BITS_PER_LONG +#define __ASM_GENERIC_BITS_PER_LONG + +#ifndef __BITS_PER_LONG +/* + * In order to keep safe and avoid regression, only unify uapi + * bitsperlong.h for some archs which are using newer toolchains + * that have the definitions of __CHAR_BIT__ and __SIZEOF_LONG__. + * See the following link for more info: + * https://lore.kernel.org/linux-arch/b9624545-2c80-49a1-ac3c-39264a591f7b@app.fastmail.com/ + */ +#if defined(__CHAR_BIT__) && defined(__SIZEOF_LONG__) +#define __BITS_PER_LONG (__CHAR_BIT__ * __SIZEOF_LONG__) +#else +/* + * There seems to be no way of detecting this automatically from user + * space, so 64 bit architectures should override this in their + * bitsperlong.h. In particular, an architecture that supports + * both 32 and 64 bit user space must not rely on CONFIG_64BIT + * to decide it, but rather check a compiler provided macro. + */ +#define __BITS_PER_LONG 32 +#endif +#endif + +#endif /* __ASM_GENERIC_BITS_PER_LONG */ diff --git a/tools/include/asm/byteorder.h b/tools/include/asm/byteorder.h new file mode 100644 index 0000000000..8e7d779d7d --- /dev/null +++ b/tools/include/asm/byteorder.h @@ -0,0 +1,12 @@ +#ifndef __ASM_BYTEORDER_H +#define __ASM_BYTEORDER_H + +#include <endian.h> + +#if __BYTE_ORDER == __LITTLE_ENDIAN +#include <linux/byteorder/little_endian.h> +#else +#include <linux/byteorder/big_endian.h> +#endif + +#endif diff --git a/tools/include/asm/errno-base.h b/tools/include/asm/errno-base.h new file mode 100644 index 0000000000..9653140bff --- /dev/null +++ b/tools/include/asm/errno-base.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_GENERIC_ERRNO_BASE_H +#define _ASM_GENERIC_ERRNO_BASE_H + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Argument list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ + +#endif diff --git a/tools/include/asm/errno.h b/tools/include/asm/errno.h new file mode 100644 index 0000000000..a96d525330 --- /dev/null +++ b/tools/include/asm/errno.h @@ -0,0 +1,123 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_GENERIC_ERRNO_H +#define _ASM_GENERIC_ERRNO_H + +#include <asm/errno-base.h> + +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ + +/* + * This error code is special: arch syscall entry code will return + * -ENOSYS if users try to call a syscall that doesn't exist. To keep + * failures of syscalls that really do exist distinguishable from + * failures due to attempts to use a nonexistent syscall, syscall + * implementations should refrain from returning -ENOSYS. + */ +#define ENOSYS 38 /* Invalid system call number */ + +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define ENOMSG 42 /* No message of desired type */ +#define EIDRM 43 /* Identifier removed */ +#define ECHRNG 44 /* Channel number out of range */ +#define EL2NSYNC 45 /* Level 2 not synchronized */ +#define EL3HLT 46 /* Level 3 halted */ +#define EL3RST 47 /* Level 3 reset */ +#define ELNRNG 48 /* Link number out of range */ +#define EUNATCH 49 /* Protocol driver not attached */ +#define ENOCSI 50 /* No CSI structure available */ +#define EL2HLT 51 /* Level 2 halted */ +#define EBADE 52 /* Invalid exchange */ +#define EBADR 53 /* Invalid request descriptor */ +#define EXFULL 54 /* Exchange full */ +#define ENOANO 55 /* No anode */ +#define EBADRQC 56 /* Invalid request code */ +#define EBADSLT 57 /* Invalid slot */ + +#define EDEADLOCK EDEADLK + +#define EBFONT 59 /* Bad font file format */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* No data available */ +#define ETIME 62 /* Timer expired */ +#define ENOSR 63 /* Out of streams resources */ +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* Object is remote */ +#define ENOLINK 67 /* Link has been severed */ +#define EADV 68 /* Advertise error */ +#define ESRMNT 69 /* Srmount error */ +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ +#define EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#define EBADMSG 74 /* Not a data message */ +#define EOVERFLOW 75 /* Value too large for defined data type */ +#define ENOTUNIQ 76 /* Name not unique on network */ +#define EBADFD 77 /* File descriptor in bad state */ +#define EREMCHG 78 /* Remote address changed */ +#define ELIBACC 79 /* Can not access a needed shared library */ +#define ELIBBAD 80 /* Accessing a corrupted shared library */ +#define ELIBSCN 81 /* .lib section in a.out corrupted */ +#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define EILSEQ 84 /* Illegal byte sequence */ +#define ERESTART 85 /* Interrupted system call should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ + +#define ENOMEDIUM 123 /* No medium found */ +#define EMEDIUMTYPE 124 /* Wrong medium type */ +#define ECANCELED 125 /* Operation Canceled */ +#define ENOKEY 126 /* Required key not available */ +#define EKEYEXPIRED 127 /* Key has expired */ +#define EKEYREVOKED 128 /* Key has been revoked */ +#define EKEYREJECTED 129 /* Key was rejected by service */ + +/* for robust mutexes */ +#define EOWNERDEAD 130 /* Owner died */ +#define ENOTRECOVERABLE 131 /* State not recoverable */ + +#define ERFKILL 132 /* Operation not possible due to RF-kill */ + +#define EHWPOISON 133 /* Memory page has hardware error */ + +#endif diff --git a/tools/include/asm/posix_types.h b/tools/include/asm/posix_types.h new file mode 100644 index 0000000000..10f5e6ef4a --- /dev/null +++ b/tools/include/asm/posix_types.h @@ -0,0 +1,100 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_POSIX_TYPES_H +#define __ASM_GENERIC_POSIX_TYPES_H + +#include <asm/bitsperlong.h> + +/* + * This file is generally used by user-level software, so you need to + * be a little careful about namespace pollution etc. + * + * First the types that are often defined in different ways across + * architectures, so that you can override them. + */ + +#ifndef __kernel_long_t +typedef long __kernel_long_t; +typedef unsigned long __kernel_ulong_t; +#endif + +#ifndef __kernel_ino_t +typedef __kernel_ulong_t __kernel_ino_t; +#endif + +#ifndef __kernel_mode_t +typedef unsigned int __kernel_mode_t; +#endif + +#ifndef __kernel_pid_t +typedef int __kernel_pid_t; +#endif + +#ifndef __kernel_ipc_pid_t +typedef int __kernel_ipc_pid_t; +#endif + +#ifndef __kernel_uid_t +typedef unsigned int __kernel_uid_t; +typedef unsigned int __kernel_gid_t; +#endif + +#ifndef __kernel_suseconds_t +typedef __kernel_long_t __kernel_suseconds_t; +#endif + +#ifndef __kernel_daddr_t +typedef int __kernel_daddr_t; +#endif + +#ifndef __kernel_uid32_t +typedef unsigned int __kernel_uid32_t; +typedef unsigned int __kernel_gid32_t; +#endif + +#ifndef __kernel_old_uid_t +typedef __kernel_uid_t __kernel_old_uid_t; +typedef __kernel_gid_t __kernel_old_gid_t; +#endif + +#ifndef __kernel_old_dev_t +typedef unsigned int __kernel_old_dev_t; +#endif + +/* + * Most 32 bit architectures use "unsigned int" size_t, + * and all 64 bit architectures use "unsigned long" size_t. + */ +#ifndef __kernel_size_t +#if __BITS_PER_LONG != 64 +typedef unsigned int __kernel_size_t; +typedef int __kernel_ssize_t; +typedef int __kernel_ptrdiff_t; +#else +typedef __kernel_ulong_t __kernel_size_t; +typedef __kernel_long_t __kernel_ssize_t; +typedef __kernel_long_t __kernel_ptrdiff_t; +#endif +#endif + +#ifndef __kernel_fsid_t +typedef struct { + int val[2]; +} __kernel_fsid_t; +#endif + +/* + * anything below here should be completely generic + */ +typedef __kernel_long_t __kernel_off_t; +typedef long long __kernel_loff_t; +typedef __kernel_long_t __kernel_old_time_t; +typedef __kernel_long_t __kernel_time_t; +typedef long long __kernel_time64_t; +typedef __kernel_long_t __kernel_clock_t; +typedef int __kernel_timer_t; +typedef int __kernel_clockid_t; +typedef char * __kernel_caddr_t; +typedef unsigned short __kernel_uid16_t; +typedef unsigned short __kernel_gid16_t; + +#endif /* __ASM_GENERIC_POSIX_TYPES_H */ diff --git a/tools/include/asm/swab.h b/tools/include/asm/swab.h new file mode 100644 index 0000000000..f2da4e4fd4 --- /dev/null +++ b/tools/include/asm/swab.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _ASM_GENERIC_SWAB_H +#define _ASM_GENERIC_SWAB_H + +#include <asm/bitsperlong.h> + +/* + * 32 bit architectures typically (but not always) want to + * set __SWAB_64_THRU_32__. In user space, this is only + * valid if the compiler supports 64 bit data types. + */ + +#if __BITS_PER_LONG == 32 +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__) +#define __SWAB_64_THRU_32__ +#endif +#endif + +#endif /* _ASM_GENERIC_SWAB_H */ diff --git a/tools/include/linux/big_endian.h b/tools/include/linux/big_endian.h new file mode 100644 index 0000000000..3bb87c573c --- /dev/null +++ b/tools/include/linux/big_endian.h @@ -0,0 +1,107 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _LINUX_BYTEORDER_BIG_ENDIAN_H +#define _LINUX_BYTEORDER_BIG_ENDIAN_H + +#ifndef __BIG_ENDIAN +#define __BIG_ENDIAN 4321 +#endif +#ifndef __BIG_ENDIAN_BITFIELD +#define __BIG_ENDIAN_BITFIELD +#endif + +#include <linux/stddef.h> +#include <linux/types.h> +#include <linux/swab.h> + +#define __constant_htonl(x) ((__be32)(__u32)(x)) +#define __constant_ntohl(x) ((__u32)(__be32)(x)) +#define __constant_htons(x) ((__be16)(__u16)(x)) +#define __constant_ntohs(x) ((__u16)(__be16)(x)) +#define __constant_cpu_to_le64(x) ((__le64)___constant_swab64((x))) +#define __constant_le64_to_cpu(x) ___constant_swab64((__u64)(__le64)(x)) +#define __constant_cpu_to_le32(x) ((__le32)___constant_swab32((x))) +#define __constant_le32_to_cpu(x) ___constant_swab32((__u32)(__le32)(x)) +#define __constant_cpu_to_le16(x) ((__le16)___constant_swab16((x))) +#define __constant_le16_to_cpu(x) ___constant_swab16((__u16)(__le16)(x)) +#define __constant_cpu_to_be64(x) ((__be64)(__u64)(x)) +#define __constant_be64_to_cpu(x) ((__u64)(__be64)(x)) +#define __constant_cpu_to_be32(x) ((__be32)(__u32)(x)) +#define __constant_be32_to_cpu(x) ((__u32)(__be32)(x)) +#define __constant_cpu_to_be16(x) ((__be16)(__u16)(x)) +#define __constant_be16_to_cpu(x) ((__u16)(__be16)(x)) +#define __cpu_to_le64(x) ((__le64)__swab64((x))) +#define __le64_to_cpu(x) __swab64((__u64)(__le64)(x)) +#define __cpu_to_le32(x) ((__le32)__swab32((x))) +#define __le32_to_cpu(x) __swab32((__u32)(__le32)(x)) +#define __cpu_to_le16(x) ((__le16)__swab16((x))) +#define __le16_to_cpu(x) __swab16((__u16)(__le16)(x)) +#define __cpu_to_be64(x) ((__be64)(__u64)(x)) +#define __be64_to_cpu(x) ((__u64)(__be64)(x)) +#define __cpu_to_be32(x) ((__be32)(__u32)(x)) +#define __be32_to_cpu(x) ((__u32)(__be32)(x)) +#define __cpu_to_be16(x) ((__be16)(__u16)(x)) +#define __be16_to_cpu(x) ((__u16)(__be16)(x)) + +static __always_inline __le64 __cpu_to_le64p(const __u64 *p) +{ + return (__le64)__swab64p(p); +} +static __always_inline __u64 __le64_to_cpup(const __le64 *p) +{ + return __swab64p((__u64 *)p); +} +static __always_inline __le32 __cpu_to_le32p(const __u32 *p) +{ + return (__le32)__swab32p(p); +} +static __always_inline __u32 __le32_to_cpup(const __le32 *p) +{ + return __swab32p((__u32 *)p); +} +static __always_inline __le16 __cpu_to_le16p(const __u16 *p) +{ + return (__le16)__swab16p(p); +} +static __always_inline __u16 __le16_to_cpup(const __le16 *p) +{ + return __swab16p((__u16 *)p); +} +static __always_inline __be64 __cpu_to_be64p(const __u64 *p) +{ + return (__be64)*p; +} +static __always_inline __u64 __be64_to_cpup(const __be64 *p) +{ + return (__u64)*p; +} +static __always_inline __be32 __cpu_to_be32p(const __u32 *p) +{ + return (__be32)*p; +} +static __always_inline __u32 __be32_to_cpup(const __be32 *p) +{ + return (__u32)*p; +} +static __always_inline __be16 __cpu_to_be16p(const __u16 *p) +{ + return (__be16)*p; +} +static __always_inline __u16 __be16_to_cpup(const __be16 *p) +{ + return (__u16)*p; +} +#define __cpu_to_le64s(x) __swab64s((x)) +#define __le64_to_cpus(x) __swab64s((x)) +#define __cpu_to_le32s(x) __swab32s((x)) +#define __le32_to_cpus(x) __swab32s((x)) +#define __cpu_to_le16s(x) __swab16s((x)) +#define __le16_to_cpus(x) __swab16s((x)) +#define __cpu_to_be64s(x) do { (void)(x); } while (0) +#define __be64_to_cpus(x) do { (void)(x); } while (0) +#define __cpu_to_be32s(x) do { (void)(x); } while (0) +#define __be32_to_cpus(x) do { (void)(x); } while (0) +#define __cpu_to_be16s(x) do { (void)(x); } while (0) +#define __be16_to_cpus(x) do { (void)(x); } while (0) + + +#endif /* _LINUX_BYTEORDER_BIG_ENDIAN_H */ diff --git a/tools/include/linux/errno.h b/tools/include/linux/errno.h new file mode 100644 index 0000000000..70f2bd34e3 --- /dev/null +++ b/tools/include/linux/errno.h @@ -0,0 +1 @@ +#include <asm/errno.h> diff --git a/tools/include/linux/little_endian.h b/tools/include/linux/little_endian.h new file mode 100644 index 0000000000..ba6c199c9b --- /dev/null +++ b/tools/include/linux/little_endian.h @@ -0,0 +1,107 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _LINUX_BYTEORDER_LITTLE_ENDIAN_H +#define _LINUX_BYTEORDER_LITTLE_ENDIAN_H + +#ifndef __LITTLE_ENDIAN +#define __LITTLE_ENDIAN 1234 +#endif +#ifndef __LITTLE_ENDIAN_BITFIELD +#define __LITTLE_ENDIAN_BITFIELD +#endif + +#include <linux/stddef.h> +#include <linux/types.h> +#include <linux/swab.h> + +#define __constant_htonl(x) ((__be32)___constant_swab32((x))) +#define __constant_ntohl(x) ___constant_swab32((__be32)(x)) +#define __constant_htons(x) ((__be16)___constant_swab16((x))) +#define __constant_ntohs(x) ___constant_swab16((__be16)(x)) +#define __constant_cpu_to_le64(x) ((__le64)(__u64)(x)) +#define __constant_le64_to_cpu(x) ((__u64)(__le64)(x)) +#define __constant_cpu_to_le32(x) ((__le32)(__u32)(x)) +#define __constant_le32_to_cpu(x) ((__u32)(__le32)(x)) +#define __constant_cpu_to_le16(x) ((__le16)(__u16)(x)) +#define __constant_le16_to_cpu(x) ((__u16)(__le16)(x)) +#define __constant_cpu_to_be64(x) ((__be64)___constant_swab64((x))) +#define __constant_be64_to_cpu(x) ___constant_swab64((__u64)(__be64)(x)) +#define __constant_cpu_to_be32(x) ((__be32)___constant_swab32((x))) +#define __constant_be32_to_cpu(x) ___constant_swab32((__u32)(__be32)(x)) +#define __constant_cpu_to_be16(x) ((__be16)___constant_swab16((x))) +#define __constant_be16_to_cpu(x) ___constant_swab16((__u16)(__be16)(x)) +#define __cpu_to_le64(x) ((__le64)(__u64)(x)) +#define __le64_to_cpu(x) ((__u64)(__le64)(x)) +#define __cpu_to_le32(x) ((__le32)(__u32)(x)) +#define __le32_to_cpu(x) ((__u32)(__le32)(x)) +#define __cpu_to_le16(x) ((__le16)(__u16)(x)) +#define __le16_to_cpu(x) ((__u16)(__le16)(x)) +#define __cpu_to_be64(x) ((__be64)__swab64((x))) +#define __be64_to_cpu(x) __swab64((__u64)(__be64)(x)) +#define __cpu_to_be32(x) ((__be32)__swab32((x))) +#define __be32_to_cpu(x) __swab32((__u32)(__be32)(x)) +#define __cpu_to_be16(x) ((__be16)__swab16((x))) +#define __be16_to_cpu(x) __swab16((__u16)(__be16)(x)) + +static __always_inline __le64 __cpu_to_le64p(const __u64 *p) +{ + return (__le64)*p; +} +static __always_inline __u64 __le64_to_cpup(const __le64 *p) +{ + return (__u64)*p; +} +static __always_inline __le32 __cpu_to_le32p(const __u32 *p) +{ + return (__le32)*p; +} +static __always_inline __u32 __le32_to_cpup(const __le32 *p) +{ + return (__u32)*p; +} +static __always_inline __le16 __cpu_to_le16p(const __u16 *p) +{ + return (__le16)*p; +} +static __always_inline __u16 __le16_to_cpup(const __le16 *p) +{ + return (__u16)*p; +} +static __always_inline __be64 __cpu_to_be64p(const __u64 *p) +{ + return (__be64)__swab64p(p); +} +static __always_inline __u64 __be64_to_cpup(const __be64 *p) +{ + return __swab64p((__u64 *)p); +} +static __always_inline __be32 __cpu_to_be32p(const __u32 *p) +{ + return (__be32)__swab32p(p); +} +static __always_inline __u32 __be32_to_cpup(const __be32 *p) +{ + return __swab32p((__u32 *)p); +} +static __always_inline __be16 __cpu_to_be16p(const __u16 *p) +{ + return (__be16)__swab16p(p); +} +static __always_inline __u16 __be16_to_cpup(const __be16 *p) +{ + return __swab16p((__u16 *)p); +} +#define __cpu_to_le64s(x) do { (void)(x); } while (0) +#define __le64_to_cpus(x) do { (void)(x); } while (0) +#define __cpu_to_le32s(x) do { (void)(x); } while (0) +#define __le32_to_cpus(x) do { (void)(x); } while (0) +#define __cpu_to_le16s(x) do { (void)(x); } while (0) +#define __le16_to_cpus(x) do { (void)(x); } while (0) +#define __cpu_to_be64s(x) __swab64s((x)) +#define __be64_to_cpus(x) __swab64s((x)) +#define __cpu_to_be32s(x) __swab32s((x)) +#define __be32_to_cpus(x) __swab32s((x)) +#define __cpu_to_be16s(x) __swab16s((x)) +#define __be16_to_cpus(x) __swab16s((x)) + + +#endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */ diff --git a/tools/include/linux/stddef.h b/tools/include/linux/stddef.h new file mode 100644 index 0000000000..e3d20e76b1 --- /dev/null +++ b/tools/include/linux/stddef.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_LINUX_STDDEF_H +#define _UAPI_LINUX_STDDEF_H + +#ifndef __always_inline +#define __always_inline inline +#endif + +/** + * __struct_group() - Create a mirrored named and anonyomous struct + * + * @TAG: The tag name for the named sub-struct (usually empty) + * @NAME: The identifier name of the mirrored sub-struct + * @ATTRS: Any struct attributes (usually empty) + * @MEMBERS: The member declarations for the mirrored structs + * + * Used to create an anonymous union of two structs with identical layout + * and size: one anonymous and one named. The former's members can be used + * normally without sub-struct naming, and the latter can be used to + * reason about the start, end, and size of the group of struct members. + * The named struct can also be explicitly tagged for layer reuse, as well + * as both having struct attributes appended. + */ +#define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \ + union { \ + struct { MEMBERS } ATTRS; \ + struct TAG { MEMBERS } ATTRS NAME; \ + } ATTRS + +#ifdef __cplusplus +/* sizeof(struct{}) is 1 in C++, not 0, can't use C version of the macro. */ +#define __DECLARE_FLEX_ARRAY(T, member) \ + T member[0] +#else +/** + * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union + * + * @TYPE: The type of each flexible array element + * @NAME: The name of the flexible array member + * + * In order to have a flexible array member in a union or alone in a + * struct, it needs to be wrapped in an anonymous struct with at least 1 + * named member, but that member can be empty. + */ +#define __DECLARE_FLEX_ARRAY(TYPE, NAME) \ + struct { \ + struct { } __empty_ ## NAME; \ + TYPE NAME[]; \ + } +#endif + +#ifndef __counted_by +#define __counted_by(m) +#endif + +#endif /* _UAPI_LINUX_STDDEF_H */ diff --git a/tools/include/linux/swab.h b/tools/include/linux/swab.h new file mode 100644 index 0000000000..7e3bad56cf --- /dev/null +++ b/tools/include/linux/swab.h @@ -0,0 +1,305 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _LINUX_SWAB_H +#define _LINUX_SWAB_H + +#include <linux/types.h> +#include <linux/stddef.h> +#include <asm/bitsperlong.h> +#include <asm/swab.h> + +/* + * casts are necessary for constants, because we never know how for sure + * how U/UL/ULL map to __u16, __u32, __u64. At least not in a portable way. + */ +#define ___constant_swab16(x) ((__u16)( \ + (((__u16)(x) & (__u16)0x00ffU) << 8) | \ + (((__u16)(x) & (__u16)0xff00U) >> 8))) + +#define ___constant_swab32(x) ((__u32)( \ + (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \ + (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \ + (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \ + (((__u32)(x) & (__u32)0xff000000UL) >> 24))) + +#define ___constant_swab64(x) ((__u64)( \ + (((__u64)(x) & (__u64)0x00000000000000ffULL) << 56) | \ + (((__u64)(x) & (__u64)0x000000000000ff00ULL) << 40) | \ + (((__u64)(x) & (__u64)0x0000000000ff0000ULL) << 24) | \ + (((__u64)(x) & (__u64)0x00000000ff000000ULL) << 8) | \ + (((__u64)(x) & (__u64)0x000000ff00000000ULL) >> 8) | \ + (((__u64)(x) & (__u64)0x0000ff0000000000ULL) >> 24) | \ + (((__u64)(x) & (__u64)0x00ff000000000000ULL) >> 40) | \ + (((__u64)(x) & (__u64)0xff00000000000000ULL) >> 56))) + +#define ___constant_swahw32(x) ((__u32)( \ + (((__u32)(x) & (__u32)0x0000ffffUL) << 16) | \ + (((__u32)(x) & (__u32)0xffff0000UL) >> 16))) + +#define ___constant_swahb32(x) ((__u32)( \ + (((__u32)(x) & (__u32)0x00ff00ffUL) << 8) | \ + (((__u32)(x) & (__u32)0xff00ff00UL) >> 8))) + +/* + * Implement the following as inlines, but define the interface using + * macros to allow constant folding when possible: + * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32 + */ + +static __inline__ __u16 __fswab16(__u16 val) +{ +#if defined (__arch_swab16) + return __arch_swab16(val); +#else + return ___constant_swab16(val); +#endif +} + +static __inline__ __u32 __fswab32(__u32 val) +{ +#if defined(__arch_swab32) + return __arch_swab32(val); +#else + return ___constant_swab32(val); +#endif +} + +static __inline__ __u64 __fswab64(__u64 val) +{ +#if defined (__arch_swab64) + return __arch_swab64(val); +#elif defined(__SWAB_64_THRU_32__) + __u32 h = val >> 32; + __u32 l = val & ((1ULL << 32) - 1); + return (((__u64)__fswab32(l)) << 32) | ((__u64)(__fswab32(h))); +#else + return ___constant_swab64(val); +#endif +} + +static __inline__ __u32 __fswahw32(__u32 val) +{ +#ifdef __arch_swahw32 + return __arch_swahw32(val); +#else + return ___constant_swahw32(val); +#endif +} + +static __inline__ __u32 __fswahb32(__u32 val) +{ +#ifdef __arch_swahb32 + return __arch_swahb32(val); +#else + return ___constant_swahb32(val); +#endif +} + +/** + * __swab16 - return a byteswapped 16-bit value + * @x: value to byteswap + */ +#ifdef __HAVE_BUILTIN_BSWAP16__ +#define __swab16(x) (__u16)__builtin_bswap16((__u16)(x)) +#else +#define __swab16(x) \ + (__u16)(__builtin_constant_p(x) ? \ + ___constant_swab16(x) : \ + __fswab16(x)) +#endif + +/** + * __swab32 - return a byteswapped 32-bit value + * @x: value to byteswap + */ +#ifdef __HAVE_BUILTIN_BSWAP32__ +#define __swab32(x) (__u32)__builtin_bswap32((__u32)(x)) +#else +#define __swab32(x) \ + (__u32)(__builtin_constant_p(x) ? \ + ___constant_swab32(x) : \ + __fswab32(x)) +#endif + +/** + * __swab64 - return a byteswapped 64-bit value + * @x: value to byteswap + */ +#ifdef __HAVE_BUILTIN_BSWAP64__ +#define __swab64(x) (__u64)__builtin_bswap64((__u64)(x)) +#else +#define __swab64(x) \ + (__u64)(__builtin_constant_p(x) ? \ + ___constant_swab64(x) : \ + __fswab64(x)) +#endif + +static __always_inline unsigned long __swab(const unsigned long y) +{ +#if __BITS_PER_LONG == 64 + return __swab64(y); +#else /* __BITS_PER_LONG == 32 */ + return __swab32(y); +#endif +} + +/** + * __swahw32 - return a word-swapped 32-bit value + * @x: value to wordswap + * + * __swahw32(0x12340000) is 0x00001234 + */ +#define __swahw32(x) \ + (__builtin_constant_p((__u32)(x)) ? \ + ___constant_swahw32(x) : \ + __fswahw32(x)) + +/** + * __swahb32 - return a high and low byte-swapped 32-bit value + * @x: value to byteswap + * + * __swahb32(0x12345678) is 0x34127856 + */ +#define __swahb32(x) \ + (__builtin_constant_p((__u32)(x)) ? \ + ___constant_swahb32(x) : \ + __fswahb32(x)) + +/** + * __swab16p - return a byteswapped 16-bit value from a pointer + * @p: pointer to a naturally-aligned 16-bit value + */ +static __always_inline __u16 __swab16p(const __u16 *p) +{ +#ifdef __arch_swab16p + return __arch_swab16p(p); +#else + return __swab16(*p); +#endif +} + +/** + * __swab32p - return a byteswapped 32-bit value from a pointer + * @p: pointer to a naturally-aligned 32-bit value + */ +static __always_inline __u32 __swab32p(const __u32 *p) +{ +#ifdef __arch_swab32p + return __arch_swab32p(p); +#else + return __swab32(*p); +#endif +} + +/** + * __swab64p - return a byteswapped 64-bit value from a pointer + * @p: pointer to a naturally-aligned 64-bit value + */ +static __always_inline __u64 __swab64p(const __u64 *p) +{ +#ifdef __arch_swab64p + return __arch_swab64p(p); +#else + return __swab64(*p); +#endif +} + +/** + * __swahw32p - return a wordswapped 32-bit value from a pointer + * @p: pointer to a naturally-aligned 32-bit value + * + * See __swahw32() for details of wordswapping. + */ +static __inline__ __u32 __swahw32p(const __u32 *p) +{ +#ifdef __arch_swahw32p + return __arch_swahw32p(p); +#else + return __swahw32(*p); +#endif +} + +/** + * __swahb32p - return a high and low byteswapped 32-bit value from a pointer + * @p: pointer to a naturally-aligned 32-bit value + * + * See __swahb32() for details of high/low byteswapping. + */ +static __inline__ __u32 __swahb32p(const __u32 *p) +{ +#ifdef __arch_swahb32p + return __arch_swahb32p(p); +#else + return __swahb32(*p); +#endif +} + +/** + * __swab16s - byteswap a 16-bit value in-place + * @p: pointer to a naturally-aligned 16-bit value + */ +static __inline__ void __swab16s(__u16 *p) +{ +#ifdef __arch_swab16s + __arch_swab16s(p); +#else + *p = __swab16p(p); +#endif +} +/** + * __swab32s - byteswap a 32-bit value in-place + * @p: pointer to a naturally-aligned 32-bit value + */ +static __always_inline void __swab32s(__u32 *p) +{ +#ifdef __arch_swab32s + __arch_swab32s(p); +#else + *p = __swab32p(p); +#endif +} + +/** + * __swab64s - byteswap a 64-bit value in-place + * @p: pointer to a naturally-aligned 64-bit value + */ +static __always_inline void __swab64s(__u64 *p) +{ +#ifdef __arch_swab64s + __arch_swab64s(p); +#else + *p = __swab64p(p); +#endif +} + +/** + * __swahw32s - wordswap a 32-bit value in-place + * @p: pointer to a naturally-aligned 32-bit value + * + * See __swahw32() for details of wordswapping + */ +static __inline__ void __swahw32s(__u32 *p) +{ +#ifdef __arch_swahw32s + __arch_swahw32s(p); +#else + *p = __swahw32p(p); +#endif +} + +/** + * __swahb32s - high and low byteswap a 32-bit value in-place + * @p: pointer to a naturally-aligned 32-bit value + * + * See __swahb32() for details of high and low byte swapping + */ +static __inline__ void __swahb32s(__u32 *p) +{ +#ifdef __arch_swahb32s + __arch_swahb32s(p); +#else + *p = __swahb32p(p); +#endif +} + + +#endif /* _LINUX_SWAB_H */ diff --git a/tools/kernel2minor/Makefile b/tools/kernel2minor/Makefile deleted file mode 100644 index 69108f43df..0000000000 --- a/tools/kernel2minor/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright (C) 2016 adron@yapic.net -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# -include $(TOPDIR)/rules.mk - -PKG_NAME:=kernel2minor -PKG_VERSION:=0.25 -PKG_RELEASE:=1 - -PKG_SOURCE_URL:=https://github.com/adron-s/kernel2minor.git -PKG_MIRROR_HASH:=4e59e6e9883a17b90d09d4b6df0cbff83badad9a0e148dfa730abafce000128d -PKG_SOURCE_PROTO:=git -PKG_SOURCE_VERSION:=1e5a52c7941945f6d64807ebca4a5923ba5466bd -PKG_HASH:=33ca413403a3341af0c9a8e6d9bb58f4ad080a5339e8a8729b83637d35bfaf1b - -include $(INCLUDE_DIR)/host-build.mk - -define Host/Install - $(INSTALL_BIN) $(HOST_BUILD_DIR)/kernel2minor $(STAGING_DIR_HOST)/bin/ -endef - -define Host/Clean - rm -f $(STAGING_DIR_HOST)/bin/kernel2minor -endef - -$(eval $(call HostBuild)) diff --git a/tools/liblzo/patches/001-add-cmake-ENABLE-configurables.patch b/tools/liblzo/patches/001-add-cmake-ENABLE-configurables.patch index 9ab27fc924..e0ba410167 100644 --- a/tools/liblzo/patches/001-add-cmake-ENABLE-configurables.patch +++ b/tools/liblzo/patches/001-add-cmake-ENABLE-configurables.patch @@ -1,6 +1,6 @@ ---- a/CMakeLists.txt 2022-11-28 06:34:39.171209779 -0800 -+++ b/CMakeLists.txt 2022-11-28 06:33:13.368239757 -0800 -@@ -51,8 +51,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -51,8 +51,11 @@ endif() project(lzo VERSION 2.10 LANGUAGES C) # configuration options @@ -14,7 +14,7 @@ if(NOT ENABLE_STATIC AND NOT ENABLE_SHARED) set(ENABLE_STATIC ON) endif() -@@ -127,14 +130,20 @@ +@@ -127,14 +130,20 @@ macro(lzo_add_executable t) endif() endmacro() # main test driver @@ -35,7 +35,7 @@ # some boring internal test programs if(0) lzo_add_executable(align tests/align.c) -@@ -144,7 +153,7 @@ +@@ -144,7 +153,7 @@ if(0) endif() # miniLZO @@ -44,7 +44,7 @@ add_executable(testmini minilzo/testmini.c minilzo/minilzo.c) target_include_directories(testmini PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include/lzo") # needed for "lzoconf.h" endif() -@@ -263,8 +272,10 @@ +@@ -263,8 +272,10 @@ add_test(NAME lzotest-03 COMMAND lzotest if(DEFINED CMAKE_INSTALL_FULL_LIBDIR) @@ -57,7 +57,7 @@ set(f include/lzo/lzo1.h include/lzo/lzo1a.h include/lzo/lzo1b.h include/lzo/lzo1c.h include/lzo/lzo1f.h include/lzo/lzo1x.h -@@ -285,7 +296,7 @@ +@@ -285,7 +296,7 @@ if(ENABLE_SHARED) ) endif() diff --git a/tools/lz4/patches/001-add-make-ENABLE_DOCS-configurable.patch b/tools/lz4/patches/001-add-make-ENABLE_DOCS-configurable.patch deleted file mode 100644 index 5d6dca33f3..0000000000 --- a/tools/lz4/patches/001-add-make-ENABLE_DOCS-configurable.patch +++ /dev/null @@ -1,60 +0,0 @@ -+++ a/programs/Makefile 2022-08-15 15:45:31.000000000 -0700 ---- b/programs/Makefile 2022-11-28 16:34:21.315593784 -0800 -@@ -66,6 +66,7 @@ - MD2ROFF = ronn - MD2ROFF_FLAGS = --roff --warnings --manual="User Commands" --organization="lz4 $(LZ4_VERSION)" - -+ENABLE_DOCS ?= 1 - - default: lz4-release - -@@ -120,6 +121,7 @@ - lz4c32 : $(SRCFILES) - $(CC) $(FLAGS) $^ -o $@$(EXT) - -+ifeq ($(ENABLE_DOCS),1) - lz4.1: lz4.1.md $(LIBVER_SRC) - cat $< | $(MD2ROFF) $(MD2ROFF_FLAGS) | $(SED) -n '/^\.\\\".*/!p' > $@ - -@@ -130,6 +132,7 @@ - - preview-man: clean-man man - man ./lz4.1 -+endif - - clean: - ifeq ($(WINBASED),yes) -@@ -172,16 +175,19 @@ - - install: lz4 - @echo Installing binaries in $(DESTDIR)$(bindir) -- $(INSTALL_DIR) $(DESTDIR)$(bindir)/ $(DESTDIR)$(man1dir)/ -+ $(INSTALL_DIR) $(DESTDIR)$(bindir)/ - $(INSTALL_PROGRAM) lz4$(EXT) $(DESTDIR)$(bindir)/lz4$(EXT) - $(LN_SF) lz4$(EXT) $(DESTDIR)$(bindir)/lz4c$(EXT) - $(LN_SF) lz4$(EXT) $(DESTDIR)$(bindir)/lz4cat$(EXT) - $(LN_SF) lz4$(EXT) $(DESTDIR)$(bindir)/unlz4$(EXT) -+ifeq ($(ENABLE_DOCS),1) - @echo Installing man pages in $(DESTDIR)$(man1dir) -+ $(INSTALL_DIR) $(DESTDIR)$(man1dir)/ - $(INSTALL_DATA) lz4.1 $(DESTDIR)$(man1dir)/lz4.1 - $(LN_SF) lz4.1 $(DESTDIR)$(man1dir)/lz4c.1 - $(LN_SF) lz4.1 $(DESTDIR)$(man1dir)/lz4cat.1 - $(LN_SF) lz4.1 $(DESTDIR)$(man1dir)/unlz4.1 -+endif - @echo lz4 installation completed - - uninstall: -@@ -189,10 +195,12 @@ - $(RM) $(DESTDIR)$(bindir)/unlz4$(EXT) - $(RM) $(DESTDIR)$(bindir)/lz4$(EXT) - $(RM) $(DESTDIR)$(bindir)/lz4c$(EXT) -+ifeq ($(ENABLE_DOCS),1) - $(RM) $(DESTDIR)$(man1dir)/lz4.1 - $(RM) $(DESTDIR)$(man1dir)/lz4c.1 - $(RM) $(DESTDIR)$(man1dir)/lz4cat.1 - $(RM) $(DESTDIR)$(man1dir)/unlz4.1 -+endif - @echo lz4 programs successfully uninstalled - - endif diff --git a/tools/lz4/patches/002-makefile-install-links-from-same-dir.patch b/tools/lz4/patches/002-makefile-install-links-from-same-dir.patch deleted file mode 100644 index 159dc67f1a..0000000000 --- a/tools/lz4/patches/002-makefile-install-links-from-same-dir.patch +++ /dev/null @@ -1,71 +0,0 @@ -diff -ur a/lib/Makefile b/lib/Makefile ---- a/lib/Makefile 2022-12-04 23:49:06.336839263 -0800 -+++ b/lib/Makefile 2022-12-05 00:00:59.172307488 -0800 -@@ -195,8 +195,8 @@ - $(INSTALL_PROGRAM) dll/$(LIBLZ4_EXP) $(DESTDIR)$(libdir) - else - $(INSTALL_PROGRAM) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir) -- $(LN_SF) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_MAJOR) -- $(LN_SF) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT) -+ (cd $(DESTDIR)$(libdir) && $(LN_SF) liblz4.$(SHARED_EXT_VER) liblz4.$(SHARED_EXT_MAJOR)) -+ (cd $(DESTDIR)$(libdir) && $(LN_SF) liblz4.$(SHARED_EXT_MAJOR) liblz4.$(SHARED_EXT)) - endif - endif - @echo Installing headers in $(DESTDIR)$(includedir) -diff -ur a/Makefile b/Makefile ---- a/Makefile 2022-12-04 23:49:06.336839263 -0800 -+++ b/Makefile 2022-12-04 23:42:09.693836654 -0800 -@@ -77,12 +77,12 @@ - - .PHONY: clean - clean: -- $(MAKE) -C $(LZ4DIR) $@ > $(VOID) -- $(MAKE) -C $(PRGDIR) $@ > $(VOID) -- $(MAKE) -C $(TESTDIR) $@ > $(VOID) -- $(MAKE) -C $(EXDIR) $@ > $(VOID) -- $(MAKE) -C $(FUZZDIR) $@ > $(VOID) -- $(MAKE) -C contrib/gen_manual $@ > $(VOID) -+ $(MAKE) -C $(LZ4DIR) $@ -+ $(MAKE) -C $(PRGDIR) $@ -+ $(MAKE) -C $(TESTDIR) $@ -+ $(MAKE) -C $(EXDIR) $@ -+ $(MAKE) -C $(FUZZDIR) $@ -+ $(MAKE) -C contrib/gen_manual $@ - $(RM) lz4$(EXT) - $(RM) -r $(CMAKE_BUILD_DIR) - @echo Cleaning completed -diff -ur a/programs/Makefile b/programs/Makefile ---- a/programs/Makefile 2022-12-04 23:49:06.336839263 -0800 -+++ b/programs/Makefile 2022-12-04 23:42:30.849582910 -0800 -@@ -138,7 +138,7 @@ - ifeq ($(WINBASED),yes) - $(RM) *.rc - endif -- $(MAKE) -C $(LZ4DIR) $@ > $(VOID) -+ $(MAKE) -C $(LZ4DIR) $@ - $(RM) core *.o *.test tmp* \ - lz4$(EXT) lz4c$(EXT) lz4c32$(EXT) lz4-wlib$(EXT) \ - unlz4$(EXT) lz4cat$(EXT) -@@ -177,16 +177,16 @@ - @echo Installing binaries in $(DESTDIR)$(bindir) - $(INSTALL_DIR) $(DESTDIR)$(bindir)/ - $(INSTALL_PROGRAM) lz4$(EXT) $(DESTDIR)$(bindir)/lz4$(EXT) -- $(LN_SF) lz4$(EXT) $(DESTDIR)$(bindir)/lz4c$(EXT) -- $(LN_SF) lz4$(EXT) $(DESTDIR)$(bindir)/lz4cat$(EXT) -- $(LN_SF) lz4$(EXT) $(DESTDIR)$(bindir)/unlz4$(EXT) -+ (cd $(DESTDIR)$(bindir) && $(LN_SF) lz4$(EXT) lz4c$(EXT)) -+ (cd $(DESTDIR)$(bindir) && $(LN_SF) lz4$(EXT) lz4cat$(EXT)) -+ (cd $(DESTDIR)$(bindir) && $(LN_SF) lz4$(EXT) unlz4$(EXT)) - ifeq ($(ENABLE_DOCS),1) - @echo Installing man pages in $(DESTDIR)$(man1dir) - $(INSTALL_DIR) $(DESTDIR)$(man1dir)/ - $(INSTALL_DATA) lz4.1 $(DESTDIR)$(man1dir)/lz4.1 -- $(LN_SF) lz4.1 $(DESTDIR)$(man1dir)/lz4c.1 -- $(LN_SF) lz4.1 $(DESTDIR)$(man1dir)/lz4cat.1 -- $(LN_SF) lz4.1 $(DESTDIR)$(man1dir)/unlz4.1 -+ (cd $(DESTDIR)$(man1dir) && $(LN_SF) lz4.1 lz4c.1) -+ (cd $(DESTDIR)$(man1dir) && $(LN_SF) lz4.1 lz4cat.1) -+ (cd $(DESTDIR)$(man1dir) && $(LN_SF) lz4.1 unlz4.1) - endif - @echo lz4 installation completed - diff --git a/tools/lzma/patches/001-large_files.patch b/tools/lzma/patches/001-large_files.patch index b95fe9e90f..65603f4976 100644 --- a/tools/lzma/patches/001-large_files.patch +++ b/tools/lzma/patches/001-large_files.patch @@ -1,8 +1,6 @@ -Index: lzma-4.65/CPP/7zip/Compress/LZMA_Alone/makefile.gcc -=================================================================== ---- lzma-4.65.orig/CPP/7zip/Compress/LZMA_Alone/makefile.gcc 2009-05-15 23:33:51.000000000 +0200 -+++ lzma-4.65/CPP/7zip/Compress/LZMA_Alone/makefile.gcc 2009-06-01 22:00:54.000000000 +0200 -@@ -3,7 +3,7 @@ +--- a/CPP/7zip/Compress/LZMA_Alone/makefile.gcc ++++ b/CPP/7zip/Compress/LZMA_Alone/makefile.gcc +@@ -3,7 +3,7 @@ CXX = g++ -O2 -Wall CXX_C = gcc -O2 -Wall LIB = -lm RM = rm -f diff --git a/tools/lzma/patches/002-lzmp.patch b/tools/lzma/patches/002-lzmp.patch index 72d881cdb2..f1d45f45ff 100644 --- a/tools/lzma/patches/002-lzmp.patch +++ b/tools/lzma/patches/002-lzmp.patch @@ -1,7 +1,5 @@ -Index: lzma-4.65/CPP/7zip/Compress/LZMA_Alone/lzmp.cpp -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ lzma-4.65/CPP/7zip/Compress/LZMA_Alone/lzmp.cpp 2009-06-01 22:01:10.000000000 +0200 +--- /dev/null ++++ b/CPP/7zip/Compress/LZMA_Alone/lzmp.cpp @@ -0,0 +1,895 @@ +/* + * LZMA command line tool similar to gzip to encode and decode LZMA files. @@ -898,10 +896,8 @@ Index: lzma-4.65/CPP/7zip/Compress/LZMA_Alone/lzmp.cpp + return STATUS_OK; +} + -Index: lzma-4.65/CPP/7zip/Compress/LZMA_Alone/Exception.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ lzma-4.65/CPP/7zip/Compress/LZMA_Alone/Exception.h 2009-06-01 22:01:10.000000000 +0200 +--- /dev/null ++++ b/CPP/7zip/Compress/LZMA_Alone/Exception.h @@ -0,0 +1,45 @@ +/* A couple of exceptions for lzmp. + * @@ -948,10 +944,8 @@ Index: lzma-4.65/CPP/7zip/Compress/LZMA_Alone/Exception.h + +#endif + -Index: lzma-4.65/CPP/7zip/Compress/LZMA_Alone/makefile.gcc -=================================================================== ---- lzma-4.65.orig/CPP/7zip/Compress/LZMA_Alone/makefile.gcc 2009-06-01 22:00:54.000000000 +0200 -+++ lzma-4.65/CPP/7zip/Compress/LZMA_Alone/makefile.gcc 2009-06-01 22:06:13.000000000 +0200 +--- a/CPP/7zip/Compress/LZMA_Alone/makefile.gcc ++++ b/CPP/7zip/Compress/LZMA_Alone/makefile.gcc @@ -1,9 +1,10 @@ -PROG = lzma +PROG = lzma_alone @@ -965,7 +959,7 @@ Index: lzma-4.65/CPP/7zip/Compress/LZMA_Alone/makefile.gcc ifdef SystemDrive IS_MINGW = 1 -@@ -45,12 +46,35 @@ +@@ -45,12 +46,35 @@ OBJS = \ Lzma86Dec.o \ Lzma86Enc.o \ @@ -1002,17 +996,15 @@ Index: lzma-4.65/CPP/7zip/Compress/LZMA_Alone/makefile.gcc LzmaAlone.o: LzmaAlone.cpp $(CXX) $(CFLAGS) LzmaAlone.cpp -@@ -131,5 +153,5 @@ +@@ -131,5 +155,5 @@ Lzma86Enc.o: ../../../../C/LzmaUtil/Lzma $(CXX_C) $(CFLAGS) ../../../../C/LzmaUtil/Lzma86Enc.c clean: - -$(RM) $(PROG) $(OBJS) + -$(RM) $(PROG) $(PROG2) $(OBJS) -Index: lzma-4.65/CPP/7zip/Compress/LZMA_Alone/lzma_version.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ lzma-4.65/CPP/7zip/Compress/LZMA_Alone/lzma_version.h 2009-06-01 22:01:10.000000000 +0200 +--- /dev/null ++++ b/CPP/7zip/Compress/LZMA_Alone/lzma_version.h @@ -0,0 +1,31 @@ +#ifndef LZMA_VERSION_H +#define LZMA_VERSION_H @@ -1045,11 +1037,9 @@ Index: lzma-4.65/CPP/7zip/Compress/LZMA_Alone/lzma_version.h + "named COPYING.\n"; + +#endif /* ifndef LZMA_VERSION_H */ -Index: lzma-4.65/CPP/Common/C_FileIO.h -=================================================================== ---- lzma-4.65.orig/CPP/Common/C_FileIO.h 2009-05-15 23:33:51.000000000 +0200 -+++ lzma-4.65/CPP/Common/C_FileIO.h 2009-06-01 22:06:56.000000000 +0200 -@@ -24,6 +24,7 @@ +--- a/CPP/Common/C_FileIO.h ++++ b/CPP/Common/C_FileIO.h +@@ -24,6 +24,7 @@ public: bool Close(); bool GetLength(UInt64 &length) const; off_t Seek(off_t distanceToMove, int moveMethod) const; diff --git a/tools/lzma/patches/003-compile_fixes.patch b/tools/lzma/patches/003-compile_fixes.patch index 49ae66b9c4..06f7a54aef 100644 --- a/tools/lzma/patches/003-compile_fixes.patch +++ b/tools/lzma/patches/003-compile_fixes.patch @@ -1,7 +1,6 @@ -diff -urN lzma-4.65/CPP/7zip/Common/FileStreams.h lzma-4.65.new/CPP/7zip/Common/FileStreams.h ---- lzma-4.65/CPP/7zip/Common/FileStreams.h 2009-05-15 23:33:51.000000000 +0200 -+++ lzma-4.65.new/CPP/7zip/Common/FileStreams.h 2009-06-01 22:30:01.000000000 +0200 -@@ -72,6 +72,7 @@ +--- a/CPP/7zip/Common/FileStreams.h ++++ b/CPP/7zip/Common/FileStreams.h +@@ -72,6 +72,7 @@ class COutFileStream: public IOutStream, public CMyUnknownImp { @@ -9,10 +8,9 @@ diff -urN lzma-4.65/CPP/7zip/Common/FileStreams.h lzma-4.65.new/CPP/7zip/Common/ #ifdef USE_WIN_FILE NWindows::NFile::NIO::COutFile File; #else -diff -urN lzma-4.65/CPP/Common/MyWindows.h lzma-4.65.new/CPP/Common/MyWindows.h ---- lzma-4.65/CPP/Common/MyWindows.h 2009-05-15 23:33:51.000000000 +0200 -+++ lzma-4.65.new/CPP/Common/MyWindows.h 2009-06-01 22:29:26.000000000 +0200 -@@ -101,8 +101,11 @@ +--- a/CPP/Common/MyWindows.h ++++ b/CPP/Common/MyWindows.h +@@ -101,8 +101,11 @@ typedef LONG SCODE; #ifdef __cplusplus diff --git a/tools/lzop/patches/001-add-cmake-ENABLE_DOCS-configurable.patch b/tools/lzop/patches/001-add-cmake-ENABLE_DOCS-configurable.patch index 01ebd33a39..27af782c1c 100644 --- a/tools/lzop/patches/001-add-cmake-ENABLE_DOCS-configurable.patch +++ b/tools/lzop/patches/001-add-cmake-ENABLE_DOCS-configurable.patch @@ -1,6 +1,6 @@ ---- a/CMakeLists.txt 2017-08-10 04:19:45.000000000 -0700 -+++ b/CMakeLists.txt 2022-11-28 17:21:03.453548350 -0800 -@@ -50,6 +50,9 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -50,6 +50,9 @@ endif() project(lzop VERSION 1.04 LANGUAGES C) @@ -10,7 +10,7 @@ # install directories if(NOT CMAKE_INSTALL_PREFIX) message(FATAL_ERROR "ERROR: CMAKE_INSTALL_PREFIX is not defined.") -@@ -186,9 +189,11 @@ +@@ -186,9 +189,11 @@ if(DEFINED CMAKE_INSTALL_FULL_LIBDIR) install(TARGETS lzop DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}") diff --git a/tools/missing-macros/Makefile b/tools/missing-macros/Makefile index 1e423621bd..15a1cc9b97 100644 --- a/tools/missing-macros/Makefile +++ b/tools/missing-macros/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=missing-macros -PKG_RELEASE:=11 +PKG_RELEASE:=12 include $(INCLUDE_DIR)/host-build.mk @@ -20,9 +20,14 @@ endef define Host/Install $(INSTALL_DIR) $(STAGING_DIR_HOST)/share/aclocal - $(INSTALL_DATA) ./src/m4/*.m4 $(STAGING_DIR_HOST)/share/aclocal/ + $(INSTALL_DATA) $(HOST_BUILD_DIR)/m4/*.m4 $(STAGING_DIR_HOST)/share/aclocal/ $(INSTALL_DIR) $(STAGING_DIR_HOST)/bin - $(INSTALL_BIN) ./src/bin/* $(STAGING_DIR_HOST)/bin/ + $(INSTALL_BIN) $(HOST_BUILD_DIR)/bin/* $(STAGING_DIR_HOST)/bin/ + $(LN) makeinfo $(STAGING_DIR_HOST)/bin/texi2any + $(LN) makeinfo $(STAGING_DIR_HOST)/bin/texi2pdf + $(LN) makeinfo $(STAGING_DIR_HOST)/bin/texi2dvi + $(LN) makeinfo $(STAGING_DIR_HOST)/bin/pdftexi2dvi + $(LN) makeinfo $(STAGING_DIR_HOST)/bin/texi2html endef $(eval $(call HostBuild)) diff --git a/tools/mkimage/Makefile b/tools/mkimage/Makefile index ae744f9bf3..6d2cc5f764 100644 --- a/tools/mkimage/Makefile +++ b/tools/mkimage/Makefile @@ -7,14 +7,14 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mkimage -PKG_VERSION:=2024.01 +PKG_VERSION:=2024.04 PKG_SOURCE:=u-boot-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:= \ https://mirror.cyberbits.eu/u-boot \ https://ftp.denx.de/pub/u-boot \ ftp://ftp.denx.de/pub/u-boot -PKG_HASH:=b99611f1ed237bf3541bdc8434b68c96a6e05967061f992443cb30aabebef5b3 +PKG_HASH:=18a853fe39fad7ad03a90cc2d4275aeaed6da69735defac3492b80508843dd4a HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/u-boot-$(PKG_VERSION) diff --git a/tools/mkimage/patches/030-allow-to-use-different-magic.patch b/tools/mkimage/patches/030-allow-to-use-different-magic.patch index f2f57965f6..bcbdc4d6cd 100644 --- a/tools/mkimage/patches/030-allow-to-use-different-magic.patch +++ b/tools/mkimage/patches/030-allow-to-use-different-magic.patch @@ -24,7 +24,7 @@ This patch makes it possible to set a custom image magic. " -a ==> set load address to 'addr' (hex)\n" " -e ==> set entry point to 'ep' (hex)\n" " -n ==> set image name to 'name'\n" -@@ -159,7 +161,7 @@ static int add_content(int type, const c +@@ -160,7 +162,7 @@ static int add_content(int type, const c } static const char optstring[] = @@ -33,7 +33,7 @@ This patch makes it possible to set a custom image magic. static const struct option longopts[] = { { "load-address", required_argument, NULL, 'a' }, -@@ -302,6 +304,14 @@ static void process_args(int argc, char +@@ -303,6 +305,14 @@ static void process_args(int argc, char case 'l': params.lflag = 1; break; diff --git a/tools/mkimage/patches/095-tools-disable-TOOLS_FIT_FULL_CHECK.patch b/tools/mkimage/patches/095-tools-disable-TOOLS_FIT_FULL_CHECK.patch index f2e3b9b053..ed6824b11a 100644 --- a/tools/mkimage/patches/095-tools-disable-TOOLS_FIT_FULL_CHECK.patch +++ b/tools/mkimage/patches/095-tools-disable-TOOLS_FIT_FULL_CHECK.patch @@ -14,7 +14,7 @@ https://github.com/u-boot/u-boot/commit/3f04db891a353f4b127ed57279279f851c6b4917 --- a/tools/Kconfig +++ b/tools/Kconfig -@@ -31,7 +31,7 @@ config TOOLS_FIT +@@ -36,7 +36,7 @@ config TOOLS_FIT Enable FIT support in the tools builds. config TOOLS_FIT_FULL_CHECK diff --git a/tools/mold/Makefile b/tools/mold/Makefile index b2a3231e67..7a7e2321b1 100644 --- a/tools/mold/Makefile +++ b/tools/mold/Makefile @@ -3,12 +3,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mold -PKG_VERSION:=2.30.0 +PKG_VERSION:=2.31.0 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL_FILE:=v$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://github.com/rui314/mold/archive/refs/tags -PKG_HASH:=6e5178ccafe828fdb4ba0dd841d083ff6004d3cb41e56485143eb64c716345fd +PKG_HASH:=3dc3af83a5d22a4b29971bfad17261851d426961c665480e2ca294e5c74aa1e5 include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/cmake.mk diff --git a/tools/padjffs2/Makefile b/tools/padjffs2/Makefile index 422d14db30..b893fadce5 100644 --- a/tools/padjffs2/Makefile +++ b/tools/padjffs2/Makefile @@ -13,8 +13,7 @@ PKG_RELEASE:=1 include $(INCLUDE_DIR)/host-build.mk define Host/Prepare - mkdir -p $(HOST_BUILD_DIR) - $(CP) ./src/* $(HOST_BUILD_DIR)/ + $(call Host/Prepare/Default) find $(HOST_BUILD_DIR) -name .svn | $(XARGS) rm -rf endef diff --git a/tools/patch/patches/050-CVE-2019-13636.patch b/tools/patch/patches/050-CVE-2019-13636.patch index e62c3d4175..d819838bba 100644 --- a/tools/patch/patches/050-CVE-2019-13636.patch +++ b/tools/patch/patches/050-CVE-2019-13636.patch @@ -14,8 +14,6 @@ with O_CREAT | O_EXCL to avoid following symlinks in that case as well. src/util.c | 14 +++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) -diff --git a/src/inp.c b/src/inp.c -index 32d0919..22d7473 100644 --- a/src/inp.c +++ b/src/inp.c @@ -238,8 +238,13 @@ plan_a (char const *filename) @@ -52,11 +50,9 @@ index 32d0919..22d7473 100644 || ! (ifp = fdopen (ifd, binary_transput ? "rb" : "r"))) pfatal ("Can't open file %s", quotearg (filename)); if (TMPINNAME_needs_removal) -diff --git a/src/util.c b/src/util.c -index 1cc08ba..fb38307 100644 --- a/src/util.c +++ b/src/util.c -@@ -388,7 +388,7 @@ create_backup (char const *to, const struct stat *to_st, bool leave_original) +@@ -388,7 +388,7 @@ create_backup (char const *to, const str try_makedirs_errno = ENOENT; safe_unlink (bakname); @@ -65,7 +61,7 @@ index 1cc08ba..fb38307 100644 { if (errno != try_makedirs_errno) pfatal ("Can't create file %s", quotearg (bakname)); -@@ -579,10 +579,13 @@ create_file (char const *file, int open_flags, mode_t mode, +@@ -579,10 +579,13 @@ create_file (char const *file, int open_ static void copy_to_fd (const char *from, int tofd) { @@ -80,7 +76,7 @@ index 1cc08ba..fb38307 100644 pfatal ("Can't reopen file %s", quotearg (from)); while ((i = read (fromfd, buf, bufsize)) != 0) { -@@ -625,6 +628,8 @@ copy_file (char const *from, char const *to, struct stat *tost, +@@ -625,6 +628,8 @@ copy_file (char const *from, char const else { assert (S_ISREG (mode)); @@ -89,7 +85,7 @@ index 1cc08ba..fb38307 100644 tofd = create_file (to, O_WRONLY | O_BINARY | to_flags, mode, to_dir_known_to_exist); copy_to_fd (from, tofd); -@@ -640,9 +645,12 @@ copy_file (char const *from, char const *to, struct stat *tost, +@@ -640,9 +645,12 @@ copy_file (char const *from, char const void append_to_file (char const *from, char const *to) { @@ -103,6 +99,3 @@ index 1cc08ba..fb38307 100644 pfatal ("Can't reopen file %s", quotearg (to)); copy_to_fd (from, tofd); if (close (tofd) != 0) --- -cgit v1.0-41-gc330 - diff --git a/tools/patch/patches/060-CVE-2019-13638.patch b/tools/patch/patches/060-CVE-2019-13638.patch index 38caff628a..590cf186e7 100644 --- a/tools/patch/patches/060-CVE-2019-13638.patch +++ b/tools/patch/patches/060-CVE-2019-13638.patch @@ -9,11 +9,9 @@ command to avoid quoting vulnerabilities. src/pch.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -diff --git a/src/pch.c b/src/pch.c -index 4fd5a05..16e001a 100644 --- a/src/pch.c +++ b/src/pch.c -@@ -2459,9 +2459,6 @@ do_ed_script (char const *inname, char const *outname, +@@ -2459,9 +2459,6 @@ do_ed_script (char const *inname, char c *outname_needs_removal = true; copy_file (inname, outname, 0, exclusive, instat.st_mode, true); } @@ -23,7 +21,7 @@ index 4fd5a05..16e001a 100644 fflush (stdout); pid = fork(); -@@ -2470,7 +2467,8 @@ do_ed_script (char const *inname, char const *outname, +@@ -2470,7 +2467,8 @@ do_ed_script (char const *inname, char c else if (pid == 0) { dup2 (tmpfd, 0); @@ -33,6 +31,3 @@ index 4fd5a05..16e001a 100644 _exit (2); } else --- -cgit v1.0-41-gc330 - diff --git a/tools/pkgconf/Makefile b/tools/pkgconf/Makefile index 517b8d847b..533af502e3 100644 --- a/tools/pkgconf/Makefile +++ b/tools/pkgconf/Makefile @@ -7,11 +7,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=pkgconf -PKG_VERSION:=2.1.1 +PKG_VERSION:=2.2.0 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://distfiles.dereferenced.org/pkgconf -PKG_HASH:=1a00b7fa08c7b506a24c40f7cc8d9e0e59be748d731af8f7aa0b4d722bd8ccbe +PKG_HASH:=28f8dfc279a10ef66148befa3f6eb266e5f3570316600208ed50e9781c7269d8 PKG_CPE_ID:=cpe:/a:pkgconf:pkgconf diff --git a/tools/pkgconf/files/pkg-config b/tools/pkgconf/files/pkg-config index 65e0fb09f5..2e4dac9073 100755 --- a/tools/pkgconf/files/pkg-config +++ b/tools/pkgconf/files/pkg-config @@ -4,6 +4,8 @@ ${STAGING_DIR_HOST}/bin/pkg-config.real \ --keep-system-cflags \ --keep-system-libs \ --define-variable=prefix="${STAGING_PREFIX}" \ +--define-variable=prefix_host="${STAGING_DIR_HOST}" \ +--define-variable=prefix_hostpkg="${STAGING_DIR_HOSTPKG}" \ --define-variable=exec_prefix="${STAGING_PREFIX}" \ --define-variable=bindir="${STAGING_PREFIX}/bin" \ $PKG_CONFIG_EXTRAARGS "$@" diff --git a/tools/quilt/Makefile b/tools/quilt/Makefile index c16f989b5d..73d1db983b 100644 --- a/tools/quilt/Makefile +++ b/tools/quilt/Makefile @@ -7,11 +7,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=quilt -PKG_VERSION:=0.67 +PKG_VERSION:=0.68 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@SAVANNAH/quilt -PKG_HASH:=3be3be0987e72a6c364678bb827e3e1fcc10322b56bc5f02b576698f55013cc2 +PKG_HASH:=fe8c09de03c106e85b3737c8f03ade147c956b79ed7af485a1c8a3858db38426 include $(INCLUDE_DIR)/host-build.mk diff --git a/tools/tar/patches/001-Avoid-excess-lseek-etc.patch b/tools/tar/patches/001-Avoid-excess-lseek-etc.patch new file mode 100644 index 0000000000..42a0c5be6b --- /dev/null +++ b/tools/tar/patches/001-Avoid-excess-lseek-etc.patch @@ -0,0 +1,491 @@ +From 66be5a789e70f911170017754fc51e499998f90e Mon Sep 17 00:00:00 2001 +From: Paul Eggert <eggert@cs.ucla.edu> +Date: Sun, 14 Aug 2022 16:32:26 -0700 +Subject: [PATCH] Avoid excess lseek etc. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +* src/buffer.c, src/delete.c: Do not include system-ioctl.h. +* src/buffer.c (guess_seekable_archive): Remove. This is now done +by get_archive_status, in a different way. +(get_archive_status): New function that gets archive_stat +unless remote, and sets seekable_archive etc. +(_open_archive): Prefer bool for boolean. +(_open_archive, new_volume): Get archive status consistently +by calling get_archive_status in both places. +* src/buffer.c (backspace_output): +* src/compare.c (verify_volume): +* src/delete.c (move_archive): +Let mtioseek worry about mtio. +* src/common.h (archive_stat): New global, replacing ar_dev and +ar_ino. All uses changed. +* src/delete.c (move_archive): Check for integer overflow. +Also report overflow if the archive position would go negative. +* src/system.c: Include system-ioctl.h, for MTIOCTOP etc. +(mtioseek): New function, which also checks for integer overflow. +(sys_save_archive_dev_ino): Remove. +(archive_stat): Now +(sys_get_archive_stat): Also initialize mtioseekable_archive. +(sys_file_is_archive): Don’t return true if the archive is /dev/null +since it’s not a problem in that case. +(sys_detect_dev_null_output): Cache dev_null_stat. + +doc: omit MS-DOS mentions in doc +It’s really FAT32 we’re worried about now, not MS-DOS. +And doschk is no longer a GNU program. +--- + src/buffer.c | 99 ++++++++++++++++++--------------------------------- + src/common.h | 10 +++--- + src/compare.c | 31 ++++------------ + src/delete.c | 51 +++++++++----------------- + src/system.c | 81 +++++++++++++++++++++++++++-------------- + 5 files changed, 119 insertions(+), 153 deletions(-) + +--- a/src/buffer.c ++++ b/src/buffer.c +@@ -20,7 +20,6 @@ + Written by John Gilmore, on 1985-08-25. */ + + #include <system.h> +-#include <system-ioctl.h> + + #include <signal.h> + +@@ -420,37 +419,6 @@ check_compressed_archive (bool *pshort) + return ct_none; + } + +-/* Guess if the archive is seekable. */ +-static void +-guess_seekable_archive (void) +-{ +- struct stat st; +- +- if (subcommand_option == DELETE_SUBCOMMAND) +- { +- /* The current code in delete.c is based on the assumption that +- skip_member() reads all data from the archive. So, we should +- make sure it won't use seeks. On the other hand, the same code +- depends on the ability to backspace a record in the archive, +- so setting seekable_archive to false is technically incorrect. +- However, it is tested only in skip_member(), so it's not a +- problem. */ +- seekable_archive = false; +- } +- +- if (seek_option != -1) +- { +- seekable_archive = !!seek_option; +- return; +- } +- +- if (!multi_volume_option && !use_compress_program_option +- && fstat (archive, &st) == 0) +- seekable_archive = S_ISREG (st.st_mode); +- else +- seekable_archive = false; +-} +- + /* Open an archive named archive_name_array[0]. Detect if it is + a compressed archive of known type and use corresponding decompression + program if so */ +@@ -702,12 +670,41 @@ check_tty (enum access_mode mode) + } + } + ++/* Fetch the status of the archive, accessed via WANTED_STATUS. */ ++ ++static void ++get_archive_status (enum access_mode wanted_access, bool backed_up_flag) ++{ ++ if (!sys_get_archive_stat ()) ++ { ++ int saved_errno = errno; ++ ++ if (backed_up_flag) ++ undo_last_backup (); ++ errno = saved_errno; ++ open_fatal (archive_name_array[0]); ++ } ++ ++ seekable_archive ++ = (! (multi_volume_option || use_compress_program_option) ++ && (seek_option < 0 ++ ? (_isrmt (archive) ++ || S_ISREG (archive_stat.st_mode) ++ || S_ISBLK (archive_stat.st_mode)) ++ : seek_option)); ++ ++ if (wanted_access != ACCESS_READ) ++ sys_detect_dev_null_output (); ++ ++ SET_BINARY_MODE (archive); ++} ++ + /* Open an archive file. The argument specifies whether we are + reading or writing, or both. */ + static void + _open_archive (enum access_mode wanted_access) + { +- int backed_up_flag = 0; ++ bool backed_up_flag = false; + + if (record_size == 0) + FATAL_ERROR ((0, 0, _("Invalid value for record_size"))); +@@ -796,15 +793,13 @@ _open_archive (enum access_mode wanted_a + { + case ACCESS_READ: + archive = open_compressed_archive (); +- if (archive >= 0) +- guess_seekable_archive (); + break; + + case ACCESS_WRITE: + if (backup_option) + { + maybe_backup_file (archive_name_array[0], 1); +- backed_up_flag = 1; ++ backed_up_flag = true; + } + if (verify_option) + archive = rmtopen (archive_name_array[0], O_RDWR | O_CREAT | O_BINARY, +@@ -832,20 +827,7 @@ _open_archive (enum access_mode wanted_a + break; + } + +- if (archive < 0 +- || (! _isrmt (archive) && !sys_get_archive_stat ())) +- { +- int saved_errno = errno; +- +- if (backed_up_flag) +- undo_last_backup (); +- errno = saved_errno; +- open_fatal (archive_name_array[0]); +- } +- +- sys_detect_dev_null_output (); +- sys_save_archive_dev_ino (); +- SET_BINARY_MODE (archive); ++ get_archive_status (wanted_access, backed_up_flag); + + switch (wanted_access) + { +@@ -1048,18 +1030,8 @@ flush_archive (void) + static void + backspace_output (void) + { +-#ifdef MTIOCTOP +- { +- struct mtop operation; +- +- operation.mt_op = MTBSR; +- operation.mt_count = 1; +- if (rmtioctl (archive, MTIOCTOP, (char *) &operation) >= 0) +- return; +- if (errno == EIO && rmtioctl (archive, MTIOCTOP, (char *) &operation) >= 0) +- return; +- } +-#endif ++ if (mtioseek (false, -1)) ++ return; + + { + off_t position = rmtlseek (archive, (off_t) 0, SEEK_CUR); +@@ -1372,7 +1344,6 @@ new_volume (enum access_mode mode) + case ACCESS_READ: + archive = rmtopen (*archive_name_cursor, O_RDONLY, MODE_RW, + rsh_command_option); +- guess_seekable_archive (); + break; + + case ACCESS_WRITE: +@@ -1397,7 +1368,7 @@ new_volume (enum access_mode mode) + goto tryagain; + } + +- SET_BINARY_MODE (archive); ++ get_archive_status (mode, false); + + return true; + } +--- a/src/common.h ++++ b/src/common.h +@@ -397,9 +397,8 @@ struct name + char *caname; /* canonical name */ + }; + +-/* Obnoxious test to see if dimwit is trying to dump the archive. */ +-GLOBAL dev_t ar_dev; +-GLOBAL ino_t ar_ino; ++/* Status of archive file, or all zeros if remote. */ ++GLOBAL struct stat archive_stat; + + /* Flags for reading, searching, and fstatatting files. */ + GLOBAL int open_read_flags; +@@ -407,6 +406,9 @@ GLOBAL int open_searchdir_flags; + GLOBAL int fstatat_flags; + + GLOBAL int seek_option; ++ ++/* true if archive if lseek should be used on the archive, 0 if it ++ should not be used. */ + GLOBAL bool seekable_archive; + + GLOBAL dev_t root_device; +@@ -894,7 +896,6 @@ void xheader_xattr_add (struct tar_stat_ + /* Module system.c */ + + void sys_detect_dev_null_output (void); +-void sys_save_archive_dev_ino (void); + void sys_wait_for_child (pid_t, bool); + void sys_spawn_shell (void); + bool sys_compare_uid (struct stat *a, struct stat *b); +@@ -912,6 +913,7 @@ int sys_exec_info_script (const char **a + void sys_exec_checkpoint_script (const char *script_name, + const char *archive_name, + int checkpoint_number); ++bool mtioseek (bool count_files, off_t count); + + /* Module compare.c */ + void report_difference (struct tar_stat_info *st, const char *message, ...) +--- a/src/compare.c ++++ b/src/compare.c +@@ -566,31 +566,12 @@ verify_volume (void) + ioctl (archive, FDFLUSH); + #endif + +-#ifdef MTIOCTOP +- { +- struct mtop operation; +- int status; +- +- operation.mt_op = MTBSF; +- operation.mt_count = 1; +- if (status = rmtioctl (archive, MTIOCTOP, (char *) &operation), status < 0) +- { +- if (errno != EIO +- || (status = rmtioctl (archive, MTIOCTOP, (char *) &operation), +- status < 0)) +- { +-#endif +- if (rmtlseek (archive, (off_t) 0, SEEK_SET) != 0) +- { +- /* Lseek failed. Try a different method. */ +- seek_warn (archive_name_array[0]); +- return; +- } +-#ifdef MTIOCTOP +- } +- } +- } +-#endif ++ if (!mtioseek (true, -1) && rmtlseek (archive, 0, SEEK_SET) != 0) ++ { ++ /* Lseek failed. Try a different method. */ ++ seek_warn (archive_name_array[0]); ++ return; ++ } + + access_mode = ACCESS_READ; + now_verifying = 1; +--- a/src/delete.c ++++ b/src/delete.c +@@ -18,7 +18,6 @@ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + + #include <system.h> +-#include <system-ioctl.h> + + #include "common.h" + #include <rmt.h> +@@ -50,41 +49,25 @@ move_archive (off_t count) + if (count == 0) + return; + +-#ifdef MTIOCTOP +- { +- struct mtop operation; +- +- if (count < 0 +- ? (operation.mt_op = MTBSR, +- operation.mt_count = -count, +- operation.mt_count == -count) +- : (operation.mt_op = MTFSR, +- operation.mt_count = count, +- operation.mt_count == count)) +- { +- if (0 <= rmtioctl (archive, MTIOCTOP, (char *) &operation)) +- return; ++ if (mtioseek (false, count)) ++ return; + +- if (errno == EIO +- && 0 <= rmtioctl (archive, MTIOCTOP, (char *) &operation)) ++ off_t position0 = rmtlseek (archive, 0, SEEK_CUR), position = 0; ++ if (0 <= position0) ++ { ++ off_t increment; ++ if (INT_MULTIPLY_WRAPV (record_size, count, &increment) ++ || INT_ADD_WRAPV (position0, increment, &position) ++ || position < 0) ++ { ++ ERROR ((0, EOVERFLOW, "lseek: %s", archive_name_array[0])); + return; +- } +- } +-#endif /* MTIOCTOP */ +- +- { +- off_t position0 = rmtlseek (archive, (off_t) 0, SEEK_CUR); +- off_t increment = record_size * (off_t) count; +- off_t position = position0 + increment; +- +- if (increment / count != record_size +- || (position < position0) != (increment < 0) +- || (position = position < 0 ? 0 : position, +- rmtlseek (archive, position, SEEK_SET) != position)) +- seek_error_details (archive_name_array[0], position); +- +- return; +- } ++ } ++ else if (rmtlseek (archive, position, SEEK_SET) == position) ++ return; ++ } ++ if (!_isrmt (archive)) ++ seek_error_details (archive_name_array[0], position); + } + + /* Write out the record which has been filled. If MOVE_BACK_FLAG, +--- a/src/system.c ++++ b/src/system.c +@@ -16,6 +16,7 @@ + with this program. If not, see <http://www.gnu.org/licenses/>. */ + + #include <system.h> ++#include <system-ioctl.h> + + #include "common.h" + #include <priv-set.h> +@@ -37,6 +38,35 @@ xexec (const char *cmd) + exec_fatal (cmd); + } + ++/* True if the archive is seekable via ioctl and MTIOCTOP, ++ or if it is not known whether it is seekable. ++ False if it is known to be not seekable. */ ++static bool mtioseekable_archive; ++ ++bool ++mtioseek (bool count_files, off_t count) ++{ ++ if (mtioseekable_archive) ++ { ++#ifdef MTIOCTOP ++ struct mtop operation; ++ operation.mt_op = (count_files ++ ? (count < 0 ? MTBSF : MTFSF) ++ : (count < 0 ? MTBSR : MTFSR)); ++ if (! (count < 0 ++ ? INT_SUBTRACT_WRAPV (0, count, &operation.mt_count) ++ : INT_ADD_WRAPV (count, 0, &operation.mt_count)) ++ && (0 <= rmtioctl (archive, MTIOCTOP, &operation) ++ || (errno == EIO ++ && 0 <= rmtioctl (archive, MTIOCTOP, &operation)))) ++ return true; ++#endif ++ ++ mtioseekable_archive = false; ++ } ++ return false; ++} ++ + #if MSDOS + + bool +@@ -52,11 +82,6 @@ sys_file_is_archive (struct tar_stat_inf + } + + void +-sys_save_archive_dev_ino (void) +-{ +-} +- +-void + sys_detect_dev_null_output (void) + { + static char const dev_null[] = "nul"; +@@ -128,31 +153,34 @@ sys_child_open_for_uncompress (void) + + extern union block *record_start; /* FIXME */ + +-static struct stat archive_stat; /* stat block for archive file */ +- + bool + sys_get_archive_stat (void) + { +- return fstat (archive, &archive_stat) == 0; ++ bool remote = _isrmt (archive); ++ mtioseekable_archive = true; ++ if (!remote && 0 <= archive && fstat (archive, &archive_stat) == 0) ++ { ++ if (!S_ISCHR (archive_stat.st_mode)) ++ mtioseekable_archive = false; ++ return true; ++ } ++ else ++ { ++ /* FIXME: This memset should not be needed. It is present only ++ because other parts of tar may incorrectly access ++ archive_stat even if it's not the archive status. */ ++ memset (&archive_stat, 0, sizeof archive_stat); ++ ++ return remote; ++ } + } + + bool + sys_file_is_archive (struct tar_stat_info *p) + { +- return (ar_dev && p->stat.st_dev == ar_dev && p->stat.st_ino == ar_ino); +-} +- +-/* Save archive file inode and device numbers */ +-void +-sys_save_archive_dev_ino (void) +-{ +- if (!_isrmt (archive) && S_ISREG (archive_stat.st_mode)) +- { +- ar_dev = archive_stat.st_dev; +- ar_ino = archive_stat.st_ino; +- } +- else +- ar_dev = 0; ++ return (!dev_null_output && !_isrmt (archive) ++ && p->stat.st_dev == archive_stat.st_dev ++ && p->stat.st_ino == archive_stat.st_ino); + } + + /* Detect if outputting to "/dev/null". */ +@@ -160,14 +188,15 @@ void + sys_detect_dev_null_output (void) + { + static char const dev_null[] = "/dev/null"; +- struct stat dev_null_stat; ++ static struct stat dev_null_stat; + + dev_null_output = (strcmp (archive_name_array[0], dev_null) == 0 + || (! _isrmt (archive) + && S_ISCHR (archive_stat.st_mode) +- && stat (dev_null, &dev_null_stat) == 0 +- && archive_stat.st_dev == dev_null_stat.st_dev +- && archive_stat.st_ino == dev_null_stat.st_ino)); ++ && (dev_null_stat.st_ino != 0 ++ || stat (dev_null, &dev_null_stat) == 0) ++ && archive_stat.st_ino == dev_null_stat.st_ino ++ && archive_stat.st_dev == dev_null_stat.st_dev)); + } + + void diff --git a/tools/tar/patches/002-Fix-delete-bug-with-short-reads.patch b/tools/tar/patches/002-Fix-delete-bug-with-short-reads.patch new file mode 100644 index 0000000000..57c28e4160 --- /dev/null +++ b/tools/tar/patches/002-Fix-delete-bug-with-short-reads.patch @@ -0,0 +1,59 @@ +From f8e14746d2ca72804a4520c059d7bf65ca00c5ac Mon Sep 17 00:00:00 2001 +From: Paul Eggert <eggert@cs.ucla.edu> +Date: Fri, 2 Sep 2022 16:32:27 -0500 +Subject: [PATCH] Fix --delete bug with short reads +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +* gnulib.modules: Add idx. +* src/common.h: Include idx.h. +* src/delete.c (move_archive): Don’t botch short reads. +--- + gnulib.modules | 1 + + src/common.h | 1 + + src/delete.c | 10 ++++++++-- + 3 files changed, 10 insertions(+), 2 deletions(-) + +# diff --git a/gnulib.modules b/gnulib.modules +# index 63e8354a..dac77d61 100644 +# --- a/gnulib.modules +# +++ b/gnulib.modules +# @@ -54,6 +54,7 @@ gettime +# gitlog-to-changelog +# hash +# human +# +idx +# inttostr +# inttypes +# lchown +--- a/src/common.h ++++ b/src/common.h +@@ -58,6 +58,7 @@ + #include <backupfile.h> + #include <exclude.h> + #include <full-write.h> ++#include <idx.h> + #include <modechange.h> + #include <quote.h> + #include <safe-read.h> +--- a/src/delete.c ++++ b/src/delete.c +@@ -55,9 +55,15 @@ move_archive (off_t count) + off_t position0 = rmtlseek (archive, 0, SEEK_CUR), position = 0; + if (0 <= position0) + { +- off_t increment; ++ /* Pretend the starting position is at the first record ++ boundary after POSITION0. This is useful at EOF after ++ a short read. */ ++ idx_t short_size = position0 % record_size; ++ idx_t start_offset = short_size ? record_size - short_size : 0; ++ off_t increment, move_start; + if (INT_MULTIPLY_WRAPV (record_size, count, &increment) +- || INT_ADD_WRAPV (position0, increment, &position) ++ || INT_ADD_WRAPV (position0, start_offset, &move_start) ++ || INT_ADD_WRAPV (move_start, increment, &position) + || position < 0) + { + ERROR ((0, EOVERFLOW, "lseek: %s", archive_name_array[0])); diff --git a/tools/tar/patches/003-Pacify-rtapelib.c-for-GCC-10-and-fix-a-bug-or-two.patch b/tools/tar/patches/003-Pacify-rtapelib.c-for-GCC-10-and-fix-a-bug-or-two.patch new file mode 100644 index 0000000000..9565a01277 --- /dev/null +++ b/tools/tar/patches/003-Pacify-rtapelib.c-for-GCC-10-and-fix-a-bug-or-two.patch @@ -0,0 +1,189 @@ +From 4053ba7cfb5255c0e6832781aebc909666b2e984 Mon Sep 17 00:00:00 2001 +From: Paul Eggert <eggert@cs.ucla.edu> +Date: Sat, 27 Feb 2021 14:39:06 -0800 +Subject: [PATCH] Pacify rtapelib.c for GCC 10 and fix a bug or two +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This patch assumes C99, but that’s OK nowadays. +* lib/rtapelib.c: Include verify.h. +(rmt_open__): Tell GCC that remote_file must be nonnull. +(rmt_read__, rmt_write__, rmt_lseek__, rmt_ioctl__): +Properly size outgoing command buffers instead of guessing 64. +Simplify by using C99 printf formats like %zu, +as that’s a safe assumption nowadays. +(rmt_ioctl__): 3rd arg is now void * not char *, to pacify gcc +-Wcast-align. Fix unlikely bug with short reads: ARGUMENT was +being incremented, whereas later code wanted the original +ARGUMENT. +* paxlib.modules: Add ‘verify’. +--- + lib/rmt.h | 2 +- + lib/rtapelib.c | 64 ++++++++++++++++++++------------------------------ + paxlib.modules | 1 + + 3 files changed, 28 insertions(+), 39 deletions(-) + +--- a/lib/rmt.h ++++ b/lib/rmt.h +@@ -25,7 +25,7 @@ int rmt_close__ (int); + size_t rmt_read__ (int, char *, size_t); + size_t rmt_write__ (int, char *, size_t); + off_t rmt_lseek__ (int, off_t, int); +-int rmt_ioctl__ (int, int, char *); ++int rmt_ioctl__ (int, int, void *); + + extern bool force_local_option; + +--- a/lib/rtapelib.c ++++ b/lib/rtapelib.c +@@ -37,6 +37,7 @@ + + #include <safe-read.h> + #include <full-write.h> ++#include <verify.h> + + /* Try hard to get EOPNOTSUPP defined. 486/ISC has it in net/errno.h, + 3B2/SVR3 has it in sys/inet.h. Otherwise, like on MSDOS, use EINVAL. */ +@@ -424,6 +425,8 @@ rmt_open__ (const char *file_name, int o + } + } + ++ assume (remote_file); ++ + /* FIXME: Should somewhat validate the decoding, here. */ + if (gethostbyname (remote_host) == NULL) + error (EXIT_ON_EXEC_ERROR, 0, _("Cannot connect to %s: resolve failed"), +@@ -567,12 +570,12 @@ rmt_close__ (int handle) + size_t + rmt_read__ (int handle, char *buffer, size_t length) + { +- char command_buffer[COMMAND_BUFFER_SIZE]; ++ char command_buffer[sizeof "R\n" + INT_STRLEN_BOUND (size_t)]; + size_t status; + size_t rlen; + size_t counter; + +- sprintf (command_buffer, "R%lu\n", (unsigned long) length); ++ sprintf (command_buffer, "R%zu\n", length); + if (do_command (handle, command_buffer) == -1 + || (status = get_status (handle)) == SAFE_READ_ERROR + || status > length) +@@ -596,11 +599,11 @@ rmt_read__ (int handle, char *buffer, si + size_t + rmt_write__ (int handle, char *buffer, size_t length) + { +- char command_buffer[COMMAND_BUFFER_SIZE]; ++ char command_buffer[sizeof "W\n" + INT_STRLEN_BOUND (size_t)]; + RETSIGTYPE (*pipe_handler) (int); + size_t written; + +- sprintf (command_buffer, "W%lu\n", (unsigned long) length); ++ sprintf (command_buffer, "W%zu\n", length); + if (do_command (handle, command_buffer) == -1) + return 0; + +@@ -628,17 +631,7 @@ rmt_write__ (int handle, char *buffer, s + off_t + rmt_lseek__ (int handle, off_t offset, int whence) + { +- char command_buffer[COMMAND_BUFFER_SIZE]; +- char operand_buffer[UINTMAX_STRSIZE_BOUND]; +- uintmax_t u = offset < 0 ? - (uintmax_t) offset : (uintmax_t) offset; +- char *p = operand_buffer + sizeof operand_buffer; +- +- *--p = 0; +- do +- *--p = '0' + (int) (u % 10); +- while ((u /= 10) != 0); +- if (offset < 0) +- *--p = '-'; ++ char command_buffer[sizeof "L\n0\n" + INT_STRLEN_BOUND (+offset)]; + + switch (whence) + { +@@ -648,7 +641,8 @@ rmt_lseek__ (int handle, off_t offset, i + default: abort (); + } + +- sprintf (command_buffer, "L%s\n%d\n", p, whence); ++ intmax_t off = offset; ++ sprintf (command_buffer, "L%jd\n%d\n", off, whence); + + if (do_command (handle, command_buffer) == -1) + return -1; +@@ -659,7 +653,7 @@ rmt_lseek__ (int handle, off_t offset, i + /* Perform a raw tape operation on remote tape connection HANDLE. + Return the results of the ioctl, or -1 on error. */ + int +-rmt_ioctl__ (int handle, int operation, char *argument) ++rmt_ioctl__ (int handle, int operation, void *argument) + { + switch (operation) + { +@@ -670,24 +664,16 @@ rmt_ioctl__ (int handle, int operation, + #ifdef MTIOCTOP + case MTIOCTOP: + { +- char command_buffer[COMMAND_BUFFER_SIZE]; +- char operand_buffer[UINTMAX_STRSIZE_BOUND]; +- uintmax_t u = (((struct mtop *) argument)->mt_count < 0 +- ? - (uintmax_t) ((struct mtop *) argument)->mt_count +- : (uintmax_t) ((struct mtop *) argument)->mt_count); +- char *p = operand_buffer + sizeof operand_buffer; +- +- *--p = 0; +- do +- *--p = '0' + (int) (u % 10); +- while ((u /= 10) != 0); +- if (((struct mtop *) argument)->mt_count < 0) +- *--p = '-'; ++ struct mtop *mtop = argument; ++ enum { oplen = INT_STRLEN_BOUND (+mtop->mt_op) }; ++ enum { countlen = INT_STRLEN_BOUND (+mtop->mt_count) }; ++ char command_buffer[sizeof "I\n\n" + oplen + countlen]; + + /* MTIOCTOP is the easy one. Nothing is transferred in binary. */ + +- sprintf (command_buffer, "I%d\n%s\n", +- ((struct mtop *) argument)->mt_op, p); ++ verify (EXPR_SIGNED (mtop->mt_count)); ++ intmax_t count = mtop->mt_count; ++ sprintf (command_buffer, "I%d\n%jd\n", mtop->mt_op, count); + if (do_command (handle, command_buffer) == -1) + return -1; + +@@ -717,9 +703,9 @@ rmt_ioctl__ (int handle, int operation, + return -1; + } + +- for (; status > 0; status -= counter, argument += counter) ++ for (char *p = argument; status > 0; status -= counter, p += counter) + { +- counter = safe_read (READ_SIDE (handle), argument, status); ++ counter = safe_read (READ_SIDE (handle), p, status); + if (counter == SAFE_READ_ERROR || counter == 0) + { + _rmt_shutdown (handle, EIO); +@@ -732,15 +718,17 @@ rmt_ioctl__ (int handle, int operation, + than 256, we will assume that the bytes are swapped and go through + and reverse all the bytes. */ + +- if (((struct mtget *) argument)->MTIO_CHECK_FIELD < 256) ++ struct mtget *mtget = argument; ++ if (mtget->MTIO_CHECK_FIELD < 256) + return 0; + ++ char *buf = argument; + for (counter = 0; counter < status; counter += 2) + { +- char copy = argument[counter]; ++ char copy = buf[counter]; + +- argument[counter] = argument[counter + 1]; +- argument[counter + 1] = copy; ++ buf[counter] = buf[counter + 1]; ++ buf[counter + 1] = copy; + } + + return 0; diff --git a/tools/yafut/Makefile b/tools/yafut/Makefile new file mode 100644 index 0000000000..a7e36e5175 --- /dev/null +++ b/tools/yafut/Makefile @@ -0,0 +1,20 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=yafut +PKG_RELEASE:=1 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=https://github.com/kempniu/yafut.git +PKG_MIRROR_HASH:=9cc6b4c485ce16d44b67ebf79e8bee1e07aecde112da739cf33e8714ac3842e7 +PKG_SOURCE_DATE:=2024-05-13 +PKG_SOURCE_VERSION:=2b45baaf1cced47af8f22dd3acbf1df2f04c7510 + +PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:=LICENSE + +include $(INCLUDE_DIR)/host-build.mk +include $(INCLUDE_DIR)/cmake.mk + +CMAKE_INSTALL:=1 + +$(eval $(call HostBuild)) diff --git a/tools/zlib/Makefile b/tools/zlib/Makefile index f743445678..b1307ef2af 100644 --- a/tools/zlib/Makefile +++ b/tools/zlib/Makefile @@ -17,7 +17,7 @@ PKG_HASH:=9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23 PKG_LICENSE:=Zlib PKG_LICENSE_FILES:=README -PKG_CPE_ID:=cpe:/a:gnu:zlib +PKG_CPE_ID:=cpe:/a:zlib:zlib HOST_BUILD_PARALLEL:=1 |