diff --git a/.config b/.config index 78f79182205c56..85d10c7f4ff690 100644 --- a/.config +++ b/.config @@ -2709,7 +2709,7 @@ CONFIG_PACKAGE_kmod-tpm-tis=m CONFIG_PACKAGE_kmod-ubootenv-nvram=m CONFIG_PACKAGE_kmod-w83627hf-wdt=m CONFIG_PACKAGE_kmod-wdt-sp805=m -CONFIG_PACKAGE_kmod-zram=m +CONFIG_PACKAGE_kmod-zram=y CONFIG_ZRAM_DEF_COMP_LZORLE=y # CONFIG_ZRAM_DEF_COMP_LZO is not set # CONFIG_ZRAM_DEF_COMP_LZ4 is not set diff --git a/config/Config-build.in b/config/Config-build.in index ed4feb58c2db8c..02931a87c6b2cd 100644 --- a/config/Config-build.in +++ b/config/Config-build.in @@ -69,6 +69,7 @@ menu "Global build settings" default y config USE_APK + imply PACKAGE_apk-mbedtls bool "Use APK instead of OPKG to build distribution (EXPERIMENTAL)" comment "General build options" diff --git a/include/package-pack.mk b/include/package-pack.mk index 5baa52caada2d8..26a32788343c42 100644 --- a/include/package-pack.mk +++ b/include/package-pack.mk @@ -205,6 +205,8 @@ $(_endef) rm -rf $$(IDIR_$(1)) ifeq ($$(CONFIG_USE_APK),) $$(call remove_ipkg_files,$(1),$$(call opkg_package_files,$(call gen_package_wildcard,$(1)))) +else + $$(call remove_ipkg_files,$(1),$$(call apk_package_files,$(call gen_package_wildcard,$(1)))) endif mkdir -p $(PACKAGE_DIR) $$(IDIR_$(1)) $(PKG_INFO_DIR) $(call Package/$(1)/install,$$(IDIR_$(1))) diff --git a/include/rootfs.mk b/include/rootfs.mk index 9fb7d8cfdfe86c..554dd48460caed 100644 --- a/include/rootfs.mk +++ b/include/rootfs.mk @@ -80,24 +80,27 @@ define prepare_rootfs @( \ cd $(1); \ if [ -n "$(CONFIG_USE_APK)" ]; then \ - $(STAGING_DIR_HOST)/bin/tar -xf ./lib/apk/db/scripts.tar --wildcards "*.post-install" -O > script.sh; \ - chmod +x script.sh; \ - IPKG_INSTROOT=$(1) $$(command -v bash) script.sh; \ + IPKG_POSTINST_PATH=./lib/apk/db/*.post-install; \ + $(STAGING_DIR_HOST)/bin/tar -C ./lib/apk/db/ -xf ./lib/apk/db/scripts.tar --wildcards "*.post-install"; \ else \ - for script in ./usr/lib/opkg/info/*.postinst; do \ + IPKG_POSTINST_PATH=./usr/lib/opkg/info/*.postinst; \ + fi; \ + for script in $$IPKG_POSTINST_PATH; do \ IPKG_INSTROOT=$(1) $$(command -v bash) $$script; \ ret=$$?; \ if [ $$ret -ne 0 ]; then \ echo "postinst script $$script has failed with exit code $$ret" >&2; \ exit 1; \ fi; \ + [ -n "$(CONFIG_USE_APK)" ] && $(STAGING_DIR_HOST)/bin/tar --delete -f ./lib/apk/db/scripts.tar $$(basename $$script); \ done; \ - $(if $(IB),,awk -i inplace \ - '/^Status:/ { \ - if ($$3 == "user") { $$3 = "ok" } \ - else { sub(/,\|\,/, "", $$3) } \ - }1' $(1)/usr/lib/opkg/status) ; \ - $(if $(SOURCE_DATE_EPOCH),sed -i "s/Installed-Time: .*/Installed-Time: $(SOURCE_DATE_EPOCH)/" $(1)/usr/lib/opkg/status ;) \ + if [ -z "$(CONFIG_USE_APK)" ]; then \ + $(if $(IB),,awk -i inplace \ + '/^Status:/ { \ + if ($$3 == "user") { $$3 = "ok" } \ + else { sub(/,\|\,/, "", $$3) } \ + }1' $(1)/usr/lib/opkg/status) ; \ + $(if $(SOURCE_DATE_EPOCH),sed -i "s/Installed-Time: .*/Installed-Time: $(SOURCE_DATE_EPOCH)/" $(1)/usr/lib/opkg/status ;) \ fi; \ for script in ./etc/init.d/*; do \ grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \ @@ -115,6 +118,7 @@ define prepare_rootfs rm -rf \ $(1)/boot \ $(1)/tmp/* \ + $(1)/lib/apk/db/*.post-install* \ $(1)/usr/lib/opkg/info/*.postinst* \ $(1)/usr/lib/opkg/lists/* \ $(1)/var/lock/*.lock diff --git a/include/target.mk b/include/target.mk index 17622e99387cf4..68065335282d63 100644 --- a/include/target.mk +++ b/include/target.mk @@ -46,8 +46,8 @@ DEFAULT_PACKAGES:=\ urandom-seed \ urngd -ifdef CONFIG_USE_APK -DEFAULT_PACKAGES+=apk +ifneq ($(CONFIG_USE_APK),) +DEFAULT_PACKAGES+=apk-mbedtls else DEFAULT_PACKAGES+=opkg endif diff --git a/include/toplevel.mk b/include/toplevel.mk index 4ec99b30de30fd..54cd8e3a908cff 100644 --- a/include/toplevel.mk +++ b/include/toplevel.mk @@ -75,7 +75,22 @@ endif _ignore = $(foreach p,$(IGNORE_PACKAGES),--ignore $(p)) -prepare-tmpinfo: FORCE +# Config that will invalidate the .targetinfo as they will affect +# DEFAULT_PACKAGES. +# Keep DYNAMIC_DEF_PKG_CONF in sync with target.mk to reflect the same configs +DYNAMIC_DEF_PKG_CONF := CONFIG_USE_APK CONFIG_SELINUX CONFIG_SMALL_FLASH CONFIG_SECCOMP +check-dynamic-def-pkg: FORCE + @+DEF_PKG_CONFS=""; \ + if [ -f $(TOPDIR)/.config ]; then \ + for config in $(DYNAMIC_DEF_PKG_CONF); do \ + DEF_PKG_CONFS="$$DEF_PKG_CONFS "$$(grep "$$config"=y $(TOPDIR)/.config); \ + done; \ + fi; \ + [ ! -f tmp/.packagedynamicdefault ] || OLD_DEF_PKG_CONFS=$$(cat tmp/.packagedynamicdefault); \ + [ "$$DEF_PKG_CONFS" = "$$OLD_DEF_PKG_CONFS" ] || rm -rf tmp/info/.targetinfo*; \ + mkdir -p tmp && echo "$$DEF_PKG_CONFS" > tmp/.packagedynamicdefault; + +prepare-tmpinfo: check-dynamic-def-pkg FORCE @+$(MAKE) -r -s $(STAGING_DIR_HOST)/.prereq-build $(PREP_MK) mkdir -p tmp/info feeds [ -e $(TOPDIR)/feeds/base ] || ln -sf $(TOPDIR)/package $(TOPDIR)/feeds/base diff --git a/package/Makefile b/package/Makefile index eb7cfcf962709e..9e3bb52b657800 100644 --- a/package/Makefile +++ b/package/Makefile @@ -81,7 +81,7 @@ endif ifndef SDK $(curdir)//compile = $(STAGING_DIR)/.prepared $(BIN_DIR) ifneq ($(CONFIG_USE_APK),) - $(curdir)/compile: $(curdir)/system/apk/host/compile $(BUILD_KEY_APK_SEC) $(BUILD_KEY_APK_PUB) + $(curdir)//compile += $(curdir)/system/apk/host/compile $(BUILD_KEY_APK_SEC) $(BUILD_KEY_APK_PUB) else $(curdir)/compile: $(curdir)/system/opkg/host/compile endif diff --git a/package/base-files/Makefile b/package/base-files/Makefile index 4425bb346deaba..313bf377b492fe 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -249,6 +249,8 @@ ifneq ($(CONFIG_USE_APK),) mkdir -p $(1)/etc/apk/ $(call FeedSourcesAppendAPK,$(1)/etc/apk/repositories) $(VERSION_SED_SCRIPT) $(1)/etc/apk/repositories + + rm -f $(1)/etc/uci-defaults/13_fix-group-user else $(if $(CONFIG_CLEAN_IPKG),, \ mkdir -p $(1)/etc/opkg; \ diff --git a/package/base-files/files/etc/uci-defaults/13_fix-group-user b/package/base-files/files/etc/uci-defaults/13_fix-group-user index 74f501e8f77fcb..c5cc74e1a038bd 100644 --- a/package/base-files/files/etc/uci-defaults/13_fix-group-user +++ b/package/base-files/files/etc/uci-defaults/13_fix-group-user @@ -1,5 +1,8 @@ . /lib/functions.sh +# Skip if we don't have /usr/lib/opkg/info (APK installation) +[ -d /usr/lib/opkg/info ] || exit 0 + for file in $(grep -sl Require-User /usr/lib/opkg/info/*.control); do file="${file##*/}" file="${file%.control}" diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh index a009aa81e99d0b..e944d36505662f 100644 --- a/package/base-files/files/lib/functions.sh +++ b/package/base-files/files/lib/functions.sh @@ -533,4 +533,4 @@ cmdline_get_var() { done } -[ -z "$IPKG_INSTROOT" ] && [ -f /lib/config/uci.sh ] && . /lib/config/uci.sh +[ -z "$IPKG_INSTROOT" ] && [ -f /lib/config/uci.sh ] && . /lib/config/uci.sh || true diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade index 9b422107d8c7ab..611d8830bfd1ff 100755 --- a/package/base-files/files/sbin/sysupgrade +++ b/package/base-files/files/sbin/sysupgrade @@ -130,12 +130,20 @@ fi list_conffiles() { - awk ' - BEGIN { conffiles = 0 } - /^Conffiles:/ { conffiles = 1; next } - !/^ / { conffiles = 0; next } - conffiles == 1 { print } - ' /usr/lib/opkg/status + if [ -f /usr/lib/opkg/status ]; then + awk ' + BEGIN { conffiles = 0 } + /^Conffiles:/ { conffiles = 1; next } + !/^ / { conffiles = 0; next } + conffiles == 1 { print } + ' /usr/lib/opkg/status + elif [ -d /lib/apk/packages ]; then + conffiles="" + for file in /lib/apk/packages/*.conffiles_static; do + conffiles="$(echo -e "$(cat $file)\n$conffiles")" + done + echo "$conffiles" + fi } list_changed_conffiles() { diff --git a/package/boot/kexec-tools/Makefile b/package/boot/kexec-tools/Makefile index 702ae009030091..0ab6affd3f25c6 100644 --- a/package/boot/kexec-tools/Makefile +++ b/package/boot/kexec-tools/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=kexec-tools PKG_VERSION:=2.0.28 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@KERNEL/linux/utils/kernel/kexec diff --git a/package/boot/kexec-tools/patches/010-Fix-building-on-x86_64-with-binutils-2.41.patch b/package/boot/kexec-tools/patches/010-Fix-building-on-x86_64-with-binutils-2.41.patch new file mode 100644 index 00000000000000..bbb1281c01e155 --- /dev/null +++ b/package/boot/kexec-tools/patches/010-Fix-building-on-x86_64-with-binutils-2.41.patch @@ -0,0 +1,81 @@ +From 328de8e00e298f00d7ba6b25dc3950147e9642e6 Mon Sep 17 00:00:00 2001 +From: Michel Lind +Date: Tue, 30 Jan 2024 04:14:31 -0600 +Subject: [PATCH] Fix building on x86_64 with binutils 2.41 + +Newer versions of the GNU assembler (observed with binutils 2.41) will +complain about the ".arch i386" in files assembled with "as --64", +with the message "Error: 64bit mode not supported on 'i386'". + +Fix by moving ".arch i386" below the relevant ".code32" directive, so +that the assembler is no longer expecting 64-bit instructions to be used +by the time that the ".arch i386" directive is encountered. + +Based on similar iPXE fix: +https://github.com/ipxe/ipxe/commit/6ca597eee + +Signed-off-by: Michel Lind +Signed-off-by: Simon Horman +--- + purgatory/arch/i386/entry32-16-debug.S | 2 +- + purgatory/arch/i386/entry32-16.S | 2 +- + purgatory/arch/i386/entry32.S | 2 +- + purgatory/arch/i386/setup-x86.S | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +--- a/purgatory/arch/i386/entry32-16-debug.S ++++ b/purgatory/arch/i386/entry32-16-debug.S +@@ -25,10 +25,10 @@ + .globl entry16_debug_pre32 + .globl entry16_debug_first32 + .globl entry16_debug_old_first32 +- .arch i386 + .balign 16 + entry16_debug: + .code32 ++ .arch i386 + /* Compute where I am running at (assumes esp valid) */ + call 1f + 1: popl %ebx +--- a/purgatory/arch/i386/entry32-16.S ++++ b/purgatory/arch/i386/entry32-16.S +@@ -20,10 +20,10 @@ + #undef i386 + .text + .globl entry16, entry16_regs +- .arch i386 + .balign 16 + entry16: + .code32 ++ .arch i386 + /* Compute where I am running at (assumes esp valid) */ + call 1f + 1: popl %ebx +--- a/purgatory/arch/i386/entry32.S ++++ b/purgatory/arch/i386/entry32.S +@@ -20,10 +20,10 @@ + #undef i386 + + .text +- .arch i386 + .globl entry32, entry32_regs + entry32: + .code32 ++ .arch i386 + + /* Setup a gdt that should that is generally usefully */ + lgdt %cs:gdt +--- a/purgatory/arch/i386/setup-x86.S ++++ b/purgatory/arch/i386/setup-x86.S +@@ -21,10 +21,10 @@ + #undef i386 + + .text +- .arch i386 + .globl purgatory_start + purgatory_start: + .code32 ++ .arch i386 + + /* Load a gdt so I know what the segment registers are */ + lgdt %cs:gdt diff --git a/package/boot/kexec-tools/patches/020-i386-improve-basename-compatibility.patch b/package/boot/kexec-tools/patches/020-i386-improve-basename-compatibility.patch new file mode 100644 index 00000000000000..6f06e61c721b94 --- /dev/null +++ b/package/boot/kexec-tools/patches/020-i386-improve-basename-compatibility.patch @@ -0,0 +1,37 @@ +From 99f62f58fac57214ecc3c9aabf6bf61ac1e1201d Mon Sep 17 00:00:00 2001 +From: Tony Ambardar +Date: Fri, 7 Jun 2024 21:54:56 -0700 +Subject: [PATCH] i386: improve basename() compatibility + +Drop usage of glibc basename() in favour of a simpler implementation that +works across GNU and musl libc, and is similar to existing code in fs2dt.c. + +This fixes compile errors seen building against musl. + +Signed-off-by: Tony Ambardar +--- + kexec/arch/i386/x86-linux-setup.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +--- a/kexec/arch/i386/x86-linux-setup.c ++++ b/kexec/arch/i386/x86-linux-setup.c +@@ -318,6 +318,7 @@ static int add_edd_entry(struct x86_linu + uint8_t devnum, version; + uint32_t mbr_sig; + struct edd_info *edd_info; ++ char *basename = strrchr(sysfs_name,'/') + 1; + + if (!current_mbr || !current_edd) { + fprintf(stderr, "%s: current_edd and current_edd " +@@ -329,9 +330,9 @@ static int add_edd_entry(struct x86_linu + memset(edd_info, 0, sizeof(struct edd_info)); + + /* extract the device number */ +- if (sscanf(basename(sysfs_name), "int13_dev%hhx", &devnum) != 1) { ++ if (sscanf(basename, "int13_dev%hhx", &devnum) != 1) { + fprintf(stderr, "Invalid format of int13_dev dir " +- "entry: %s\n", basename(sysfs_name)); ++ "entry: %s\n", basename); + return -1; + } + diff --git a/package/firmware/intel-microcode/Makefile b/package/firmware/intel-microcode/Makefile index 91a697c673af04..bdd8ae73d88f3c 100644 --- a/package/firmware/intel-microcode/Makefile +++ b/package/firmware/intel-microcode/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=intel-microcode -PKG_VERSION:=20240312 +PKG_VERSION:=20240531 PKG_RELEASE:=1 PKG_SOURCE:=intel-microcode_3.$(PKG_VERSION).1.tar.xz PKG_SOURCE_URL:=@DEBIAN/pool/non-free-firmware/i/intel-microcode/ -PKG_HASH:=25f53bab1bf0c84aba927a77a97a9f1147c94199fa95b5187d874f839f022808 +PKG_HASH:=808cbb57a790dab7060b59b31e70e54ac47d3798d75e9784ed57a65b9f951fc4 PKG_BUILD_DIR:=$(BUILD_DIR)/intel-microcode-3.$(PKG_VERSION).1 PKG_CPE_ID:=cpe:/a:intel:microcode diff --git a/package/kernel/lantiq/ltq-adsl-mei/src/drv_mei_cpe.c b/package/kernel/lantiq/ltq-adsl-mei/src/drv_mei_cpe.c index b5e7f07319af2f..ba23232ee9429c 100644 --- a/package/kernel/lantiq/ltq-adsl-mei/src/drv_mei_cpe.c +++ b/package/kernel/lantiq/ltq-adsl-mei/src/drv_mei_cpe.c @@ -2771,7 +2771,11 @@ static int ltq_mei_probe(struct platform_device *pdev) IFX_MEI_DMSG("Start loopback test...\n"); DFE_Loopback_Test (); #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) dsl_class = class_create(THIS_MODULE, "ifx_mei"); +#else + dsl_class = class_create("ifx_mei"); +#endif device_create(dsl_class, NULL, MKDEV(MEI_MAJOR, 0), NULL, "ifx_mei"); return 0; } diff --git a/package/kernel/lantiq/ltq-adsl/patches/100-dsl_compat.patch b/package/kernel/lantiq/ltq-adsl/patches/100-dsl_compat.patch index 1e860010e91c32..db02ebf4fdb237 100644 --- a/package/kernel/lantiq/ltq-adsl/patches/100-dsl_compat.patch +++ b/package/kernel/lantiq/ltq-adsl/patches/100-dsl_compat.patch @@ -111,12 +111,16 @@ DSL_int_t i; printk(DSL_DRV_CRLF DSL_DRV_CRLF "Infineon CPE API Driver version: %s" DSL_DRV_CRLF, -@@ -1104,7 +1119,8 @@ int __init DSL_ModuleInit(void) +@@ -1104,7 +1119,12 @@ int __init DSL_ModuleInit(void) } DSL_DRV_DevNodeInit(); - ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) + dsl_class = class_create(THIS_MODULE, "dsl_cpe_api"); ++#else ++ dsl_class = class_create("dsl_cpe_api"); ++#endif + device_create(dsl_class, NULL, MKDEV(DRV_DSL_CPE_API_DEV_MAJOR, 0), NULL, "dsl_cpe_api"); return 0; } diff --git a/package/kernel/lantiq/ltq-adsl/patches/120-platform.patch b/package/kernel/lantiq/ltq-adsl/patches/120-platform.patch index e1dc254ec0536c..7bbcf35cd2834c 100644 --- a/package/kernel/lantiq/ltq-adsl/patches/120-platform.patch +++ b/package/kernel/lantiq/ltq-adsl/patches/120-platform.patch @@ -18,7 +18,7 @@ { struct class *dsl_class; DSL_int_t i; -@@ -1124,7 +1124,7 @@ int __init DSL_ModuleInit(void) +@@ -1128,7 +1128,7 @@ int __init DSL_ModuleInit(void) return 0; } @@ -27,7 +27,7 @@ { printk("Module will be unloaded"DSL_DRV_CRLF); -@@ -1139,7 +1139,7 @@ void __exit DSL_ModuleCleanup(void) +@@ -1143,7 +1143,7 @@ void __exit DSL_ModuleCleanup(void) (DSL_uint8_t**)&g_BndFpgaBase); #endif /* defined(INCLUDE_DSL_CPE_API_VINAX) && defined(INCLUDE_DSL_BONDING)*/ @@ -36,7 +36,7 @@ } #ifndef _lint -@@ -1155,8 +1155,30 @@ module_param(debug_level, byte, 0); +@@ -1159,8 +1159,30 @@ module_param(debug_level, byte, 0); MODULE_PARM_DESC(debug_level, "set to get more (1) or fewer (4) debug outputs"); #endif /* #ifndef DSL_DEBUG_DISABLE*/ diff --git a/package/kernel/lantiq/ltq-adsl/patches/130-linux3.8.patch b/package/kernel/lantiq/ltq-adsl/patches/130-linux3.8.patch index 93c2f67796ac87..1fbc5d13ab927a 100644 --- a/package/kernel/lantiq/ltq-adsl/patches/130-linux3.8.patch +++ b/package/kernel/lantiq/ltq-adsl/patches/130-linux3.8.patch @@ -95,7 +95,7 @@ &(dsl_cpe_api_version[4])); DSL_DRV_MemSet( ifxDevices, 0, sizeof(DSL_devCtx_t) * DSL_DRV_MAX_DEVICE_NUMBER ); -@@ -1124,7 +1099,7 @@ static int __devinit ltq_adsl_probe(stru +@@ -1128,7 +1103,7 @@ static int __devinit ltq_adsl_probe(stru return 0; } @@ -104,7 +104,7 @@ { printk("Module will be unloaded"DSL_DRV_CRLF); -@@ -1169,7 +1144,7 @@ MODULE_DEVICE_TABLE(of, ltq_adsl_match); +@@ -1173,7 +1148,7 @@ MODULE_DEVICE_TABLE(of, ltq_adsl_match); static struct platform_driver ltq_adsl_driver = { .probe = ltq_adsl_probe, diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c index 2aa4b09593578a..3be7461108d1db 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_aes.c @@ -487,28 +487,28 @@ void ifx_deu_aes_ctr (void *ctx, uint8_t *dst, const uint8_t *src, ifx_deu_aes (ctx, dst, src, iv, nbytes, encdec, 4); } -/*! \fn void aes_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) +/*! \fn void ifx_deu_aes_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) * \ingroup IFX_AES_FUNCTIONS * \brief encrypt AES_BLOCK_SIZE of data * \param tfm linux crypto algo transform * \param out output bytestream * \param in input bytestream */ -void aes_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) +void ifx_deu_aes_encrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) { struct aes_ctx *ctx = crypto_tfm_ctx(tfm); ifx_deu_aes (ctx, out, in, NULL, AES_BLOCK_SIZE, CRYPTO_DIR_ENCRYPT, 0); } -/*! \fn void aes_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) +/*! \fn void ifx_deu_aes_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) * \ingroup IFX_AES_FUNCTIONS * \brief decrypt AES_BLOCK_SIZE of data * \param tfm linux crypto algo transform * \param out output bytestream * \param in input bytestream */ -void aes_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) +void ifx_deu_aes_decrypt (struct crypto_tfm *tfm, uint8_t *out, const uint8_t *in) { struct aes_ctx *ctx = crypto_tfm_ctx(tfm); ifx_deu_aes (ctx, out, in, NULL, AES_BLOCK_SIZE, @@ -532,8 +532,8 @@ struct crypto_alg ifxdeu_aes_alg = { .cia_min_keysize = AES_MIN_KEY_SIZE, .cia_max_keysize = AES_MAX_KEY_SIZE, .cia_setkey = aes_set_key, - .cia_encrypt = aes_encrypt, - .cia_decrypt = aes_decrypt, + .cia_encrypt = ifx_deu_aes_encrypt, + .cia_decrypt = ifx_deu_aes_decrypt, } } }; @@ -721,7 +721,7 @@ void ifx_deu_aes_xts (void *ctx_arg, u8 *out_arg, const u8 *in_arg, memcpy(oldiv, iv_arg, 16); gf128mul_x_ble((le128 *)iv_arg, (le128 *)iv_arg); } - u128_xor((u128 *)((u32 *) in_arg + (i * 4) + 0), (u128 *)((u32 *) in_arg + (i * 4) + 0), (u128 *)iv_arg); + be128_xor((be128 *)((u32 *) in_arg + (i * 4) + 0), (be128 *)((u32 *) in_arg + (i * 4) + 0), (be128 *)iv_arg); } aes->IV3R = DEU_ENDIAN_SWAP(*(u32 *) iv_arg); @@ -744,7 +744,7 @@ void ifx_deu_aes_xts (void *ctx_arg, u8 *out_arg, const u8 *in_arg, *((volatile u32 *) out_arg + (i * 4) + 3) = aes->OD0R; if (encdec) { - u128_xor((u128 *)((volatile u32 *) out_arg + (i * 4) + 0), (u128 *)((volatile u32 *) out_arg + (i * 4) + 0), (u128 *)iv_arg); + be128_xor((be128 *)((volatile u32 *) out_arg + (i * 4) + 0), (be128 *)((volatile u32 *) out_arg + (i * 4) + 0), (be128 *)iv_arg); } gf128mul_x_ble((le128 *)iv_arg, (le128 *)iv_arg); i++; @@ -764,7 +764,7 @@ void ifx_deu_aes_xts (void *ctx_arg, u8 *out_arg, const u8 *in_arg, memcpy(state, ((u32 *) in_arg + (i * 4) + 0), byte_cnt); memcpy((state + byte_cnt), (out_arg + ((i - 1) * 16) + byte_cnt), (XTS_BLOCK_SIZE - byte_cnt)); if (!encdec) { - u128_xor((u128 *)state, (u128 *)state, (u128 *)iv_arg); + be128_xor((be128 *)state, (be128 *)state, (be128 *)iv_arg); } aes->ID3R = INPUT_ENDIAN_SWAP(*((u32 *) state + 0)); @@ -784,7 +784,7 @@ void ifx_deu_aes_xts (void *ctx_arg, u8 *out_arg, const u8 *in_arg, *((volatile u32 *) out_arg + ((i-1) * 4) + 3) = aes->OD0R; if (encdec) { - u128_xor((u128 *)((volatile u32 *) out_arg + ((i-1) * 4) + 0), (u128 *)((volatile u32 *) out_arg + ((i-1) * 4) + 0), (u128 *)iv_arg); + be128_xor((be128 *)((volatile u32 *) out_arg + ((i-1) * 4) + 0), (be128 *)((volatile u32 *) out_arg + ((i-1) * 4) + 0), (be128 *)iv_arg); } } @@ -810,7 +810,7 @@ int xts_aes_encrypt(struct skcipher_request *req) return -EINVAL; ctx->use_tweak = 1; - aes_encrypt(req->base.tfm, walk.iv, walk.iv); + ifx_deu_aes_encrypt(req->base.tfm, walk.iv, walk.iv); ctx->use_tweak = 0; processed = 0; @@ -866,7 +866,7 @@ int xts_aes_decrypt(struct skcipher_request *req) return -EINVAL; ctx->use_tweak = 1; - aes_encrypt(req->base.tfm, walk.iv, walk.iv); + ifx_deu_aes_encrypt(req->base.tfm, walk.iv, walk.iv); ctx->use_tweak = 0; processed = 0; @@ -1658,7 +1658,7 @@ int gcm_aes_encrypt(struct aead_request *req) assoc_remain -= enc_bytes; temp = walk.dst.virt.addr; while (enc_bytes > 0) { - u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)temp); + be128_xor((be128 *)ctx->hash, (be128 *)ctx->hash, (be128 *)temp); gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); enc_bytes -= AES_BLOCK_SIZE; temp += 16; @@ -1674,7 +1674,7 @@ int gcm_aes_encrypt(struct aead_request *req) memcpy(ctx->lastbuffer, walk.src.virt.addr, enc_bytes); memset(ctx->lastbuffer + enc_bytes, 0, (AES_BLOCK_SIZE - enc_bytes)); memcpy(walk.dst.virt.addr, walk.src.virt.addr, ghashlen); - u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)ctx->lastbuffer); + be128_xor((be128 *)ctx->hash, (be128 *)ctx->hash, (be128 *)ctx->lastbuffer); gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); walk.stride = AES_BLOCK_SIZE; err = skcipher_walk_done(&walk, (walk.nbytes - ghashlen)); @@ -1690,7 +1690,7 @@ int gcm_aes_encrypt(struct aead_request *req) nbytes &= AES_BLOCK_SIZE - 1; temp = walk.dst.virt.addr; while (enc_bytes) { - u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)temp); + be128_xor((be128 *)ctx->hash, (be128 *)ctx->hash, (be128 *)temp); gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); enc_bytes -= AES_BLOCK_SIZE; temp += 16; @@ -1704,15 +1704,15 @@ int gcm_aes_encrypt(struct aead_request *req) iv, walk.nbytes, CRYPTO_DIR_ENCRYPT, 0); memcpy(ctx->lastbuffer, walk.dst.virt.addr, enc_bytes); memset(ctx->lastbuffer + enc_bytes, 0, (AES_BLOCK_SIZE - enc_bytes)); - u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)ctx->lastbuffer); + be128_xor((be128 *)ctx->hash, (be128 *)ctx->hash, (be128 *)ctx->lastbuffer); gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); err = skcipher_walk_done(&walk, 0); } //finalize and copy hash - u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)&lengths); + be128_xor((be128 *)ctx->hash, (be128 *)ctx->hash, (be128 *)&lengths); gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); - u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)ctx->block); + be128_xor((be128 *)ctx->hash, (be128 *)ctx->hash, (be128 *)ctx->block); scatterwalk_map_and_copy(ctx->hash, req->dst, req->cryptlen + req->assoclen, crypto_aead_authsize(crypto_aead_reqtfm(req)), 1); aead_request_complete(req, 0); @@ -1773,7 +1773,7 @@ int gcm_aes_decrypt(struct aead_request *req) assoc_remain -= dec_bytes; temp = walk.dst.virt.addr; while (dec_bytes > 0) { - u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)temp); + be128_xor((be128 *)ctx->hash, (be128 *)ctx->hash, (be128 *)temp); gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); dec_bytes -= AES_BLOCK_SIZE; temp += 16; @@ -1789,7 +1789,7 @@ int gcm_aes_decrypt(struct aead_request *req) memcpy(ctx->lastbuffer, walk.src.virt.addr, dec_bytes); memset(ctx->lastbuffer + dec_bytes, 0, (AES_BLOCK_SIZE - dec_bytes)); memcpy(walk.dst.virt.addr, walk.src.virt.addr, ghashlen); - u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)ctx->lastbuffer); + be128_xor((be128 *)ctx->hash, (be128 *)ctx->hash, (be128 *)ctx->lastbuffer); gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); walk.stride = AES_BLOCK_SIZE; err = skcipher_walk_done(&walk, (walk.nbytes - ghashlen)); @@ -1802,7 +1802,7 @@ int gcm_aes_decrypt(struct aead_request *req) dec_bytes -= (nbytes % AES_BLOCK_SIZE); temp = walk.src.virt.addr; while (dec_bytes) { - u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)temp); + be128_xor((be128 *)ctx->hash, (be128 *)ctx->hash, (be128 *)temp); gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); dec_bytes -= AES_BLOCK_SIZE; temp += 16; @@ -1818,7 +1818,7 @@ int gcm_aes_decrypt(struct aead_request *req) if ((dec_bytes = walk.nbytes)) { memcpy(ctx->lastbuffer, walk.src.virt.addr, dec_bytes); memset(ctx->lastbuffer + dec_bytes, 0, (AES_BLOCK_SIZE - dec_bytes)); - u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)ctx->lastbuffer); + be128_xor((be128 *)ctx->hash, (be128 *)ctx->hash, (be128 *)ctx->lastbuffer); gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); ifx_deu_aes_ctr(ctx, walk.dst.virt.addr, walk.src.virt.addr, iv, walk.nbytes, CRYPTO_DIR_DECRYPT, 0); @@ -1826,9 +1826,9 @@ int gcm_aes_decrypt(struct aead_request *req) } //finalize and copy hash - u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)&lengths); + be128_xor((be128 *)ctx->hash, (be128 *)ctx->hash, (be128 *)&lengths); gf128mul_4k_lle((be128 *)ctx->hash, ctx->gf128); - u128_xor((u128 *)ctx->hash, (u128 *)ctx->hash, (u128 *)ctx->block); + be128_xor((be128 *)ctx->hash, (be128 *)ctx->hash, (be128 *)ctx->block); scatterwalk_map_and_copy(ctx->lastbuffer, req->src, req->cryptlen + req->assoclen - authsize, authsize, 0); err = crypto_memneq(ctx->lastbuffer, ctx->hash, authsize) ? -EBADMSG : 0; diff --git a/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/402-kernel-6.6-fixes.patch b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/402-kernel-6.6-fixes.patch new file mode 100644 index 00000000000000..8df0a31e7ea8a4 --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr9-mei/patches/402-kernel-6.6-fixes.patch @@ -0,0 +1,32 @@ +--- a/src/drv_mei_cpe_os.h ++++ b/src/drv_mei_cpe_os.h +@@ -36,6 +36,15 @@ + #include "ifxos_select.h" + #include "ifx_fifo.h" + ++/* __BYTE_ORDER is defined in ifxos_linux_common.h and ifxos_linux_drv.h, which ++ * leads to an compile error in include/uapi/linux/aio_abi.h because the ++ * __LITTLE_ENDIAN is still undefined. So let's undef the unwanted __BYTE_ORDER ++ * again here. ++ */ ++#ifdef __BYTE_ORDER ++ #undef __BYTE_ORDER ++#endif ++ + #if defined(IFXOS_HAVE_VERSION_CHECK) + # if (IFXOS_VERSION_CHECK_EG_THAN(1,1,0)) + # define IFXOS_SUPPORTS_FIFO_PEEK 1 +--- a/src/drv_mei_cpe_linux.c ++++ b/src/drv_mei_cpe_linux.c +@@ -2548,7 +2548,11 @@ static int MEI_InitModuleRegCharDev(cons + ("Using major number %d" MEI_DRV_CRLF, major_number)); + } + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) + mei_class = class_create(THIS_MODULE, devName); ++#else ++ mei_class = class_create(devName); ++#endif + mei_devt = MKDEV(major_number, 0); + device_create(mei_class, NULL, mei_devt, NULL, "%s/%i", devName, 0); + diff --git a/package/kernel/lantiq/ltq-vdsl-vr9/patches/302-kernel-6.6-fixes.patch b/package/kernel/lantiq/ltq-vdsl-vr9/patches/302-kernel-6.6-fixes.patch new file mode 100644 index 00000000000000..3bf9cefc53dada --- /dev/null +++ b/package/kernel/lantiq/ltq-vdsl-vr9/patches/302-kernel-6.6-fixes.patch @@ -0,0 +1,54 @@ +--- a/src/common/drv_dsl_cpe_api.c ++++ b/src/common/drv_dsl_cpe_api.c +@@ -2879,7 +2879,7 @@ DSL_Error_t DSL_DRV_RetxStatisticsGet( + + DSL_CHECK_POINTER(pContext, pData); + DSL_CHECK_ERR_CODE(); +- DSL_CHECK_DIRECTION(pData->nDirection); ++ DSL_CHECK_ATU_DIRECTION(pData->nDirection); + DSL_CHECK_ERR_CODE(); + + DSL_DEBUG(DSL_DBG_MSG, +--- a/src/common/drv_dsl_cpe_os_linux.c ++++ b/src/common/drv_dsl_cpe_os_linux.c +@@ -1251,7 +1251,11 @@ int __init DSL_ModuleInit(void) + + DSL_DRV_DevNodeInit(); + ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) + dsl_class = class_create(THIS_MODULE, DRV_DSL_CPE_API_DEV_NAME); ++#else ++ dsl_class = class_create(DRV_DSL_CPE_API_DEV_NAME); ++#endif + dsl_devt = MKDEV(DRV_DSL_CPE_API_DEV_MAJOR, 0); + device_create(dsl_class, NULL, dsl_devt, NULL, "dsl_cpe_api/0"); + +--- a/src/device/drv_dsl_cpe_device_vrx.c ++++ b/src/device/drv_dsl_cpe_device_vrx.c +@@ -2628,7 +2628,7 @@ static DSL_Error_t DSL_DRV_VRX_ChannelSt + DSL_CHECK_CHANNEL_RANGE(nChannel); + DSL_CHECK_ERR_CODE(); + +- DSL_CHECK_ATU_DIRECTION(nDirection); ++ DSL_CHECK_DIRECTION(nDirection); + DSL_CHECK_ERR_CODE(); + + DSL_DEBUG(DSL_DBG_MSG, +@@ -4644,7 +4644,7 @@ DSL_Error_t DSL_DRV_DEV_FwDownload( + + /* Set VRX device FW mode*/ + fwModeSelect.firmwareFeatures.nPlatformId = nFwFeatures.nPlatformId; +- fwModeSelect.firmwareFeatures.eFirmwareXdslModes = nFwFeatures.nFirmwareXdslModes; ++ fwModeSelect.firmwareFeatures.eFirmwareXdslModes = (IOCTL_MEI_firmwareXdslMode_t)nFwFeatures.nFirmwareXdslModes; + + if( DSL_DRV_VRX_InternalFwModeCtrlSet((MEI_DYN_CNTRL_T*)dev, &fwModeSelect) != 0 ) + { +@@ -6891,7 +6891,7 @@ DSL_Error_t DSL_DRV_VRX_ChannelStatusGet + { + DSL_Error_t nErrCode = DSL_SUCCESS; + +- DSL_CHECK_ATU_DIRECTION(nDirection); ++ DSL_CHECK_DIRECTION(nDirection); + DSL_CHECK_ERR_CODE(); + + DSL_CTX_READ_SCALAR(pContext, nErrCode, diff --git a/package/kernel/lantiq/ltq-vectoring/patches/200-compat.patch b/package/kernel/lantiq/ltq-vectoring/patches/200-compat.patch index 04c6880ddea6ee..ea689819616f42 100644 --- a/package/kernel/lantiq/ltq-vectoring/patches/200-compat.patch +++ b/package/kernel/lantiq/ltq-vectoring/patches/200-compat.patch @@ -17,7 +17,7 @@ /* * #################################### -@@ -118,9 +121,11 @@ struct erb_head { +@@ -118,9 +121,13 @@ struct erb_head { static struct notifier_block g_netdev_event_handler_nb = {0}; static struct net_device *g_ptm_net_dev = NULL; @@ -25,12 +25,14 @@ +static uint32_t vector_prio = TC_PRIO_CONTROL; static int g_dbg_enable = 0; ++static struct workqueue_struct *vectoring_wq; ++ +DECLARE_WORK(xmit_work, xmit_work_handler); +struct sk_buff_head xmit_queue; /* -@@ -129,9 +134,16 @@ static int g_dbg_enable = 0; +@@ -129,9 +136,16 @@ static int g_dbg_enable = 0; * #################################### */ @@ -48,7 +50,7 @@ struct sk_buff *skb_list = NULL; struct sk_buff *skb; struct erb_head *erb; -@@ -179,7 +191,6 @@ static int mei_dsm_cb_func(unsigned int +@@ -179,7 +193,6 @@ static int mei_dsm_cb_func(unsigned int } } @@ -56,7 +58,7 @@ sent_size = 0; segment_code = 0; while ( (skb = skb_list) != NULL ) { -@@ -197,24 +208,23 @@ static int mei_dsm_cb_func(unsigned int +@@ -197,24 +210,23 @@ static int mei_dsm_cb_func(unsigned int segment_code |= 0xC0; ((struct erb_head *)skb->data)->segment_code = segment_code; @@ -75,7 +77,7 @@ - if ( rc == 0 ) - rc = ret; + skb_queue_tail(&xmit_queue, skb); -+ schedule_work(&xmit_work); ++ queue_work(vectoring_wq, &xmit_work); segment_code++; } @@ -88,7 +90,7 @@ } static void ltq_vectoring_priority(uint32_t priority) { -@@ -242,7 +252,7 @@ static int netdev_event_handler(struct n +@@ -242,7 +254,7 @@ static int netdev_event_handler(struct n return NOTIFY_DONE; netif = netdev_notifier_info_to_dev(netdev); @@ -97,10 +99,12 @@ return NOTIFY_DONE; g_ptm_net_dev = event == NETDEV_REGISTER ? netif : NULL; -@@ -438,8 +448,10 @@ static int __init vectoring_init(void) +@@ -438,8 +450,12 @@ static int __init vectoring_init(void) 0, &g_proc_file_vectoring_dbg_seq_fops); ++ vectoring_wq = alloc_workqueue("vectoring", 0, 0); ++ + skb_queue_head_init(&xmit_queue); + register_netdev_event_handler(); @@ -109,11 +113,13 @@ if ( g_ptm_net_dev != NULL ) dev_put(g_ptm_net_dev); -@@ -459,6 +471,8 @@ static void __exit vectoring_exit(void) +@@ -459,6 +475,10 @@ static void __exit vectoring_exit(void) unregister_netdev_event_handler(); -+ flush_scheduled_work(); ++ flush_workqueue(vectoring_wq); ++ ++ destroy_workqueue(vectoring_wq); + remove_proc_entry("driver/vectoring", NULL); } diff --git a/package/kernel/lantiq/ltq-vectoring/patches/300-fix-compilation-warning-stack-limit.patch b/package/kernel/lantiq/ltq-vectoring/patches/300-fix-compilation-warning-stack-limit.patch index 434d7d830d90da..e0b7b0d4a8981a 100644 --- a/package/kernel/lantiq/ltq-vectoring/patches/300-fix-compilation-warning-stack-limit.patch +++ b/package/kernel/lantiq/ltq-vectoring/patches/300-fix-compilation-warning-stack-limit.patch @@ -1,6 +1,6 @@ --- a/src/vectoring/ifxmips_vectoring.c +++ b/src/vectoring/ifxmips_vectoring.c -@@ -298,7 +298,7 @@ static int proc_write_dbg(struct file *f +@@ -300,7 +300,7 @@ static int proc_write_dbg(struct file *f DBG_ENABLE_MASK_ALL }; @@ -9,7 +9,7 @@ char *p; int len, rlen; -@@ -306,6 +306,10 @@ static int proc_write_dbg(struct file *f +@@ -308,6 +308,10 @@ static int proc_write_dbg(struct file *f int f_enable = 0; int i; @@ -20,7 +20,7 @@ len = count < sizeof(str) ? count : sizeof(str) - 1; rlen = len - copy_from_user(str, buf, len); while ( rlen && str[rlen - 1] <= ' ' ) -@@ -365,6 +369,8 @@ static int proc_write_dbg(struct file *f +@@ -367,6 +371,8 @@ static int proc_write_dbg(struct file *f } } diff --git a/package/kernel/linux/modules/netdevices.mk b/package/kernel/linux/modules/netdevices.mk index cf253ff9e05e13..06bae6a7ed758a 100644 --- a/package/kernel/linux/modules/netdevices.mk +++ b/package/kernel/linux/modules/netdevices.mk @@ -1607,7 +1607,7 @@ $(eval $(call KernelPackage,pcs-xpcs)) define KernelPackage/stmmac-core SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Synopsis Ethernet Controller core (NXP,STMMicro,others) - DEPENDS:=@TARGET_x86_64||TARGET_armsr_armv8 +kmod-pcs-xpcs +LINUX_6_6:kmod-of-mdio +kmod-ptp + DEPENDS:=@TARGET_x86_64||TARGET_armsr_armv8 +kmod-pcs-xpcs +kmod-ptp KCONFIG:=CONFIG_STMMAC_ETH \ CONFIG_STMMAC_SELFTESTS=n \ CONFIG_STMMAC_PLATFORM \ diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile index 566cfdd7b2efcb..79ef87b998facd 100644 --- a/package/kernel/mac80211/Makefile +++ b/package/kernel/mac80211/Makefile @@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=mac80211 PKG_VERSION:=6.6.15 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_LICENSE:=GPL-2.0-only PKG_LICENSE_FILES:=COPYING diff --git a/package/kernel/mac80211/patches/ath9k/552-ath9k-ahb_of.patch b/package/kernel/mac80211/patches/ath9k/552-ath9k-ahb_of.patch index 637e607e366b5c..29e66c070c3006 100644 --- a/package/kernel/mac80211/patches/ath9k/552-ath9k-ahb_of.patch +++ b/package/kernel/mac80211/patches/ath9k/552-ath9k-ahb_of.patch @@ -16,7 +16,7 @@ static const struct platform_device_id ath9k_platform_id_table[] = { { -@@ -69,6 +77,236 @@ static const struct ath_bus_ops ath_ahb_ +@@ -69,6 +77,192 @@ static const struct ath_bus_ops ath_ahb_ .eeprom_read = ath_ahb_eeprom_read, }; @@ -25,47 +25,6 @@ +#define QCA955X_DDR_CTL_CONFIG 0x108 +#define QCA955X_DDR_CTL_CONFIG_ACT_WMAC BIT(23) + -+static int of_get_wifi_cal(struct device_node *np, struct ath9k_platform_data *pdata) -+{ -+#ifdef CONFIG_MTD -+ struct device_node *mtd_np = NULL; -+ size_t retlen; -+ int size, ret; -+ struct mtd_info *mtd; -+ const char *part; -+ const __be32 *list; -+ phandle phandle; -+ -+ list = of_get_property(np, "mtd-cal-data", &size); -+ if (!list) -+ return 0; -+ -+ if (size != (2 * sizeof(*list))) -+ return 1; -+ -+ phandle = be32_to_cpup(list++); -+ if (phandle) -+ mtd_np = of_find_node_by_phandle(phandle); -+ -+ if (!mtd_np) -+ return 1; -+ -+ part = of_get_property(mtd_np, "label", NULL); -+ if (!part) -+ part = mtd_np->name; -+ -+ mtd = get_mtd_device_nm(part); -+ if (IS_ERR(mtd)) -+ return 1; -+ -+ ret = mtd_read(mtd, be32_to_cpup(list), sizeof(pdata->eeprom_data), -+ &retlen, (u8*)pdata->eeprom_data); -+ put_mtd_device(mtd); -+ -+#endif -+ return 0; -+} -+ +static int ar913x_wmac_reset(void) +{ + ath79_device_reset_set(AR913X_RESET_AMBA2WMAC); @@ -243,9 +202,6 @@ + + pdata->get_mac_revision = data->soc_revision; + -+ if (of_get_wifi_cal(pdev->dev.of_node, pdata)) -+ dev_err(&pdev->dev, "failed to load calibration data from mtd device\n"); -+ + return data->dev_id; +} +#endif diff --git a/package/kernel/mt76/Makefile b/package/kernel/mt76/Makefile index 03c97de797734f..c6cce9cf9c6749 100644 --- a/package/kernel/mt76/Makefile +++ b/package/kernel/mt76/Makefile @@ -318,7 +318,7 @@ endef define KernelPackage/mt7996e $(KernelPackage/mt76-default) TITLE:=MediaTek MT7996E wireless driver - DEPENDS+=@PCI_SUPPORT +kmod-mt76-connac +kmod-hwmon-core + DEPENDS+=@PCI_SUPPORT +kmod-mt76-connac +kmod-hwmon-core +@DRIVER_11AX_SUPPORT +@KERNEL_RELAY FILES:= $(PKG_BUILD_DIR)/mt7996/mt7996e.ko AUTOLOAD:=$(call AutoProbe,mt7996e) endef diff --git a/package/libs/libbpf/Makefile b/package/libs/libbpf/Makefile index 2105a1c568e8d1..3b732e37bbd64e 100644 --- a/package/libs/libbpf/Makefile +++ b/package/libs/libbpf/Makefile @@ -8,13 +8,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libbpf -PKG_VERSION:=1.4.2 +PKG_VERSION:=1.4.3 PKG_RELEASE:=1 PKG_SOURCE_URL:=https://github.com/libbpf/libbpf -PKG_MIRROR_HASH:=eaf56a8d4297a1dfb477d91b4fb7c7c5ad6b6df73e0f7ac3c8fd93f2664c2e85 +PKG_MIRROR_HASH:=53f2f290fced9663da309e9e03ddcb0b176a47d39d61639c74dbc555d6b979a8 PKG_SOURCE_PROTO:=git -PKG_SOURCE_VERSION:=v1.4.2 +PKG_SOURCE_VERSION:=v$(PKG_VERSION) PKG_ABI_VERSION:=$(firstword $(subst .,$(space),$(PKG_VERSION))) PKG_MAINTAINER:=Tony Ambardar diff --git a/package/libs/openssl/Makefile b/package/libs/openssl/Makefile index 4c42518afc05c4..82784ddddee611 100644 --- a/package/libs/openssl/Makefile +++ b/package/libs/openssl/Makefile @@ -24,7 +24,7 @@ PKG_SOURCE_URL:= \ ftp://ftp.pca.dfn.de/pub/tools/net/openssl/source/ \ ftp://ftp.pca.dfn.de/pub/tools/net/openssl/source/old/$(PKG_BASE)/ -PKG_HASH:=88525753f79d3bec27d2fa7c66aa0b92b3aa9498dafd93d7cfa4b3780cdae313 +PKG_HASH:=eeca035d4dd4e84fc25846d952da6297484afa0650a6f84c682e39df3a4123ca PKG_LICENSE:=Apache-2.0 PKG_LICENSE_FILES:=LICENSE diff --git a/package/network/services/dropbear/Makefile b/package/network/services/dropbear/Makefile index 3812602b35a382..3367fd7f74eb92 100644 --- a/package/network/services/dropbear/Makefile +++ b/package/network/services/dropbear/Makefile @@ -224,7 +224,6 @@ define Package/dropbear/install $(INSTALL_CONF) ./files/dropbear.config $(1)/etc/config/dropbear $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) ./files/dropbear.init $(1)/etc/init.d/dropbear - $(INSTALL_DIR) $(1)/usr/lib/opkg/info $(INSTALL_DIR) $(1)/etc/dropbear $(INSTALL_DIR) $(1)/lib/preinit $(INSTALL_DATA) ./files/dropbear.failsafe $(1)/lib/preinit/99_10_failsafe_dropbear diff --git a/package/system/apk/Makefile b/package/system/apk/Makefile index e30bce94552f55..a372e7cc9c7343 100644 --- a/package/system/apk/Makefile +++ b/package/system/apk/Makefile @@ -17,7 +17,7 @@ PKG_LICENSE_FILES:=LICENSE PKG_INSTALL:=1 HOST_BUILD_PREFIX:=$(STAGING_DIR_HOST) -PKG_BUILD_DEPENDS:=lua/host +HOST_BUILD_DEPENDS:=lua/host include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/host-build.mk @@ -52,7 +52,6 @@ MESON_HOST_VARS+=VERSION=$(PKG_VERSION) MESON_VARS+=VERSION=$(PKG_VERSION) MESON_HOST_ARGS += \ - -Dhelp=disabled \ -Dcompressed-help=false \ -Ddocs=disabled \ -Dcrypto_backend=openssl \ diff --git a/package/utils/yafut/Makefile b/package/utils/yafut/Makefile index 2907024eb1d6ca..1e2ec7bc024d87 100644 --- a/package/utils/yafut/Makefile +++ b/package/utils/yafut/Makefile @@ -5,9 +5,9 @@ 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_MIRROR_HASH:=7540e977104d41b3aca27b58fda8cd84ebec80cfe01d955712fb8dc717aff6a6 +PKG_SOURCE_DATE:=2024-06-10 +PKG_SOURCE_VERSION:=38439f8a53d33b14744bc8f938662670b9d3e361 PKG_LICENSE:=GPL-2.0 PKG_LICENSE_FILES:=LICENSE diff --git a/target/linux/generic/backport-6.6/065-v6.10-compiler_types.h-Define-__retain.patch b/target/linux/generic/backport-6.6/065-v6.10-compiler_types.h-Define-__retain.patch new file mode 100644 index 00000000000000..862207fd0e082c --- /dev/null +++ b/target/linux/generic/backport-6.6/065-v6.10-compiler_types.h-Define-__retain.patch @@ -0,0 +1,58 @@ +From 443df175be581618d6ff781dc3af3aa1a9ba789d Mon Sep 17 00:00:00 2001 +From: Tony Ambardar +Date: Fri, 31 May 2024 23:55:55 -0700 +Subject: [PATCH 1/2] compiler_types.h: Define __retain for + __attribute__((__retain__)) + +Some code includes the __used macro to prevent functions and data from +being optimized out. This macro implements __attribute__((__used__)), which +operates at the compiler and IR-level, and so still allows a linker to +remove objects intended to be kept. + +Compilers supporting __attribute__((__retain__)) can address this gap by +setting the flag SHF_GNU_RETAIN on the section of a function/variable, +indicating to the linker the object should be retained. This attribute is +available since gcc 11, clang 13, and binutils 2.36. + +Provide a __retain macro implementing __attribute__((__retain__)), whose +first user will be the '__bpf_kfunc' tag. + +Link: https://lore.kernel.org/bpf/ZlmGoT9KiYLZd91S@krava/T/ +Cc: stable@vger.kernel.org # v6.6+ +Signed-off-by: Tony Ambardar +--- + include/linux/compiler_types.h | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + +--- a/include/linux/compiler_types.h ++++ b/include/linux/compiler_types.h +@@ -145,6 +145,29 @@ static inline void __chk_io_ptr(const vo + #define __has_builtin(x) (0) + #endif + ++/* ++ * Annotating a function/variable with __retain tells the compiler to place ++ * the object in its own section and set the flag SHF_GNU_RETAIN. This flag ++ * instructs the linker to retain the object during garbage-cleanup or LTO ++ * phases. ++ * ++ * Note that the __used macro is also used to prevent functions or data ++ * being optimized out, but operates at the compiler/IR-level and may still ++ * allow unintended removal of objects during linking. ++ * ++ * Optional: only supported since gcc >= 11, clang >= 13 ++ * ++ * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-retain-function-attribute ++ * clang: https://clang.llvm.org/docs/AttributeReference.html#retain ++ */ ++#if __has_attribute(__retain__) && \ ++ (defined(CONFIG_LD_DEAD_CODE_DATA_ELIMINATION) || \ ++ defined(CONFIG_LTO_CLANG)) ++# define __retain __attribute__((__retain__)) ++#else ++# define __retain ++#endif ++ + /* Compiler specific macros. */ + #ifdef __clang__ + #include diff --git a/target/linux/generic/backport-6.6/066-v6.10-bpf-Harden-__bpf_kfunc-against-linker-removal.patch b/target/linux/generic/backport-6.6/066-v6.10-bpf-Harden-__bpf_kfunc-against-linker-removal.patch new file mode 100644 index 00000000000000..f7e4f4391de874 --- /dev/null +++ b/target/linux/generic/backport-6.6/066-v6.10-bpf-Harden-__bpf_kfunc-against-linker-removal.patch @@ -0,0 +1,65 @@ +From ac507ed9882fd91a94657d68fe9ceac04b957103 Mon Sep 17 00:00:00 2001 +From: Tony Ambardar +Date: Sat, 1 Jun 2024 00:00:21 -0700 +Subject: [PATCH 2/2] bpf: Harden __bpf_kfunc tag against linker kfunc removal + +BPF kfuncs are often not directly referenced and may be inadvertently +removed by optimization steps during kernel builds, thus the __bpf_kfunc +tag mitigates against this removal by including the __used macro. However, +this macro alone does not prevent removal during linking, and may still +yield build warnings (e.g. on mips64el): + + LD vmlinux + BTFIDS vmlinux + WARN: resolve_btfids: unresolved symbol bpf_verify_pkcs7_signature + WARN: resolve_btfids: unresolved symbol bpf_lookup_user_key + WARN: resolve_btfids: unresolved symbol bpf_lookup_system_key + WARN: resolve_btfids: unresolved symbol bpf_key_put + WARN: resolve_btfids: unresolved symbol bpf_iter_task_next + WARN: resolve_btfids: unresolved symbol bpf_iter_css_task_new + WARN: resolve_btfids: unresolved symbol bpf_get_file_xattr + WARN: resolve_btfids: unresolved symbol bpf_ct_insert_entry + WARN: resolve_btfids: unresolved symbol bpf_cgroup_release + WARN: resolve_btfids: unresolved symbol bpf_cgroup_from_id + WARN: resolve_btfids: unresolved symbol bpf_cgroup_acquire + WARN: resolve_btfids: unresolved symbol bpf_arena_free_pages + NM System.map + SORTTAB vmlinux + OBJCOPY vmlinux.32 + +Update the __bpf_kfunc tag to better guard against linker optimization by +including the new __retain compiler macro, which fixes the warnings above. + +Verify the __retain macro with readelf by checking object flags for 'R': + + $ readelf -Wa kernel/trace/bpf_trace.o + Section Headers: + [Nr] Name Type Address Off Size ES Flg Lk Inf Al + ... + [178] .text.bpf_key_put PROGBITS 00000000 6420 0050 00 AXR 0 0 8 + ... + Key to Flags: + ... + R (retain), D (mbind), p (processor specific) + +Link: https://lore.kernel.org/bpf/ZlmGoT9KiYLZd91S@krava/T/ +Reported-by: kernel test robot +Closes: https://lore.kernel.org/r/202401211357.OCX9yllM-lkp@intel.com/ +Fixes: 57e7c169cd6a ("bpf: Add __bpf_kfunc tag for marking kernel functions as kfuncs") +Cc: stable@vger.kernel.org # v6.6+ +Signed-off-by: Tony Ambardar +--- + include/linux/btf.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/include/linux/btf.h ++++ b/include/linux/btf.h +@@ -81,7 +81,7 @@ + * as to avoid issues such as the compiler inlining or eliding either a static + * kfunc, or a global kfunc in an LTO build. + */ +-#define __bpf_kfunc __used noinline ++#define __bpf_kfunc __used __retain noinline + + /* + * Return the name of the passed struct, if exists, or halt the build if for diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367.c b/target/linux/generic/files/drivers/net/phy/rtl8367.c index 7f0569d0385b0c..b14b63e03630bd 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8367.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8367.c @@ -1641,7 +1641,7 @@ static int rtl8367_switch_init(struct rtl8366_smi *smi) int err; dev->name = "RTL8367"; - dev->cpu_port = RTL8367_CPU_PORT_NUM; + dev->cpu_port = smi->cpu_port; dev->ports = RTL8367_NUM_PORTS; dev->vlans = RTL8367_NUM_VIDS; dev->ops = &rtl8367_sw_ops; @@ -1722,6 +1722,11 @@ static int rtl8367_detect(struct rtl8366_smi *smi) dev_info(smi->parent, "RTL%s ver. %u chip found\n", chip_name, rtl_ver & RTL8367_RTL_VER_MASK); + if (of_property_present(smi->parent->of_node, "realtek,extif1")) + smi->cpu_port = RTL8367_CPU_PORT_NUM - 1; + + dev_info(smi->parent, "CPU port: %u\n", smi->cpu_port); + return 0; } diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367b.c b/target/linux/generic/files/drivers/net/phy/rtl8367b.c index cd0d58cbfa33c7..04c790e924569b 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8367b.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8367b.c @@ -1583,6 +1583,13 @@ static int rtl8367b_detect(struct rtl8366_smi *smi) dev_info(smi->parent, "RTL%s chip found\n", chip_name); + if (of_property_present(smi->parent->of_node, "realtek,extif2")) + smi->cpu_port = RTL8367B_CPU_PORT_NUM + 2; + else if (of_property_present(smi->parent->of_node, "realtek,extif1") && (chip_ver != 0x1010)) /* for the RTL8367R-VB chip, extif1 corresponds to cpu_port 5 */ + smi->cpu_port = RTL8367B_CPU_PORT_NUM + 1; + + dev_info(smi->parent, "CPU port: %u\n", smi->cpu_port); + return 0; } @@ -1621,9 +1628,7 @@ static int rtl8367b_probe(struct platform_device *pdev) smi->cmd_write = 0xb8; smi->ops = &rtl8367b_smi_ops; smi->num_ports = RTL8367B_NUM_PORTS; - if (of_property_read_u32(pdev->dev.of_node, "cpu_port", &smi->cpu_port) - || smi->cpu_port >= smi->num_ports) - smi->cpu_port = RTL8367B_CPU_PORT_NUM; + smi->cpu_port = RTL8367B_CPU_PORT_NUM; smi->num_vlan_mc = RTL8367B_NUM_VLANS; smi->mib_counters = rtl8367b_mib_counters; smi->num_mib_counters = ARRAY_SIZE(rtl8367b_mib_counters); diff --git a/toolchain/musl/patches/610-add-renameat2-linux-syscall-wrapper.patch b/toolchain/musl/patches/610-add-renameat2-linux-syscall-wrapper.patch new file mode 100644 index 00000000000000..167769360e30fd --- /dev/null +++ b/toolchain/musl/patches/610-add-renameat2-linux-syscall-wrapper.patch @@ -0,0 +1,61 @@ +From dc651fe2e6b16087c519c0bd0bf943cb7c53c807 Mon Sep 17 00:00:00 2001 +In-Reply-To: <20240423234355.2414567-1-Tony.Ambardar@gmail.com> +References: <20240423234355.2414567-1-Tony.Ambardar@gmail.com> +From: Tony Ambardar +Date: Sat, 20 Apr 2024 21:30:13 -0700 +Subject: [PATCH v3] add renameat2 linux syscall wrapper +To: musl@lists.openwall.com +Cc: Rich Felker + +This syscall is available since Linux 3.15 and also implemented in glibc +from version 2.28. It is commonly used in filesystem or security contexts. + +Constants RENAME_NOREPLACE, RENAME_EXCHANGE, RENAME_WHITEOUT are guarded by +_GNU_SOURCE as with glibc. + +Signed-off-by: Tony Ambardar +--- +v2 -> v3: + * call SYS_renameat first if applicable + * drop unneeded error code handling + +v1 -> v2: + * align related constants + * drop 'int' from 'unsigned int' + * add fallback to SYS_renameat where applicable +--- + include/stdio.h | 7 +++++++ + src/linux/renameat2.c | 11 +++++++++++ + 2 files changed, 18 insertions(+) + create mode 100644 src/linux/renameat2.c + +--- a/include/stdio.h ++++ b/include/stdio.h +@@ -158,6 +158,13 @@ char *ctermid(char *); + #define L_ctermid 20 + #endif + ++#if defined(_GNU_SOURCE) ++#define RENAME_NOREPLACE (1 << 0) ++#define RENAME_EXCHANGE (1 << 1) ++#define RENAME_WHITEOUT (1 << 2) ++ ++int renameat2(int, const char *, int, const char *, unsigned); ++#endif + + #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +--- /dev/null ++++ b/src/linux/renameat2.c +@@ -0,0 +1,11 @@ ++#define _GNU_SOURCE ++#include ++#include "syscall.h" ++ ++int renameat2(int oldfd, const char *old, int newfd, const char *new, unsigned flags) ++{ ++#ifdef SYS_renameat ++ if (!flags) return syscall(SYS_renameat, oldfd, old, newfd, new); ++#endif ++ return syscall(SYS_renameat2, oldfd, old, newfd, new, flags); ++} diff --git a/tools/ccache/Makefile b/tools/ccache/Makefile index cd2c6d27d5e1cd..47c24a5c98864a 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 8f1c4265018806..a40665ea25836c 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 1027b671bd5626..89194ac5d7a8de 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/dwarves/Makefile b/tools/dwarves/Makefile index 16dc765f586e45..bcb16dd3da36b1 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 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 00000000000000..15bddd56457a38 --- /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/elfutils/patches/010-backport-mips-support-reloc.patch b/tools/elfutils/patches/010-backport-mips-support-reloc.patch new file mode 100644 index 00000000000000..8a65e4e4640ad3 --- /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 +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 +--- + 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 . */ ++ ++#ifdef HAVE_CONFIG_H ++# include ++#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 . */ ++ ++/* 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 . */ ++ ++#ifdef HAVE_CONFIG_H ++# include ++#endif ++ ++#include ++ ++#include ++#include ++#include ++#include ++#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 . */ ++ ++#ifdef HAVE_CONFIG_H ++# include ++#endif ++ ++#include ++ ++#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 . */ ++ ++#ifdef HAVE_CONFIG_H ++# include ++#endif ++ ++#include ++#if (defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)) && defined(__linux__) ++# include ++# include ++#include ++#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 . */ ++ ++#ifdef HAVE_CONFIG_H ++# include ++#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 . */ ++ ++#ifdef HAVE_CONFIG_H ++# include ++#endif ++ ++#include ++#include ++#include ++#include ++#include ++#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 . */ ++ ++#ifdef HAVE_CONFIG_H ++# include ++#endif ++ ++#include ++#include ++#include ++ ++#define BACKEND mips_ ++#include "libebl_CPU.h" ++#include ++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 . */ ++ ++#ifdef HAVE_CONFIG_H ++# include ++#endif ++ ++#include ++#include ++#include ++#include ++#include ++ ++#define BACKEND mips_ ++#include "libebl_CPU.h" ++#include "libdwP.h" ++#include ++ ++/* $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 . */ ++ ++#ifdef HAVE_CONFIG_H ++# include ++#endif ++ ++#include ++#include ++ ++#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 +- : _(""), +- 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 ++ : _(""), ++ 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 +- : _(""), +- 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 ++ : _(""), ++ 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 +- : _(""), +- 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 ++ : _(""), ++ 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 +- : _(""), +- 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 ++ : _(""), ++ 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 . ++ ++. $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/fakeroot/patches/300-time64-hack.patch b/tools/fakeroot/patches/300-time64-hack.patch new file mode 100644 index 00000000000000..540724fb5a856c --- /dev/null +++ b/tools/fakeroot/patches/300-time64-hack.patch @@ -0,0 +1,11 @@ +--- a/configure.ac ++++ b/configure.ac +@@ -386,7 +386,7 @@ dnl Digital Unix: stat + time64_hack=no + AH_TEMPLATE([TIME64_HACK], [time64 shuffle]) + AC_MSG_CHECKING([if we need to cope with time64]) +-AC_EGREP_CPP([time64],[ ++AC_EGREP_CPP([_*[a-z0-9]+_time64[^_]],[ + #include + #if __WORDSIZE == 32 + #define __USE_TIME_BITS64 1 diff --git a/tools/findutils/Makefile b/tools/findutils/Makefile index fd0cde2145edea..6587c759f88dc2 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 dc346f3f766240..00000000000000 --- 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/pkgconf/Makefile b/tools/pkgconf/Makefile index 517b8d847ba874..533af502e35c40 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/quilt/Makefile b/tools/quilt/Makefile index c16f989b5d198f..73d1db983b2671 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