vboot: add weak __attribute__ tag to stub functions

Function stubs in vboot2 namespace are all marked with
__attribute__((weak)) tags, whereas those in vboot1
are not.  Add the tag to stubs in vboot1 for consistency.

BUG=b:124141368, chromium:968464
TEST=make clean && make runtests
BRANCH=none

Signed-off-by: Joel Kitching <kitching@google.com>
Change-Id: I8e54ef82882bd80720f810c17f41e902af244ead
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2635673
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
diff --git a/firmware/stub/vboot_api_stub.c b/firmware/stub/vboot_api_stub.c
index fe1c13d..f5bc9fc 100644
--- a/firmware/stub/vboot_api_stub.c
+++ b/firmware/stub/vboot_api_stub.c
@@ -18,65 +18,78 @@
 #include "vboot_api.h"
 #include "vboot_test.h"
 
+__attribute__((weak))
 void vb2ex_msleep(uint32_t msec)
 {
 }
 
+__attribute__((weak))
 void vb2ex_beep(uint32_t msec, uint32_t frequency)
 {
 }
 
+__attribute__((weak))
 uint32_t vb2ex_get_locale_count(void)
 {
 	return 0;
 }
 
+__attribute__((weak))
 uint32_t vb2ex_get_bootloader_count(void)
 {
 	return 0;
 }
 
+__attribute__((weak))
 uint32_t VbExKeyboardRead(void)
 {
 	return 0;
 }
 
+__attribute__((weak))
 uint32_t VbExKeyboardReadWithFlags(uint32_t *flags_ptr)
 {
 	return 0;
 }
 
+__attribute__((weak))
 int vb2ex_physical_presence_pressed(void)
 {
 	return 0;
 }
 
+__attribute__((weak))
 uint32_t VbExIsShutdownRequested(void)
 {
 	return 0;
 }
 
+__attribute__((weak))
 int vb2ex_ec_trusted(void)
 {
 	return 1;
 }
 
+__attribute__((weak))
 vb2_error_t vb2ex_ec_running_rw(int *in_rw)
 {
 	*in_rw = 0;
 	return VB2_SUCCESS;
 }
 
+__attribute__((weak))
 vb2_error_t vb2ex_ec_jump_to_rw(void)
 {
 	return VB2_SUCCESS;
 }
 
+__attribute__((weak))
 vb2_error_t vb2ex_ec_disable_jump(void)
 {
 	return VB2_SUCCESS;
 }
 
+__attribute__((weak))
 vb2_error_t vb2ex_ec_hash_image(enum vb2_firmware_selection select,
 				const uint8_t **hash, int *hash_size)
 {
@@ -87,6 +100,7 @@
 	return VB2_SUCCESS;
 }
 
+__attribute__((weak))
 vb2_error_t vb2ex_ec_get_expected_image_hash(enum vb2_firmware_selection select,
 					     const uint8_t **hash, int *hash_size)
 {
@@ -97,37 +111,44 @@
 	return VB2_SUCCESS;
 }
 
+__attribute__((weak))
 vb2_error_t vb2ex_ec_update_image(enum vb2_firmware_selection select)
 {
 	return VB2_SUCCESS;
 }
 
+__attribute__((weak))
 vb2_error_t vb2ex_ec_protect(enum vb2_firmware_selection select)
 {
 	return VB2_SUCCESS;
 }
 
+__attribute__((weak))
 vb2_error_t vb2ex_ec_vboot_done(struct vb2_context *ctx)
 {
 	return VB2_SUCCESS;
 }
 
+__attribute__((weak))
 vb2_error_t vb2ex_ec_battery_cutoff(void)
 {
 	return VB2_SUCCESS;
 }
 
+__attribute__((weak))
 vb2_error_t vb2ex_auxfw_check(enum vb2_auxfw_update_severity *severity)
 {
 	*severity = VB2_AUXFW_NO_UPDATE;
 	return VB2_SUCCESS;
 }
 
+__attribute__((weak))
 vb2_error_t vb2ex_auxfw_update(void)
 {
 	return VB2_SUCCESS;
 }
 
+__attribute__((weak))
 vb2_error_t VbExLegacy(enum VbAltFwIndex_t altfw_num)
 {
 	return VB2_SUCCESS;
diff --git a/firmware/stub/vboot_api_stub_disk.c b/firmware/stub/vboot_api_stub_disk.c
index 7dc413f..3244dc6 100644
--- a/firmware/stub/vboot_api_stub_disk.c
+++ b/firmware/stub/vboot_api_stub_disk.c
@@ -16,6 +16,7 @@
 #include "vboot_api.h"
 
 
+__attribute__((weak))
 vb2_error_t VbExDiskGetInfo(VbDiskInfo** infos_ptr, uint32_t* count,
 			    uint32_t disk_flags)
 {
@@ -25,6 +26,7 @@
 }
 
 
+__attribute__((weak))
 vb2_error_t VbExDiskFreeInfo(VbDiskInfo* infos_ptr,
 			     VbExDiskHandle_t preserve_handle)
 {
@@ -32,6 +34,7 @@
 }
 
 
+__attribute__((weak))
 vb2_error_t VbExDiskRead(VbExDiskHandle_t handle, uint64_t lba_start,
 			 uint64_t lba_count, void* buffer)
 {
@@ -39,6 +42,7 @@
 }
 
 
+__attribute__((weak))
 vb2_error_t VbExDiskWrite(VbExDiskHandle_t handle, uint64_t lba_start,
 			  uint64_t lba_count, const void* buffer)
 {
diff --git a/firmware/stub/vboot_api_stub_init.c b/firmware/stub/vboot_api_stub_init.c
index bd5c0c2..8fffc05 100644
--- a/firmware/stub/vboot_api_stub_init.c
+++ b/firmware/stub/vboot_api_stub_init.c
@@ -13,6 +13,7 @@
 #include "2common.h"
 #include "vboot_api.h"
 
+__attribute__((weak))
 uint32_t vb2ex_mtime(void)
 {
 	struct timeval tv;
@@ -20,6 +21,7 @@
 	return tv.tv_sec * VB2_MSEC_PER_SEC + tv.tv_usec / VB2_USEC_PER_MSEC;
 }
 
+__attribute__((weak))
 vb2_error_t vb2ex_commit_data(struct vb2_context *ctx)
 {
 	ctx->flags &= ~VB2_CONTEXT_SECDATA_FIRMWARE_CHANGED;
diff --git a/firmware/stub/vboot_api_stub_stream.c b/firmware/stub/vboot_api_stub_stream.c
index ae0a674..68e7ec7 100644
--- a/firmware/stub/vboot_api_stub_stream.c
+++ b/firmware/stub/vboot_api_stub_stream.c
@@ -25,6 +25,7 @@
 	uint64_t sectors_left;
 };
 
+__attribute__((weak))
 vb2_error_t VbExStreamOpen(VbExDiskHandle_t handle, uint64_t lba_start,
 			   uint64_t lba_count, VbExStream_t *stream)
 {
@@ -45,6 +46,7 @@
 	return VB2_SUCCESS;
 }
 
+__attribute__((weak))
 vb2_error_t VbExStreamRead(VbExStream_t stream, uint32_t bytes, void *buffer)
 {
 	struct disk_stream *s = (struct disk_stream *)stream;
@@ -73,6 +75,7 @@
 	return VB2_SUCCESS;
 }
 
+__attribute__((weak))
 void VbExStreamClose(VbExStream_t stream)
 {
 	struct disk_stream *s = (struct disk_stream *)stream;