summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2018-05-13 02:33:19 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-08-15 09:22:46 (GMT)
commit7add7e58920ca0addaa444ebad4183ee24987044 (patch)
treead0ba6821e01acc3f98ec18cef641efb4d112429
parent9c8021f2fba059cd03518e5825074b790759d5db (diff)
downloadpoky-7add7e58920ca0addaa444ebad4183ee24987044.tar.gz
ovmf: Fix build with gcc8
(From OE-Core rev: 278b00ddccb274150ed85e48e984675b40fc9aaa) (From OE-Core rev: 2e4a05879f56e96bcdc0770d3fe27abc8b9af35e) (From OE-Core rev: 2b3d976392d53afc3033ddf37d2404d61904bf78) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-core/ovmf/ovmf/0001-BaseTools-header.makefile-add-Wno-stringop-truncatio.patch71
-rw-r--r--meta/recipes-core/ovmf/ovmf/0002-BaseTools-header.makefile-add-Wno-restrict.patch102
-rw-r--r--meta/recipes-core/ovmf/ovmf/0003-BaseTools-header.makefile-revert-gcc-8-Wno-xxx-optio.patch53
-rw-r--r--meta/recipes-core/ovmf/ovmf/0004-BaseTools-GenVtf-silence-false-stringop-overflow-war.patch66
-rw-r--r--meta/recipes-core/ovmf/ovmf_git.bb4
5 files changed, 296 insertions, 0 deletions
diff --git a/meta/recipes-core/ovmf/ovmf/0001-BaseTools-header.makefile-add-Wno-stringop-truncatio.patch b/meta/recipes-core/ovmf/ovmf/0001-BaseTools-header.makefile-add-Wno-stringop-truncatio.patch
new file mode 100644
index 0000000..342fcc6
--- /dev/null
+++ b/meta/recipes-core/ovmf/ovmf/0001-BaseTools-header.makefile-add-Wno-stringop-truncatio.patch
@@ -0,0 +1,71 @@
1From 9fce4bab014b9aa618060eba13d6dd04b0fa1b70 Mon Sep 17 00:00:00 2001
2From: Laszlo Ersek <lersek@redhat.com>
3Date: Fri, 2 Mar 2018 17:11:52 +0100
4Subject: [PATCH 1/4] BaseTools/header.makefile: add "-Wno-stringop-truncation"
5
6gcc-8 (which is part of Fedora 28) enables the new warning
7"-Wstringop-truncation" in "-Wall". This warning is documented in detail
8at <https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html>; the
9introduction says
10
11> Warn for calls to bounded string manipulation functions such as strncat,
12> strncpy, and stpncpy that may either truncate the copied string or leave
13> the destination unchanged.
14
15It breaks the BaseTools build with:
16
17> EfiUtilityMsgs.c: In function 'PrintMessage':
18> EfiUtilityMsgs.c:484:9: error: 'strncat' output may be truncated copying
19> between 0 and 511 bytes from a string of length 511
20> [-Werror=stringop-truncation]
21> strncat (Line, Line2, MAX_LINE_LEN - strlen (Line) - 1);
22> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23> EfiUtilityMsgs.c:469:9: error: 'strncat' output may be truncated copying
24> between 0 and 511 bytes from a string of length 511
25> [-Werror=stringop-truncation]
26> strncat (Line, Line2, MAX_LINE_LEN - strlen (Line) - 1);
27> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28> EfiUtilityMsgs.c:511:5: error: 'strncat' output may be truncated copying
29> between 0 and 511 bytes from a string of length 511
30> [-Werror=stringop-truncation]
31> strncat (Line, Line2, MAX_LINE_LEN - strlen (Line) - 1);
32> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33
34The right way to fix the warning would be to implement string concat with
35snprintf(). However, Microsoft does not appear to support snprintf()
36before VS2015
37<https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010>,
38so we just have to shut up the warning. The strncat() calls flagged above
39are valid BTW.
40
41Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
42Cc: Cole Robinson <crobinso@redhat.com>
43Cc: Liming Gao <liming.gao@intel.com>
44Cc: Paolo Bonzini <pbonzini@redhat.com>
45Cc: Yonghong Zhu <yonghong.zhu@intel.com>
46Contributed-under: TianoCore Contribution Agreement 1.1
47Signed-off-by: Laszlo Ersek <lersek@redhat.com>
48Reviewed-by: Liming Gao <liming.gao@intel.com>
49---
50Signed-off-by: Khem Raj <raj.khem@gmail.com>
51Upstream-Status: Backport
52
53 BaseTools/Source/C/Makefiles/header.makefile | 4 ++--
54 1 file changed, 2 insertions(+), 2 deletions(-)
55
56Index: git/BaseTools/Source/C/Makefiles/header.makefile
57===================================================================
58--- git.orig/BaseTools/Source/C/Makefiles/header.makefile
59+++ git/BaseTools/Source/C/Makefiles/header.makefile
60@@ -47,9 +47,9 @@ INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT)
61 BUILD_CPPFLAGS += $(INCLUDE) -O2
62 ifeq ($(DARWIN),Darwin)
63 # assume clang or clang compatible flags on OS X
64-BUILD_CFLAGS += -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -c -g
65+BUILD_CFLAGS += -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-self-assign -Wno-unused-result -nostdlib -c -g
66 else
67-BUILD_CFLAGS += -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-unused-result -nostdlib -c -g
68+BUILD_CFLAGS += -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-unused-result -nostdlib -c -g
69 endif
70 BUILD_LFLAGS = $(LDFLAGS)
71 BUILD_CXXFLAGS += -Wno-unused-result
diff --git a/meta/recipes-core/ovmf/ovmf/0002-BaseTools-header.makefile-add-Wno-restrict.patch b/meta/recipes-core/ovmf/ovmf/0002-BaseTools-header.makefile-add-Wno-restrict.patch
new file mode 100644
index 0000000..a076665
--- /dev/null
+++ b/meta/recipes-core/ovmf/ovmf/0002-BaseTools-header.makefile-add-Wno-restrict.patch
@@ -0,0 +1,102 @@
1From 86dbdac5a25bd23deb4a0e0a97b527407e02184d Mon Sep 17 00:00:00 2001
2From: Laszlo Ersek <lersek@redhat.com>
3Date: Fri, 2 Mar 2018 17:11:52 +0100
4Subject: [PATCH 2/4] BaseTools/header.makefile: add "-Wno-restrict"
5
6gcc-8 (which is part of Fedora 28) enables the new warning
7"-Wrestrict" in "-Wall". This warning is documented in detail
8at <https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html>; the
9introduction says
10
11> Warn when an object referenced by a restrict-qualified parameter (or, in
12> C++, a __restrict-qualified parameter) is aliased by another argument,
13> or when copies between such objects overlap.
14
15It breaks the BaseTools build (in the Brotli compression library) with:
16
17> In function 'ProcessCommandsInternal',
18> inlined from 'ProcessCommands' at dec/decode.c:1828:10:
19> dec/decode.c:1781:9: error: 'memcpy' accessing between 17 and 2147483631
20> bytes at offsets 16 and 16 overlaps between 17 and 2147483631 bytes at
21> offset 16 [-Werror=restrict]
22> memcpy(copy_dst + 16, copy_src + 16, (size_t)(i - 16));
23> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24> In function 'ProcessCommandsInternal',
25> inlined from 'SafeProcessCommands' at dec/decode.c:1833:10:
26> dec/decode.c:1781:9: error: 'memcpy' accessing between 17 and 2147483631
27> bytes at offsets 16 and 16 overlaps between 17 and 2147483631 bytes at
28> offset 16 [-Werror=restrict]
29> memcpy(copy_dst + 16, copy_src + 16, (size_t)(i - 16));
30> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31
32Paolo Bonzini <pbonzini@redhat.com> analyzed the Brotli source in detail,
33and concluded that the warning is a false positive:
34
35> This seems safe to me, because it's preceded by:
36>
37> uint8_t* copy_dst = &s->ringbuffer[pos];
38> uint8_t* copy_src = &s->ringbuffer[src_start];
39> int dst_end = pos + i;
40> int src_end = src_start + i;
41> if (src_end > pos && dst_end > src_start) {
42> /* Regions intersect. */
43> goto CommandPostWrapCopy;
44> }
45>
46> If [src_start, src_start + i) and [pos, pos + i) don't intersect, then
47> neither do [src_start + 16, src_start + i) and [pos + 16, pos + i).
48>
49> The if seems okay:
50>
51> (src_start + i > pos && pos + i > src_start)
52>
53> which can be rewritten to:
54>
55> (pos < src_start + i && src_start < pos + i)
56>
57> Then the numbers are in one of these two orders:
58>
59> pos <= src_start < pos + i <= src_start + i
60> src_start <= pos < src_start + i <= pos + i
61>
62> These two would be allowed by the "if", but they can only happen if pos
63> == src_start so they degenerate to the same two orders above:
64>
65> pos <= src_start < src_start + i <= pos + i
66> src_start <= pos < pos + i <= src_start + i
67>
68> So it is a false positive in GCC.
69
70Disable the warning for now.
71
72Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
73Cc: Cole Robinson <crobinso@redhat.com>
74Cc: Liming Gao <liming.gao@intel.com>
75Cc: Paolo Bonzini <pbonzini@redhat.com>
76Cc: Yonghong Zhu <yonghong.zhu@intel.com>
77Reported-by: Cole Robinson <crobinso@redhat.com>
78Contributed-under: TianoCore Contribution Agreement 1.1
79Signed-off-by: Laszlo Ersek <lersek@redhat.com>
80Reviewed-by: Liming Gao <liming.gao@intel.com>
81---
82Signed-off-by: Khem Raj <raj.khem@gmail.com>
83Upstream-Status: Backport
84 BaseTools/Source/C/Makefiles/header.makefile | 4 ++--
85 1 file changed, 2 insertions(+), 2 deletions(-)
86
87Index: git/BaseTools/Source/C/Makefiles/header.makefile
88===================================================================
89--- git.orig/BaseTools/Source/C/Makefiles/header.makefile
90+++ git/BaseTools/Source/C/Makefiles/header.makefile
91@@ -47,9 +47,9 @@ INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT)
92 BUILD_CPPFLAGS += $(INCLUDE) -O2
93 ifeq ($(DARWIN),Darwin)
94 # assume clang or clang compatible flags on OS X
95-BUILD_CFLAGS += -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-self-assign -Wno-unused-result -nostdlib -c -g
96+BUILD_CFLAGS += -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict -Wno-self-assign -Wno-unused-result -nostdlib -c -g
97 else
98-BUILD_CFLAGS += -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-unused-result -nostdlib -c -g
99+BUILD_CFLAGS += -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict -Wno-unused-result -nostdlib -c -g
100 endif
101 BUILD_LFLAGS = $(LDFLAGS)
102 BUILD_CXXFLAGS += -Wno-unused-result
diff --git a/meta/recipes-core/ovmf/ovmf/0003-BaseTools-header.makefile-revert-gcc-8-Wno-xxx-optio.patch b/meta/recipes-core/ovmf/ovmf/0003-BaseTools-header.makefile-revert-gcc-8-Wno-xxx-optio.patch
new file mode 100644
index 0000000..920723e
--- /dev/null
+++ b/meta/recipes-core/ovmf/ovmf/0003-BaseTools-header.makefile-revert-gcc-8-Wno-xxx-optio.patch
@@ -0,0 +1,53 @@
1From 6866325dd9c17412e555974dde41f9631224db52 Mon Sep 17 00:00:00 2001
2From: Laszlo Ersek <lersek@redhat.com>
3Date: Wed, 7 Mar 2018 10:17:28 +0100
4Subject: [PATCH 3/4] BaseTools/header.makefile: revert gcc-8 "-Wno-xxx"
5 options on OSX
6
7I recently added the gcc-8 specific "-Wno-stringop-truncation" and
8"-Wno-restrict" options to BUILD_CFLAGS, both for "Darwin" (XCODE5 /
9clang, OSX) and otherwise (gcc, Linux / Cygwin).
10
11I also regression-tested the change with gcc-4.8 on Linux -- gcc-4.8 does
12not know either of the (gcc-8 specific) "-Wno-stringop-truncation" and
13"-Wno-restrict" options, yet the build completed fine (by GCC design).
14
15Regarding OSX, my expectation was that
16
17- XCODE5 / clang would either recognize these warnings options (because
18 clang does recognize most -W options of gcc),
19
20- or, similarly to gcc, clang would simply ignore the "-Wno-xxx" flags
21 that it didn't recognize.
22
23Neither is the case; the new flags have broken the BaseTools build on OSX.
24Revert them (for OSX only).
25
26Cc: Liming Gao <liming.gao@intel.com>
27Cc: Yonghong Zhu <yonghong.zhu@intel.com>
28Reported-by: Liming Gao <liming.gao@intel.com>
29Fixes: 1d212a83df0eaf32a6f5d4159beb2d77832e0231
30Fixes: 9222154ae7b3eef75ae88cdb56158256227cb929
31Contributed-under: TianoCore Contribution Agreement 1.1
32Signed-off-by: Laszlo Ersek <lersek@redhat.com>
33Reviewed-by: Liming Gao <liming.gao@intel.com>
34Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
35---
36Signed-off-by: Khem Raj <raj.khem@gmail.com>
37Upstream-Status: Backport
38 BaseTools/Source/C/Makefiles/header.makefile | 2 +-
39 1 file changed, 1 insertion(+), 1 deletion(-)
40
41Index: git/BaseTools/Source/C/Makefiles/header.makefile
42===================================================================
43--- git.orig/BaseTools/Source/C/Makefiles/header.makefile
44+++ git/BaseTools/Source/C/Makefiles/header.makefile
45@@ -47,7 +47,7 @@ INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT)
46 BUILD_CPPFLAGS += $(INCLUDE) -O2
47 ifeq ($(DARWIN),Darwin)
48 # assume clang or clang compatible flags on OS X
49-BUILD_CFLAGS += -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict -Wno-self-assign -Wno-unused-result -nostdlib -c -g
50+BUILD_CFLAGS += -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -c -g
51 else
52 BUILD_CFLAGS += -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict -Wno-unused-result -nostdlib -c -g
53 endif
diff --git a/meta/recipes-core/ovmf/ovmf/0004-BaseTools-GenVtf-silence-false-stringop-overflow-war.patch b/meta/recipes-core/ovmf/ovmf/0004-BaseTools-GenVtf-silence-false-stringop-overflow-war.patch
new file mode 100644
index 0000000..7ad7cdf
--- /dev/null
+++ b/meta/recipes-core/ovmf/ovmf/0004-BaseTools-GenVtf-silence-false-stringop-overflow-war.patch
@@ -0,0 +1,66 @@
1From dfb42a5bff78d9239a80731e337855234badef3e Mon Sep 17 00:00:00 2001
2From: Laszlo Ersek <lersek@redhat.com>
3Date: Fri, 2 Mar 2018 17:11:52 +0100
4Subject: [PATCH 4/4] BaseTools/GenVtf: silence false "stringop-overflow"
5 warning with memcpy()
6
7gcc-8 (which is part of Fedora 28) enables the new warning
8"-Wstringop-overflow" in "-Wall". This warning is documented in detail at
9<https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html>; the
10introduction says
11
12> Warn for calls to string manipulation functions such as memcpy and
13> strcpy that are determined to overflow the destination buffer.
14
15It breaks the BaseTools build with:
16
17> GenVtf.c: In function 'ConvertVersionInfo':
18> GenVtf.c:132:7: error: 'strncpy' specified bound depends on the length
19> of the source argument [-Werror=stringop-overflow=]
20> strncpy (TemStr + 4 - Length, Str, Length);
21> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22> GenVtf.c:130:14: note: length computed here
23> Length = strlen(Str);
24> ^~~~~~~~~~~
25
26It is a false positive because, while the bound equals the length of the
27source argument, the destination pointer is moved back towards the
28beginning of the destination buffer by the same amount (and this amount is
29range-checked first, so we can't precede the start of the dest buffer).
30
31Replace both strncpy() calls with memcpy().
32
33Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
34Cc: Cole Robinson <crobinso@redhat.com>
35Cc: Liming Gao <liming.gao@intel.com>
36Cc: Paolo Bonzini <pbonzini@redhat.com>
37Cc: Yonghong Zhu <yonghong.zhu@intel.com>
38Reported-by: Cole Robinson <crobinso@redhat.com>
39Contributed-under: TianoCore Contribution Agreement 1.1
40Signed-off-by: Laszlo Ersek <lersek@redhat.com>
41Reviewed-by: Liming Gao <liming.gao@intel.com>
42---
43Signed-off-by: Khem Raj <raj.khem@gmail.com>
44Upstream-Status: Backport
45 BaseTools/Source/C/GenVtf/GenVtf.c | 4 ++--
46 1 file changed, 2 insertions(+), 2 deletions(-)
47
48diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c b/BaseTools/Source/C/GenVtf/GenVtf.c
49index 2ae9a7be2c..0cd33e71e9 100644
50--- a/BaseTools/Source/C/GenVtf/GenVtf.c
51+++ b/BaseTools/Source/C/GenVtf/GenVtf.c
52@@ -129,9 +129,9 @@ Returns:
53 } else {
54 Length = strlen(Str);
55 if (Length < 4) {
56- strncpy (TemStr + 4 - Length, Str, Length);
57+ memcpy (TemStr + 4 - Length, Str, Length);
58 } else {
59- strncpy (TemStr, Str + Length - 4, 4);
60+ memcpy (TemStr, Str + Length - 4, 4);
61 }
62
63 sscanf (
64--
652.17.0
66
diff --git a/meta/recipes-core/ovmf/ovmf_git.bb b/meta/recipes-core/ovmf/ovmf_git.bb
index fa0d662..692f80a 100644
--- a/meta/recipes-core/ovmf/ovmf_git.bb
+++ b/meta/recipes-core/ovmf/ovmf_git.bb
@@ -19,6 +19,10 @@ SRC_URI = "git://github.com/tianocore/edk2.git;branch=master \
19 file://0004-ovmf-enable-long-path-file.patch \ 19 file://0004-ovmf-enable-long-path-file.patch \
20 file://VfrCompile-increase-path-length-limit.patch \ 20 file://VfrCompile-increase-path-length-limit.patch \
21 file://no-stack-protector-all-archs.patch \ 21 file://no-stack-protector-all-archs.patch \
22 file://0001-BaseTools-header.makefile-add-Wno-stringop-truncatio.patch \
23 file://0002-BaseTools-header.makefile-add-Wno-restrict.patch \
24 file://0003-BaseTools-header.makefile-revert-gcc-8-Wno-xxx-optio.patch \
25 file://0004-BaseTools-GenVtf-silence-false-stringop-overflow-war.patch \
22 " 26 "
23UPSTREAM_VERSION_UNKNOWN = "1" 27UPSTREAM_VERSION_UNKNOWN = "1"
24 28