1From df4d2000a22db673a788b8e57e8e7c0cc3cee777 Mon Sep 17 00:00:00 2001
2From: Leonard Chan <leonardchan@google.com>
3Date: Thu, 3 Oct 2019 18:53:04 -0700
4Subject: [PATCH] Make vboot_version extern in header
5
6When enabling `-fno-common` in Fuchsia, we get a bunch of linker errors
7when linking futility:
8
9```
10ld.lld: error: duplicate symbol: vboot_version
11>>> defined at futility.h:43 (../../third_party/vboot_reference/futility/futility.h:43)
12>>>            host_x63-asan_no_detect_leaks/obj/third_party/vboot_reference/futility/futility.cmd_bdb.c.o:(vboot_version)
13>>> defined at futility.h:43 (../../third_party/vboot_reference/futility/futility.h:43)
14>>>            host_x64-asan_no_detect_leaks/obj/third_party/vboot_reference/futility/futility.cmd_create.c.o:(.bss.vboot_version+0x0)
15```
16
17and think this is because -fno-common places vboot_version for
18unitialized global variables in the BSS section of each object file.
19Making it extern instead resolves each reference to its definition in
20futility/misc.c.
21
22Change-Id: I591f07abd1f975a8a9d078bb4366e2e0861390b4
23Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1839207
24Reviewed-by: Julius Werner <jwerner@chromium.org>
25Reviewed-by: Joel Kitching <kitching@chromium.org>
26Commit-Queue: Julius Werner <jwerner@chromium.org>
27Tested-by: Julius Werner <jwerner@chromium.org>
28
29Patch taken from upstream: https://chromium.googlesource.com/chromiumos/platform/vboot_reference/+/df4d2000a22db673a788b8e57e8e7c0cc3cee777
30Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
31---
32 futility/futility.h | 2 +-
33 1 file changed, 1 insertion(+), 1 deletion(-)
34
35diff --git a/futility/futility.h b/futility/futility.h
36index 3bce1106..5dc426dd 100644
37--- a/futility/futility.h
38+++ b/futility/futility.h
39@@ -41,7 +41,7 @@ enum vboot_version  {
40 };
41
42 /* What's our preferred API & data format? */
43-enum vboot_version vboot_version;
44+extern enum vboot_version vboot_version;
45
46 /* Here's a structure to define the commands that futility implements. */
47 struct futil_cmd_t {
48--
492.20.1
50
51