kexec-tools: update to 2.0.14-rc1, fix build errors

Signed-off-by: Felix Fietkau <nbd@nbd.name>
v19.07.3_mercusys_ac12_duma
Felix Fietkau 8 years ago
parent 364ec6e0e0
commit 1a071115d6

@ -8,12 +8,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=kexec-tools
PKG_VERSION:=2.0.9
PKG_VERSION:=2.0.14-rc1
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@KERNEL/linux/utils/kernel/kexec
PKG_HASH:=8ae34a9ceb76350954e1e1e3ca9ab51da15862bd5f2fd14392208e60fb454f71
PKG_HASH:=3fc505ff8d8a2d24c68aac5e6b4783997d5a086966ff3de8b05a0ceb27e5e23b
PKG_FIXUP:=autoreconf
@ -55,7 +55,8 @@ CONFIGURE_ARGS = \
--libexecdir=/usr/lib \
--sysconfdir=/etc \
$(if $(CONFIG_KEXEC_ZLIB),--with,--without)-zlib \
$(if $(CONFIG_KEXEC_LZMA),--with,--without)-lzma
$(if $(CONFIG_KEXEC_LZMA),--with,--without)-lzma \
TARGET_LD="$(TARGET_CROSS)ld"
TARGET_CFLAGS += -ffunction-sections -fdata-sections
TARGET_LDFLAGS += -Wl,--gc-sections

@ -1,171 +0,0 @@
From d606837b56d46eb7f815b5d85f07fcc3f1555d00 Mon Sep 17 00:00:00 2001
From: Yousong Zhou <yszhou4tech@gmail.com>
Date: Sun, 1 Feb 2015 00:10:07 +0800
Subject: [PATCH 1/5] Fix zlib/lzma decompression.
Let {zlib,lzma}_decompress_file() return NULL if anything wrong happened
to allow the other method to have a chance to run.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
kexec/lzma.c | 33 ++++++++++++++++++++++-----------
kexec/zlib.c | 57 +++++++++++++++++++++++++++++++++++----------------------
2 files changed, 57 insertions(+), 33 deletions(-)
diff --git a/kexec/lzma.c b/kexec/lzma.c
index 939aeb3..5bfccb7 100644
--- a/kexec/lzma.c
+++ b/kexec/lzma.c
@@ -162,13 +162,16 @@ char *lzma_decompress_file(const char *filename, off_t *r_size)
off_t size, allocated;
ssize_t result;
- if (!filename) {
- *r_size = 0;
- return 0;
- }
+ dbgprintf("Try LZMA decompression.\n");
+
+ *r_size = 0;
+ if (!filename)
+ return NULL;
+
fp = lzopen(filename, "rb");
if (fp == 0) {
- die("Cannot open `%s'\n", filename);
+ dbgprintf("Cannot open `%s'\n", filename);
+ return NULL;
}
size = 0;
allocated = 65536;
@@ -183,17 +186,25 @@ char *lzma_decompress_file(const char *filename, off_t *r_size)
if ((errno == EINTR) || (errno == EAGAIN))
continue;
- die ("read on %s of %ld bytes failed\n",
- filename, (allocated - size) + 0UL);
+ dbgprintf("%s: read on %s of %ld bytes failed\n",
+ __func__, filename, (allocated - size) + 0UL);
+ break;
}
size += result;
- } while(result > 0);
- result = lzclose(fp);
- if (result != LZMA_OK) {
- die ("Close of %s failed\n", filename);
+ } while (result > 0);
+
+ if (lzclose(fp) != LZMA_OK) {
+ dbgprintf("%s: Close of %s failed\n", __func__, filename);
+ goto fail;
}
+ if (result < 0)
+ goto fail;
+
*r_size = size;
return buf;
+fail:
+ free(buf);
+ return NULL;
}
#else
char *lzma_decompress_file(const char *UNUSED(filename), off_t *UNUSED(r_size))
diff --git a/kexec/zlib.c b/kexec/zlib.c
index d44df12..7170ac3 100644
--- a/kexec/zlib.c
+++ b/kexec/zlib.c
@@ -15,29 +15,39 @@
#include <ctype.h>
#include <zlib.h>
+static void _gzerror(gzFile fp, int *errnum, const char **errmsg)
+{
+ *errmsg = gzerror(fp, errnum);
+ if (*errnum == Z_ERRNO) {
+ *errmsg = strerror(*errnum);
+ }
+}
+
char *zlib_decompress_file(const char *filename, off_t *r_size)
{
gzFile fp;
int errnum;
const char *msg;
char *buf;
- off_t size, allocated;
+ off_t size = 0, allocated;
ssize_t result;
+ dbgprintf("Try gzip decompression.\n");
+
+ *r_size = 0;
if (!filename) {
- *r_size = 0;
- return 0;
+ return NULL;
}
fp = gzopen(filename, "rb");
if (fp == 0) {
- msg = gzerror(fp, &errnum);
- if (errnum == Z_ERRNO) {
- msg = strerror(errno);
- }
- fprintf(stderr, "Cannot open `%s': %s\n", filename, msg);
+ _gzerror(fp, &errnum, &msg);
+ dbgprintf("Cannot open `%s': %s\n", filename, msg);
+ return NULL;
+ }
+ if (gzdirect(fp)) {
+ /* It's not in gzip format */
return NULL;
}
- size = 0;
allocated = 65536;
buf = xmalloc(allocated);
do {
@@ -49,25 +59,28 @@ char *zlib_decompress_file(const char *filename, off_t *r_size)
if (result < 0) {
if ((errno == EINTR) || (errno == EAGAIN))
continue;
-
- msg = gzerror(fp, &errnum);
- if (errnum == Z_ERRNO) {
- msg = strerror(errno);
- }
- die ("read on %s of %ld bytes failed: %s\n",
- filename, (allocated - size) + 0UL, msg);
+ _gzerror(fp, &errnum, &msg);
+ dbgprintf("Read on %s of %ld bytes failed: %s\n",
+ filename, (allocated - size) + 0UL, msg);
+ size = 0;
+ goto fail;
}
size += result;
} while(result > 0);
+
+fail:
result = gzclose(fp);
if (result != Z_OK) {
- msg = gzerror(fp, &errnum);
- if (errnum == Z_ERRNO) {
- msg = strerror(errno);
- }
- die ("Close of %s failed: %s\n", filename, msg);
+ _gzerror(fp, &errnum, &msg);
+ dbgprintf(" Close of %s failed: %s\n", filename, msg);
+ }
+
+ if (size > 0) {
+ *r_size = size;
+ } else {
+ free(buf);
+ buf = NULL;
}
- *r_size = size;
return buf;
}
#else
--
1.7.10.4

@ -1,52 +0,0 @@
From eb20884c9bbc42bdf1ccace4444f3ce72657d7d8 Mon Sep 17 00:00:00 2001
From: Yousong Zhou <yszhou4tech@gmail.com>
Date: Tue, 9 Sep 2014 20:15:16 +0800
Subject: [PATCH 2/5] configure.ac: apply necessary quotes to result of macro
expansion.
This can fix the following error when searching for lzma support and
while at it also apply the practice to other uses of the same pattern.
checking for lzma_code in -llzma... ./configure: line 4756: ac_fn_c_try_link: command not found
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
---
configure.ac | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/configure.ac b/configure.ac
index db93331..c410e90 100644
--- a/configure.ac
+++ b/configure.ac
@@ -152,22 +152,22 @@ AC_CHECK_PROG([DIRNAME], dirname, dirname, "no", [$PATH])
dnl See if I have a usable copy of zlib available
if test "$with_zlib" = yes ; then
AC_CHECK_HEADER(zlib.h,
- AC_CHECK_LIB(z, inflateInit_, ,
- AC_MSG_NOTICE([zlib support disabled])))
+ [AC_CHECK_LIB(z, inflateInit_, ,
+ AC_MSG_NOTICE([zlib support disabled]))])
fi
dnl See if I have a usable copy of lzma available
if test "$with_lzma" = yes ; then
AC_CHECK_HEADER(lzma.h,
- AC_CHECK_LIB(lzma, lzma_code, ,
- AC_MSG_NOTICE([lzma support disabled])))
+ [AC_CHECK_LIB(lzma, lzma_code, ,
+ AC_MSG_NOTICE([lzma support disabled]))])
fi
dnl find Xen control stack libraries
if test "$with_xen" = yes ; then
AC_CHECK_HEADER(xenctrl.h,
- AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
- AC_MSG_NOTICE([Xen support disabled])))
+ [AC_CHECK_LIB(xenctrl, xc_kexec_load, ,
+ AC_MSG_NOTICE([Xen support disabled]))])
fi
dnl ---Sanity checks
--
1.7.10.4

@ -1,35 +0,0 @@
From 89d455d785190203b1d3a8766c8babb8c1688fc3 Mon Sep 17 00:00:00 2001
From: Yousong Zhou <yszhou4tech@gmail.com>
Date: Mon, 9 Feb 2015 19:51:25 +0800
Subject: [PATCH 3/5] mips: fix compiler warning on printing 64-bit integer.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
---
kexec/arch/mips/crashdump-mips.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
index e7840e0..98c9f7c 100644
--- a/kexec/arch/mips/crashdump-mips.c
+++ b/kexec/arch/mips/crashdump-mips.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <errno.h>
#include <limits.h>
+#include <inttypes.h>
#include <elf.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -52,7 +53,7 @@ static int get_kernel_paddr(struct crash_elf_info *elf_info)
if (parse_iomem_single("Kernel code\n", &start, NULL) == 0) {
elf_info->kern_paddr_start = start;
- dbgprintf("kernel load physical addr start = 0x%lx\n", start);
+ dbgprintf("kernel load physical addr start = 0x%" PRIu64 "\n", start);
return 0;
}
--
1.7.10.4

@ -1,30 +0,0 @@
From 904e9ae892b0592c916a013869e3be3d830e0155 Mon Sep 17 00:00:00 2001
From: Yousong Zhou <yszhou4tech@gmail.com>
Date: Mon, 9 Feb 2015 20:11:04 +0800
Subject: [PATCH 4/5] mips: remove unused variable.
Fixes the following compilation warning.
kexec/arch/mips/crashdump-mips.c:151:6: warning: unused variable 'i' [-Wunused-variable]
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
---
kexec/arch/mips/crashdump-mips.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c
index 98c9f7c..dc68cb4 100644
--- a/kexec/arch/mips/crashdump-mips.c
+++ b/kexec/arch/mips/crashdump-mips.c
@@ -148,7 +148,7 @@ static int exclude_crash_reserve_region(int *nr_ranges)
static int get_crash_memory_ranges(struct memory_range **range, int *ranges)
{
const char iomem[] = "/proc/iomem";
- int i, memory_ranges = 0;
+ int memory_ranges = 0;
char line[MAX_LINE];
FILE *fp;
unsigned long long start, end;
--
1.7.10.4

@ -1,30 +0,0 @@
From 00e75179b3b4b80e6e58d29a2bd948f97682fd00 Mon Sep 17 00:00:00 2001
From: Yousong Zhou <yszhou4tech@gmail.com>
Date: Mon, 9 Feb 2015 20:28:14 +0800
Subject: [PATCH 5/5] mips: fix warning about implicit type conversion.
Fixes the following warning.
kexec/arch/mips/kexec-elf-mips.c:161:16: warning: assignment makes integer from pointer without a cast [enabled by default]
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
---
kexec/arch/mips/kexec-elf-mips.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c
index a27d986..8a6419a 100644
--- a/kexec/arch/mips/kexec-elf-mips.c
+++ b/kexec/arch/mips/kexec-elf-mips.c
@@ -158,7 +158,7 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len,
if (info->kexec_flags & KEXEC_ON_CRASH)
/* In case of crashdump segment[0] is kernel.
* Put cmdline just after it. */
- cmdline_addr = info->segment[0].mem +
+ cmdline_addr = (unsigned long)info->segment[0].mem +
info->segment[0].memsz;
else
cmdline_addr = 0;
--
1.7.10.4

@ -0,0 +1,20 @@
--- a/kexec/arch/i386/kexec-elf-x86.c
+++ b/kexec/arch/i386/kexec-elf-x86.c
@@ -296,6 +296,6 @@ out:
free(command_line);
free(modified_cmdline);
if (error_msg)
- die(error_msg);
+ die("%s", error_msg);
return result;
}
--- a/kexec/arch/x86_64/kexec-elf-x86_64.c
+++ b/kexec/arch/x86_64/kexec-elf-x86_64.c
@@ -276,6 +276,6 @@ out:
free(command_line);
free(modified_cmdline);
if (error_msg)
- die(error_msg);
+ die("%s", error_msg);
return result;
}
Loading…
Cancel
Save