efivar: add patches to enable cross compilation

This commit is contained in:
Elie ROUDNINSKI 2018-10-07 18:39:47 +01:00 committed by maxice8
parent 5353e57c4a
commit 0a720997cd
3 changed files with 166 additions and 4 deletions

View file

@ -0,0 +1,54 @@
From 41d039a327a6a9254a1580699188413a7e7363af Mon Sep 17 00:00:00 2001
From: Elie ROUDNINSKI <xademax@gmail.com>
Date: Sun, 7 Oct 2018 18:02:24 +0100
Subject: [PATCH] Support custom c(cld)flags for CC(LD)_FOR_BUILD
---
Make.defaults | 11 +++++++++++
src/Makefile | 1 +
2 files changed, 12 insertions(+)
diff --git a/Make.defaults b/Make.defaults
index 57cee6e..814b0ef 100644
--- a/Make.defaults
+++ b/Make.defaults
@@ -36,6 +36,11 @@ cflags = $(CFLAGS) -I${TOPDIR}/src/include/ \
$(if $(findstring ccc-analyzer,$(CC)),$(clang_cflags),) \
$(if $(findstring gcc,$(CC)),$(gcc_cflags),) \
$(call pkg-config-cflags)
+cflags_for_build = $(CFLAGS_FOR_BUILD) -I${TOPDIR}/src/include/ \
+ $(if $(findstring clang,$(CC_FOR_BUILD)),$(clang_cflags),) \
+ $(if $(findstring ccc-analyzer,$(CC_FOR_BUILD)),$(clang_cflags),) \
+ $(if $(findstring gcc,$(CC_FOR_BUILD)),$(gcc_cflags),) \
+ $(call pkg-config-cflags)
clang_ccldflags =
gcc_ccldflags =
ccldflags = $(cflags) -L. $(CCLDFLAGS) $(LDFLAGS) \
@@ -44,6 +49,12 @@ ccldflags = $(cflags) -L. $(CCLDFLAGS) $(LDFLAGS) \
$(if $(findstring ccc-analyzer,$(CCLD)),$(clang_ccldflags),) \
$(if $(findstring gcc,$(CCLD)),$(gcc_ccldflags),) \
$(call pkg-config-ldflags)
+ccldflags_for_build = $(cflags_for_build) -L. $(CCLDFLAGS) $(LDFLAGS) \
+ -Wl,-z,muldefs \
+ $(if $(findstring clang,$(CCLD_FOR_BUILD)),$(clang_ccldflags),) \
+ $(if $(findstring ccc-analyzer,$(CCLD_FOR_BUILD)),$(clang_ccldflags),) \
+ $(if $(findstring gcc,$(CCLD_FOR_BUILD)),$(gcc_ccldflags),) \
+ $(call pkg-config-ldflags)
SOFLAGS=-shared
LDLIBS=$(foreach lib,$(LIBS),-l$(lib)) $(call pkg-config-ldlibs)
diff --git a/src/Makefile b/src/Makefile
index 76bc474..287bb1d 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -56,6 +56,7 @@ makeguids : CPPFLAGS+=-DEFIVAR_BUILD_ENVIRONMENT
makeguids : LIBS=dl
makeguids : $(MAKEGUIDS_SOURCES)
makeguids : CCLD=$(CCLD_FOR_BUILD)
+makeguids : ccldflags=$(ccldflags_for_build)
guids.o : guids.S | guids.bin names.bin
--
2.19.0

View file

@ -0,0 +1,111 @@
From 9fc8c48fa59a6d7aaa4c7df7642bfd316086d3b7 Mon Sep 17 00:00:00 2001
From: Elie ROUDNINSKI <xademax@gmail.com>
Date: Sun, 7 Oct 2018 18:38:47 +0100
Subject: [PATCH] Replace call to strncpy by memcpy to fix some GCC8 warnings
---
src/guid.h | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/src/guid.h b/src/guid.h
index d4a06f9..c03a362 100644
--- a/src/guid.h
+++ b/src/guid.h
@@ -103,7 +103,8 @@ text_to_guid(const char *text, efi_guid_t *guid)
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(eightbytes, text, 8);
+ memcpy(eightbytes, text, 8);
+ eightbytes[8] = 0;
if (check_segment_sanity(eightbytes, 8) < 0)
return -1;
guid->a = (uint32_t)strtoul(eightbytes, NULL, 16);
@@ -111,7 +112,8 @@ text_to_guid(const char *text, efi_guid_t *guid)
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(fourbytes, text+9, 4);
+ memcpy(fourbytes, text+9, 4);
+ fourbytes[4] = 0;
if (check_segment_sanity(fourbytes, 4) < 0)
return -1;
guid->b = (uint16_t)strtoul(fourbytes, NULL, 16);
@@ -119,7 +121,8 @@ text_to_guid(const char *text, efi_guid_t *guid)
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(fourbytes, text+14, 4);
+ memcpy(fourbytes, text+14, 4);
+ fourbytes[4] = 0;
if (check_segment_sanity(fourbytes, 4) < 0)
return -1;
guid->c = (uint16_t)strtoul(fourbytes, NULL, 16);
@@ -127,7 +130,8 @@ text_to_guid(const char *text, efi_guid_t *guid)
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(fourbytes, text+19, 4);
+ memcpy(fourbytes, text+19, 4);
+ fourbytes[4] = 0;
if (check_segment_sanity(fourbytes, 4) < 0)
return -1;
guid->d = (uint16_t)strtoul(fourbytes, NULL, 16);
@@ -135,42 +139,48 @@ text_to_guid(const char *text, efi_guid_t *guid)
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(twobytes, text+24, 2);
+ memcpy(twobytes, text+24, 2);
+ twobytes[2] = 0;
if (check_segment_sanity(twobytes, 2) < 0)
return -1;
guid->e[0] = (uint8_t)strtoul(twobytes, NULL, 16);
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(twobytes, text+26, 2);
+ memcpy(twobytes, text+26, 2);
+ twobytes[2] = 0;
if (check_segment_sanity(twobytes, 2) < 0)
return -1;
guid->e[1] = (uint8_t)strtoul(twobytes, NULL, 16);
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(twobytes, text+28, 2);
+ memcpy(twobytes, text+28, 2);
+ twobytes[2] = 0;
if (check_segment_sanity(twobytes, 2) < 0)
return -1;
guid->e[2] = (uint8_t)strtoul(twobytes, NULL, 16);
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(twobytes, text+30, 2);
+ memcpy(twobytes, text+30, 2);
+ twobytes[2] = 0;
if (check_segment_sanity(twobytes, 2) < 0)
return -1;
guid->e[3] = (uint8_t)strtoul(twobytes, NULL, 16);
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(twobytes, text+32, 2);
+ memcpy(twobytes, text+32, 2);
+ twobytes[2] = 0;
if (check_segment_sanity(twobytes, 2) < 0)
return -1;
guid->e[4] = (uint8_t)strtoul(twobytes, NULL, 16);
/* 84be9c3e-8a32-42c0-891c-4cd3b072becc
* ^ */
- strncpy(twobytes, text+34, 2);
+ memcpy(twobytes, text+34, 2);
+ twobytes[2] = 0;
if (check_segment_sanity(twobytes, 2) < 0)
return -1;
guid->e[5] = (uint8_t)strtoul(twobytes, NULL, 16);
--
2.19.0

View file

@ -2,6 +2,7 @@
pkgname=efivar pkgname=efivar
version=36 version=36
revision=1 revision=1
patch_args="-Np1"
build_style=gnu-makefile build_style=gnu-makefile
hostmakedepends="pkg-config" hostmakedepends="pkg-config"
short_desc="Tools to manipulate EFI variables" short_desc="Tools to manipulate EFI variables"
@ -14,10 +15,6 @@ make_build_args="libdir=/usr/lib"
make_build_target="all test" make_build_target="all test"
make_install_args="libdir=/usr/lib" make_install_args="libdir=/usr/lib"
case "$XBPS_TARGET_MACHINE" in
armv*|mips*|aarch*) broken="unsupported arches for UEFI" ;;
esac
CFLAGS="-D_GNU_SOURCE" CFLAGS="-D_GNU_SOURCE"
post_build() { post_build() {