diff options
| author | Khem Raj <raj.khem@gmail.com> | 2022-05-13 09:22:44 -0700 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-06-07 11:53:26 +0100 |
| commit | cd23b8349e8b7a6f4d0e45aa328ad13aae9771df (patch) | |
| tree | ef64f38d1104cd9ebc1bfd0ee8f05dc9bc8e1b14 /meta | |
| parent | c9b490e16211c3766ee9a66fa25aaf5398fe9646 (diff) | |
| download | poky-cd23b8349e8b7a6f4d0e45aa328ad13aae9771df.tar.gz | |
ovmf: Fix native build with gcc-12
Host distros have started deploying gcc12 as well e.g. archlinux
this build failure shows up which has been fixed upstream
In function ‘GetAlignmentFromFile’,
inlined from ‘main’ at GenFfs.c:816:20:
GenFfs.c:545:5: error: pointer ‘InFileHandle’ used after ‘fclose’ [-Werror=use-after-free]
545 | Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFileHandle);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(From OE-Core rev: d28d84c5b43ffcc312808af085d949e403805aca)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 7b67f19d353d88107f52cceda3c858730ac1db54)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
3 files changed, 106 insertions, 0 deletions
diff --git a/meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch b/meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch new file mode 100644 index 0000000000..23366b4d07 --- /dev/null +++ b/meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | From b0a0b7b605aeb8106e7b50d1efeb746f401498cc Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Gerd Hoffmann <kraxel@redhat.com> | ||
| 3 | Date: Thu, 24 Mar 2022 20:04:35 +0800 | ||
| 4 | Subject: [PATCH] BaseTools: fix gcc12 warning | ||
| 5 | |||
| 6 | Sdk/C/LzmaEnc.c: In function ?LzmaEnc_CodeOneMemBlock?: | ||
| 7 | Sdk/C/LzmaEnc.c:2828:19: error: storing the address of local variable ?outStream? in ?*p.rc.outStream? [-Werror=dangling-pointer=] | ||
| 8 | 2828 | p->rc.outStream = &outStream.vt; | ||
| 9 | | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~ | ||
| 10 | Sdk/C/LzmaEnc.c:2811:28: note: ?outStream? declared here | ||
| 11 | 2811 | CLzmaEnc_SeqOutStreamBuf outStream; | ||
| 12 | | ^~~~~~~~~ | ||
| 13 | Sdk/C/LzmaEnc.c:2811:28: note: ?pp? declared here | ||
| 14 | Sdk/C/LzmaEnc.c:2828:19: error: storing the address of local variable ?outStream? in ?*(CLzmaEnc *)pp.rc.outStream? [-Werror=dangling-pointer=] | ||
| 15 | 2828 | p->rc.outStream = &outStream.vt; | ||
| 16 | | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~ | ||
| 17 | Sdk/C/LzmaEnc.c:2811:28: note: ?outStream? declared here | ||
| 18 | 2811 | CLzmaEnc_SeqOutStreamBuf outStream; | ||
| 19 | | ^~~~~~~~~ | ||
| 20 | Sdk/C/LzmaEnc.c:2811:28: note: ?pp? declared here | ||
| 21 | cc1: all warnings being treated as errors | ||
| 22 | |||
| 23 | Upstream-Status: Backport [https://github.com/tianocore/edk2/commit/85021f8cf22d1bd4114803c6c610dea5ef0059f1] | ||
| 24 | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> | ||
| 25 | Reviewed-by: Bob Feng <bob.c.feng@intel.com> | ||
| 26 | --- | ||
| 27 | BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | 3 ++- | ||
| 28 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
| 29 | |||
| 30 | diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | ||
| 31 | index 4e9b499f8d..4b9f5fa692 100644 | ||
| 32 | --- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | ||
| 33 | +++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | ||
| 34 | @@ -2825,12 +2825,13 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit, | ||
| 35 | |||
| 36 | nowPos64 = p->nowPos64; | ||
| 37 | RangeEnc_Init(&p->rc); | ||
| 38 | - p->rc.outStream = &outStream.vt; | ||
| 39 | |||
| 40 | if (desiredPackSize == 0) | ||
| 41 | return SZ_ERROR_OUTPUT_EOF; | ||
| 42 | |||
| 43 | + p->rc.outStream = &outStream.vt; | ||
| 44 | res = LzmaEnc_CodeOneBlock(p, desiredPackSize, *unpackSize); | ||
| 45 | + p->rc.outStream = NULL; | ||
| 46 | |||
| 47 | *unpackSize = (UInt32)(p->nowPos64 - nowPos64); | ||
| 48 | *destLen -= outStream.rem; | ||
| 49 | -- | ||
| 50 | 2.36.1 | ||
| 51 | |||
diff --git a/meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch b/meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch new file mode 100644 index 0000000000..91c01647db --- /dev/null +++ b/meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | From 2435c17e56652479315853cec5b91fb0ea0911a3 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Gerd Hoffmann <kraxel@redhat.com> | ||
| 3 | Date: Thu, 24 Mar 2022 20:04:34 +0800 | ||
| 4 | Subject: [PATCH] BaseTools: fix gcc12 warning | ||
| 5 | |||
| 6 | GenFfs.c:545:5: error: pointer ?InFileHandle? used after ?fclose? [-Werror=use-after-free] | ||
| 7 | 545 | Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFileHandle); | ||
| 8 | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 9 | GenFfs.c:544:5: note: call to ?fclose? here | ||
| 10 | 544 | fclose (InFileHandle); | ||
| 11 | | ^~~~~~~~~~~~~~~~~~~~~ | ||
| 12 | |||
| 13 | Upstream-Status: Backport [https://github.com/tianocore/edk2/commit/7b005f344e533cd913c3ca05b266f9872df886d1] | ||
| 14 | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> | ||
| 15 | Reviewed-by: Bob Feng <bob.c.feng@intel.com> | ||
| 16 | --- | ||
| 17 | BaseTools/Source/C/GenFfs/GenFfs.c | 2 +- | ||
| 18 | BaseTools/Source/C/GenSec/GenSec.c | 2 +- | ||
| 19 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
| 20 | |||
| 21 | diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c b/BaseTools/Source/C/GenFfs/GenFfs.c | ||
| 22 | index 949025c333..d78d62ab36 100644 | ||
| 23 | --- a/BaseTools/Source/C/GenFfs/GenFfs.c | ||
| 24 | +++ b/BaseTools/Source/C/GenFfs/GenFfs.c | ||
| 25 | @@ -542,7 +542,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment) | ||
| 26 | PeFileBuffer = (UINT8 *) malloc (PeFileSize); | ||
| 27 | if (PeFileBuffer == NULL) { | ||
| 28 | fclose (InFileHandle); | ||
| 29 | - Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFileHandle); | ||
| 30 | + Error(NULL, 0, 4001, "Resource", "memory cannot be allocated for %s", InFile); | ||
| 31 | return EFI_OUT_OF_RESOURCES; | ||
| 32 | } | ||
| 33 | fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle); | ||
| 34 | diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec/GenSec.c | ||
| 35 | index d54a4f9e0a..b1d05367ec 100644 | ||
| 36 | --- a/BaseTools/Source/C/GenSec/GenSec.c | ||
| 37 | +++ b/BaseTools/Source/C/GenSec/GenSec.c | ||
| 38 | @@ -1062,7 +1062,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment) | ||
| 39 | PeFileBuffer = (UINT8 *) malloc (PeFileSize); | ||
| 40 | if (PeFileBuffer == NULL) { | ||
| 41 | fclose (InFileHandle); | ||
| 42 | - Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFileHandle); | ||
| 43 | + Error(NULL, 0, 4001, "Resource", "memory cannot be allocated for %s", InFile); | ||
| 44 | return EFI_OUT_OF_RESOURCES; | ||
| 45 | } | ||
| 46 | fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle); | ||
| 47 | -- | ||
| 48 | 2.36.1 | ||
| 49 | |||
diff --git a/meta/recipes-core/ovmf/ovmf_git.bb b/meta/recipes-core/ovmf/ovmf_git.bb index b15d40eac8..84e3360a3a 100644 --- a/meta/recipes-core/ovmf/ovmf_git.bb +++ b/meta/recipes-core/ovmf/ovmf_git.bb | |||
| @@ -15,12 +15,18 @@ PACKAGECONFIG += "${@bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'tpm', '', d) | |||
| 15 | PACKAGECONFIG[secureboot] = ",,," | 15 | PACKAGECONFIG[secureboot] = ",,," |
| 16 | PACKAGECONFIG[tpm] = "-D TPM_ENABLE=TRUE,-D TPM_ENABLE=FALSE,," | 16 | PACKAGECONFIG[tpm] = "-D TPM_ENABLE=TRUE,-D TPM_ENABLE=FALSE,," |
| 17 | 17 | ||
| 18 | # GCC12 trips on it | ||
| 19 | #see https://src.fedoraproject.org/rpms/edk2/blob/rawhide/f/0032-Basetools-turn-off-gcc12-warning.patch | ||
| 20 | BUILD_CFLAGS += "-Wno-error=stringop-overflow" | ||
| 21 | |||
| 18 | SRC_URI = "gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https \ | 22 | SRC_URI = "gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https \ |
| 19 | file://0001-ovmf-update-path-to-native-BaseTools.patch \ | 23 | file://0001-ovmf-update-path-to-native-BaseTools.patch \ |
| 20 | file://0002-BaseTools-makefile-adjust-to-build-in-under-bitbake.patch \ | 24 | file://0002-BaseTools-makefile-adjust-to-build-in-under-bitbake.patch \ |
| 21 | file://0003-ovmf-Update-to-latest.patch \ | 25 | file://0003-ovmf-Update-to-latest.patch \ |
| 22 | file://0005-debug-prefix-map.patch \ | 26 | file://0005-debug-prefix-map.patch \ |
| 23 | file://0006-reproducible.patch \ | 27 | file://0006-reproducible.patch \ |
| 28 | file://0001-BaseTools-fix-gcc12-warning.patch \ | ||
| 29 | file://0001-BaseTools-fix-gcc12-warning-1.patch \ | ||
| 24 | " | 30 | " |
| 25 | 31 | ||
| 26 | PV = "edk2-stable202202" | 32 | PV = "edk2-stable202202" |
