diff options
Diffstat (limited to 'tools/mkimage')
| -rw-r--r-- | tools/mkimage/Makefile | 29 | ||||
| -rw-r--r-- | tools/mkimage/patches/010-freebsd-ulong-fix.patch | 8 | ||||
| -rw-r--r-- | tools/mkimage/patches/020-darwin-10_7-getline-fix.patch | 22 | ||||
| -rw-r--r-- | tools/mkimage/patches/020-include_compile_fix.patch | 10 | ||||
| -rw-r--r-- | tools/mkimage/patches/030-allow-to-use-different-magic.patch | 98 | ||||
| -rw-r--r-- | tools/mkimage/patches/050-image_h_portability.patch | 31 | ||||
| -rw-r--r-- | tools/mkimage/patches/060-remove_kernel_includes.patch | 35 | ||||
| -rw-r--r-- | tools/mkimage/patches/080-remove_compiler_check.patch | 16 | ||||
| -rw-r--r-- | tools/mkimage/patches/100-freebsd-compat.patch | 14 | ||||
| -rw-r--r-- | tools/mkimage/patches/200-rsa-sign-add-support-for-libressl.patch | 68 | ||||
| -rw-r--r-- | tools/mkimage/patches/210-link-libcrypto-static.patch | 14 |
11 files changed, 265 insertions, 80 deletions
diff --git a/tools/mkimage/Makefile b/tools/mkimage/Makefile index 2ea1123c265..d0ff5f7e370 100644 --- a/tools/mkimage/Makefile +++ b/tools/mkimage/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2011 OpenWrt.org +# Copyright (C) 2006-2014 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -7,29 +7,42 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mkimage -PKG_VERSION:=2011.06 +PKG_VERSION:=2018.03 PKG_SOURCE:=u-boot-$(PKG_VERSION).tar.bz2 -PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot -PKG_MD5SUM:=0cc5026aad02f218a9b9ac56b301c97a -PKG_CAT:=bzcat +PKG_SOURCE_URL:=\ + http://mirror2.openwrt.org/sources \ + ftp://ftp.denx.de/pub/u-boot +PKG_HASH:=7e7477534409d5368eb1371ffde6820f0f79780a1a1f676161c48442cb303dfd HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/u-boot-$(PKG_VERSION) include $(INCLUDE_DIR)/host-build.mk +define Host/Prepare + $(Host/Prepare/Default) + mkdir -p $(HOST_BUILD_DIR)/include/config + touch $(HOST_BUILD_DIR)/include/config/auto.conf +endef + define Host/Compile - rm -f $(HOST_BUILD_DIR)/tools/.depend - touch $(HOST_BUILD_DIR)/include/config.h - $(MAKE) -C $(HOST_BUILD_DIR) BUILD_DIR= BIN_FILES-y="mkimage" tools + $(MAKE) -C $(HOST_BUILD_DIR) \ + HOSTCFLAGS="$(HOST_CFLAGS)" \ + HOSTLDFLAGS="$(HOST_LDFLAGS)" \ + no-dot-config-targets=tools-only \ + CONFIG_MKIMAGE_DTC_PATH=dtc \ + CONFIG_FIT_SIGNATURE=y \ + tools-only endef define Host/Install $(CP) $(HOST_BUILD_DIR)/tools/mkimage $(STAGING_DIR_HOST)/bin/ + $(CP) $(HOST_BUILD_DIR)/tools/mkenvimage $(STAGING_DIR_HOST)/bin/ endef define Host/Clean rm -f $(STAGING_DIR_HOST)/bin/mkimage + rm -f $(STAGING_DIR_HOST)/bin/mkenvimage endef $(eval $(call HostBuild)) diff --git a/tools/mkimage/patches/010-freebsd-ulong-fix.patch b/tools/mkimage/patches/010-freebsd-ulong-fix.patch index 32fa0745339..7d891657f8a 100644 --- a/tools/mkimage/patches/010-freebsd-ulong-fix.patch +++ b/tools/mkimage/patches/010-freebsd-ulong-fix.patch @@ -1,6 +1,6 @@ --- a/include/image.h +++ b/include/image.h -@@ -50,6 +50,10 @@ +@@ -51,6 +51,10 @@ struct lmb; #endif /* USE_HOSTCC */ @@ -8,6 +8,6 @@ +#define ulong unsigned long +#endif + - #if defined(CONFIG_FIT) - #include <fdt.h> - #include <libfdt.h> + #if IMAGE_ENABLE_FIT + #include <hash.h> + #include <linux/libfdt.h> diff --git a/tools/mkimage/patches/020-darwin-10_7-getline-fix.patch b/tools/mkimage/patches/020-darwin-10_7-getline-fix.patch deleted file mode 100644 index ff1ae807da0..00000000000 --- a/tools/mkimage/patches/020-darwin-10_7-getline-fix.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/tools/os_support.h -+++ b/tools/os_support.h -@@ -28,7 +28,7 @@ - #include "mingw_support.h" - #endif - --#ifdef __APPLE__ -+#if defined(__APPLE__) && __DARWIN_C_LEVEL < 200809L - #include "getline.h" - #endif - ---- a/tools/os_support.c -+++ b/tools/os_support.c -@@ -23,6 +23,7 @@ - #ifdef __MINGW32__ - #include "mingw_support.c" - #endif --#ifdef __APPLE__ -+ -+#if defined(__APPLE__) && __DARWIN_C_LEVEL < 200809L - #include "getline.c" - #endif diff --git a/tools/mkimage/patches/020-include_compile_fix.patch b/tools/mkimage/patches/020-include_compile_fix.patch new file mode 100644 index 00000000000..276cae0cb16 --- /dev/null +++ b/tools/mkimage/patches/020-include_compile_fix.patch @@ -0,0 +1,10 @@ +--- a/include/u-boot/rsa-checksum.h ++++ b/include/u-boot/rsa-checksum.h +@@ -7,7 +7,6 @@ + #ifndef _RSA_CHECKSUM_H + #define _RSA_CHECKSUM_H + +-#include <errno.h> + #include <image.h> + #include <u-boot/sha1.h> + #include <u-boot/sha256.h> diff --git a/tools/mkimage/patches/030-allow-to-use-different-magic.patch b/tools/mkimage/patches/030-allow-to-use-different-magic.patch index 31a9065f3f0..c6de9a0aaf6 100644 --- a/tools/mkimage/patches/030-allow-to-use-different-magic.patch +++ b/tools/mkimage/patches/030-allow-to-use-different-magic.patch @@ -1,48 +1,65 @@ --- a/tools/mkimage.c +++ b/tools/mkimage.c -@@ -37,6 +37,7 @@ struct mkimage_params params = { +@@ -21,6 +21,7 @@ static struct image_tool_params params = .arch = IH_ARCH_PPC, .type = IH_TYPE_KERNEL, .comp = IH_COMP_GZIP, + .magic = IH_MAGIC, .dtc = MKIMAGE_DEFAULT_DTC_OPTIONS, .imagename = "", - }; -@@ -180,6 +181,16 @@ main (int argc, char **argv) - genimg_get_comp_id (*++argv)) < 0) - usage (); - goto NXTARG; -+ case 'M': -+ if (--argc <=0) -+ usage (); -+ params.magic = strtoul (*++argv, &ptr, 16); -+ if (*ptr) { -+ fprintf (stderr, -+ "%s: invalid magic %s\n", -+ params.cmdname, *argv); -+ } -+ goto NXTARG; - case 'D': - if (--argc <= 0) - usage (); -@@ -580,12 +591,13 @@ usage () - fprintf (stderr, "Usage: %s -l image\n" + .imagename2 = "", +@@ -77,11 +78,12 @@ static void usage(const char *msg) " -l ==> list image header information\n", params.cmdname); -- fprintf (stderr, " %s [-x] -A arch -O os -T type -C comp " -+ fprintf (stderr, " %s [-x] -A arch -O os -T type -C comp -M magic " - "-a addr -e ep -n name -d data_file[:data_file...] image\n" - " -A ==> set architecture to 'arch'\n" - " -O ==> set operating system to 'os'\n" - " -T ==> set image type to 'type'\n" - " -C ==> set compression type 'comp'\n" -+ " -M ==> set image magic to 'magic'\n" - " -a ==> set load address to 'addr' (hex)\n" - " -e ==> set entry point to 'ep' (hex)\n" - " -n ==> set image name to 'name'\n" ---- a/tools/mkimage.h -+++ b/tools/mkimage.h -@@ -64,6 +64,7 @@ struct mkimage_params { + fprintf(stderr, +- " %s [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image\n" ++ " %s [-x] -A arch -O os -T type -C comp -M magic -a addr -e ep -n name -d data_file[:data_file...] image\n" + " -A ==> set architecture to 'arch'\n" + " -O ==> set operating system to 'os'\n" + " -T ==> set image type to 'type'\n" + " -C ==> set compression type 'comp'\n" ++ " -M ==> set image magic to 'magic'\n" + " -a ==> set load address to 'addr' (hex)\n" + " -e ==> set entry point to 'ep' (hex)\n" + " -n ==> set image name to 'name'\n" +@@ -144,7 +146,7 @@ static void process_args(int argc, char + int opt; + + while ((opt = getopt(argc, argv, +- "a:A:b:c:C:d:D:e:Ef:Fk:i:K:ln:N:p:O:rR:qsT:vVx")) != -1) { ++ "a:A:b:c:C:d:D:e:Ef:Fk:i:K:lM:n:N:p:O:rR:qsT:vVx")) != -1) { + switch (opt) { + case 'a': + params.addr = strtoull(optarg, &ptr, 16); +@@ -222,6 +224,14 @@ static void process_args(int argc, char + case 'l': + params.lflag = 1; + break; ++ case 'M': ++ params.magic = strtoull(optarg, &ptr, 16); ++ if (*ptr) { ++ fprintf(stderr, "%s: invalid magic %s\n", ++ params.cmdname, optarg); ++ exit(EXIT_FAILURE); ++ } ++ break; + case 'n': + params.imagename = optarg; + break; +--- a/tools/default_image.c ++++ b/tools/default_image.c +@@ -106,7 +106,7 @@ static void image_set_header(void *ptr, + imagesize = sbuf->st_size - sizeof(image_header_t); + + /* Build new header */ +- image_set_magic(hdr, IH_MAGIC); ++ image_set_magic(hdr, params->magic); + image_set_time(hdr, time); + image_set_size(hdr, imagesize); + image_set_load(hdr, params->addr); +--- a/tools/imagetool.h ++++ b/tools/imagetool.h +@@ -54,6 +54,7 @@ struct image_tool_params { int arch; int type; int comp; @@ -50,14 +67,3 @@ char *dtc; unsigned int addr; unsigned int ep; ---- a/tools/default_image.c -+++ b/tools/default_image.c -@@ -110,7 +110,7 @@ static void image_set_header (void *ptr, - sbuf->st_size - sizeof(image_header_t)); - - /* Build new header */ -- image_set_magic (hdr, IH_MAGIC); -+ image_set_magic (hdr, params->magic); - image_set_time (hdr, sbuf->st_mtime); - image_set_size (hdr, sbuf->st_size - sizeof(image_header_t)); - image_set_load (hdr, params->addr); diff --git a/tools/mkimage/patches/050-image_h_portability.patch b/tools/mkimage/patches/050-image_h_portability.patch new file mode 100644 index 00000000000..dabab399080 --- /dev/null +++ b/tools/mkimage/patches/050-image_h_portability.patch @@ -0,0 +1,31 @@ +--- a/include/image.h ++++ b/include/image.h +@@ -17,7 +17,6 @@ + #define __IMAGE_H__ + + #include "compiler.h" +-#include <asm/byteorder.h> + + /* Define this to avoid #ifdefs later on */ + struct lmb; +@@ -308,13 +307,13 @@ enum { + * all data in network byte order (aka natural aka bigendian). + */ + typedef struct image_header { +- __be32 ih_magic; /* Image Header Magic Number */ +- __be32 ih_hcrc; /* Image Header CRC Checksum */ +- __be32 ih_time; /* Image Creation Timestamp */ +- __be32 ih_size; /* Image Data Size */ +- __be32 ih_load; /* Data Load Address */ +- __be32 ih_ep; /* Entry Point Address */ +- __be32 ih_dcrc; /* Image Data CRC Checksum */ ++ uint32_t ih_magic; /* Image Header Magic Number */ ++ uint32_t ih_hcrc; /* Image Header CRC Checksum */ ++ uint32_t ih_time; /* Image Creation Timestamp */ ++ uint32_t ih_size; /* Image Data Size */ ++ uint32_t ih_load; /* Data Load Address */ ++ uint32_t ih_ep; /* Entry Point Address */ ++ uint32_t ih_dcrc; /* Image Data CRC Checksum */ + uint8_t ih_os; /* Operating System */ + uint8_t ih_arch; /* CPU architecture */ + uint8_t ih_type; /* Image Type */ diff --git a/tools/mkimage/patches/060-remove_kernel_includes.patch b/tools/mkimage/patches/060-remove_kernel_includes.patch new file mode 100644 index 00000000000..e61d8cc4961 --- /dev/null +++ b/tools/mkimage/patches/060-remove_kernel_includes.patch @@ -0,0 +1,35 @@ +--- a/include/compiler.h ++++ b/include/compiler.h +@@ -66,6 +66,11 @@ typedef uint8_t __u8; + typedef uint16_t __u16; + typedef uint32_t __u32; + typedef unsigned int uint; ++typedef uint64_t __u64; ++#ifndef linux ++typedef int __kernel_daddr_t; ++typedef unsigned int __kernel_ino_t; ++#endif + + #define uswap_16(x) \ + ((((x) & 0xff00) >> 8) | \ +--- a/include/linux/posix_types.h ++++ b/include/linux/posix_types.h +@@ -43,6 +43,8 @@ typedef void (*__kernel_sighandler_t)(in + /* Type of a SYSV IPC key. */ + typedef int __kernel_key_t; + ++#ifdef linux + #include <asm/posix_types.h> ++#endif + + #endif /* _LINUX_POSIX_TYPES_H */ +--- a/include/linux/types.h ++++ b/include/linux/types.h +@@ -2,7 +2,6 @@ + #define _LINUX_TYPES_H + + #include <linux/posix_types.h> +-#include <asm/types.h> + #include <stdbool.h> + + #ifndef __KERNEL_STRICT_NAMES diff --git a/tools/mkimage/patches/080-remove_compiler_check.patch b/tools/mkimage/patches/080-remove_compiler_check.patch new file mode 100644 index 00000000000..5e0792f25f3 --- /dev/null +++ b/tools/mkimage/patches/080-remove_compiler_check.patch @@ -0,0 +1,16 @@ +--- a/include/linux/compiler-gcc.h ++++ b/include/linux/compiler-gcc.h +@@ -146,13 +146,6 @@ + + #if GCC_VERSION >= 40000 + +-/* GCC 4.1.[01] miscompiles __weak */ +-#ifdef __KERNEL__ +-# if GCC_VERSION >= 40100 && GCC_VERSION <= 40101 +-# error Your version of gcc miscompiles the __weak directive +-# endif +-#endif +- + #define __used __attribute__((__used__)) + #define __compiler_offsetof(a, b) \ + __builtin_offsetof(a, b) diff --git a/tools/mkimage/patches/100-freebsd-compat.patch b/tools/mkimage/patches/100-freebsd-compat.patch new file mode 100644 index 00000000000..1567285714d --- /dev/null +++ b/tools/mkimage/patches/100-freebsd-compat.patch @@ -0,0 +1,14 @@ +--- a/Makefile ++++ b/Makefile +@@ -634,7 +634,10 @@ UBOOTINCLUDE := \ + -I$(srctree)/arch/$(ARCH)/include \ + -include $(srctree)/include/linux/kconfig.h + +-NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) ++ifneq ($(shell uname),FreeBSD) ++ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) ++endif ++ + CHECKFLAGS += $(NOSTDINC_FLAGS) + + # FIX ME diff --git a/tools/mkimage/patches/200-rsa-sign-add-support-for-libressl.patch b/tools/mkimage/patches/200-rsa-sign-add-support-for-libressl.patch new file mode 100644 index 00000000000..29058e22b71 --- /dev/null +++ b/tools/mkimage/patches/200-rsa-sign-add-support-for-libressl.patch @@ -0,0 +1,68 @@ +From 69176c8602e29f4bd30457240374800d88dc39ed Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens <hauke@hauke-m.de> +Date: Sat, 14 Apr 2018 22:39:34 +0200 +Subject: [PATCH] rsa-sign: add support for libressl + +--- + lib/rsa/rsa-sign.c | 15 +++++++++------ + 1 file changed, 9 insertions(+), 6 deletions(-) + +--- a/lib/rsa/rsa-sign.c ++++ b/lib/rsa/rsa-sign.c +@@ -21,7 +21,8 @@ + #define HAVE_ERR_REMOVE_THREAD_STATE + #endif + +-#if OPENSSL_VERSION_NUMBER < 0x10100000L ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || \ ++ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL) + static void RSA_get0_key(const RSA *r, + const BIGNUM **n, const BIGNUM **e, const BIGNUM **d) + { +@@ -300,7 +301,8 @@ static int rsa_init(void) + { + int ret; + +-#if OPENSSL_VERSION_NUMBER < 0x10100000L ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || \ ++ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL) + ret = SSL_library_init(); + #else + ret = OPENSSL_init_ssl(0, NULL); +@@ -309,7 +311,7 @@ static int rsa_init(void) + fprintf(stderr, "Failure to init SSL library\n"); + return -1; + } +-#if OPENSSL_VERSION_NUMBER < 0x10100000L ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) + SSL_load_error_strings(); + + OpenSSL_add_all_algorithms(); +@@ -355,7 +357,7 @@ err_set_rsa: + err_engine_init: + ENGINE_free(e); + err_engine_by_id: +-#if OPENSSL_VERSION_NUMBER < 0x10100000L ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) + ENGINE_cleanup(); + #endif + return ret; +@@ -363,7 +365,7 @@ err_engine_by_id: + + static void rsa_remove(void) + { +-#if OPENSSL_VERSION_NUMBER < 0x10100000L ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) + CRYPTO_cleanup_all_ex_data(); + ERR_free_strings(); + #ifdef HAVE_ERR_REMOVE_THREAD_STATE +@@ -433,7 +435,8 @@ static int rsa_sign_with_key(RSA *rsa, s + ret = rsa_err("Could not obtain signature"); + goto err_sign; + } +- #if OPENSSL_VERSION_NUMBER < 0x10100000L ++ #if OPENSSL_VERSION_NUMBER < 0x10100000L || \ ++ defined(LIBRESSL_VERSION_NUMBER) + EVP_MD_CTX_cleanup(context); + #else + EVP_MD_CTX_reset(context); diff --git a/tools/mkimage/patches/210-link-libcrypto-static.patch b/tools/mkimage/patches/210-link-libcrypto-static.patch new file mode 100644 index 00000000000..66412ce43b5 --- /dev/null +++ b/tools/mkimage/patches/210-link-libcrypto-static.patch @@ -0,0 +1,14 @@ +OpenWrt links the libressl statically against mkimage, make sure all the +needed dependencies are added too. + +--- a/tools/Makefile ++++ b/tools/Makefile +@@ -145,7 +145,7 @@ endif + # MXSImage needs LibSSL + ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_ARMADA_38X)$(CONFIG_ARMADA_39X)$(CONFIG_FIT_SIGNATURE),) + HOSTLOADLIBES_mkimage += \ +- $(shell pkg-config --libs libssl libcrypto 2> /dev/null || echo "-lssl -lcrypto") ++ $(shell pkg-config --libs --static libssl libcrypto 2> /dev/null || echo "-lssl -lcrypto") + + # OS X deprecate openssl in favour of CommonCrypto, supress deprecation + # warnings on those systems |
