From 91852e7f58d50a031bcb5c02e68473cefb10ebb0 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Fri, 28 Nov 2014 12:28:04 -0800 Subject: [PATCH] futility: workaround for broken toolchain in static builds The cros-compiler doesn't support backtrace(3) when linked statically. Until that's fixed, just don't use it. BUG=chromium:437107 BRANCH=ToT, samus TEST=manual FEATURES=test emerge-link vboot_reference /build/link/usr/bin/futility_s gbb_utility -c 100,100,100,100 test.bin /build/link/usr/bin/futility_s gbb_utility -s --hwid=HEY test.bin Change-Id: I66b76fc8c0aa92f95976c5d5015f62730bb12064 Signed-off-by: Bill Richardson Reviewed-on: https://chromium-review.googlesource.com/232234 Reviewed-by: Mike Frysinger --- Makefile | 4 +++ firmware/stub/vboot_api_stub_static_sf.c | 39 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 firmware/stub/vboot_api_stub_static_sf.c diff --git a/Makefile b/Makefile index e18679f526..dbd89253c3 100644 --- a/Makefile +++ b/Makefile @@ -566,7 +566,11 @@ endif FUTIL_STATIC_CMD_LIST = ${BUILD}/gen/futility_static_cmds.c FUTIL_CMD_LIST = ${BUILD}/gen/futility_cmds.c +# Workaround for TODO(crbug.com/437107). +FUTIL_STATIC_WORKAROUND_SRCS = firmware/stub/vboot_api_stub_static_sf.c + FUTIL_STATIC_OBJS = ${FUTIL_STATIC_SRCS:%.c=${BUILD}/%.o} \ + ${FUTIL_STATIC_WORKAROUND_SRCS:%.c=${BUILD}/%.o} \ ${FUTIL_STATIC_CMD_LIST:%.c=%.o} FUTIL_OBJS = ${FUTIL_SRCS:%.c=${BUILD}/%.o} ${FUTIL_CMD_LIST:%.c=%.o} diff --git a/firmware/stub/vboot_api_stub_static_sf.c b/firmware/stub/vboot_api_stub_static_sf.c new file mode 100644 index 0000000000..c266177db5 --- /dev/null +++ b/firmware/stub/vboot_api_stub_static_sf.c @@ -0,0 +1,39 @@ +/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Workaround for TODO(crbug.com/437107). Remove this file when it's fixed. + */ + +#define _STUB_IMPLEMENTATION_ + +#include +#include + +#include "vboot_api.h" + +void *VbExMalloc(size_t size) +{ + void *p = malloc(size); + + if (!p) { + /* Fatal Error. We must abort. */ + abort(); + } + + return p; +} +void VbExFree(void *ptr) +{ + free(ptr); +} + + +/* + * This file should be used only when building the static version of futility, + * so let's intentionally break any tests that link with it by accident. + */ +int vboot_api_stub_check_memory(void) +{ + return -1; +}