mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
Add CONFIG_LTO to use GCC Link-Time Optimizations to try to reduce the flash footprint of the firmware. Add additional protection to some functions/data to avoid removal by the linker when their usage is not obvious. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=make buildall (with and without LTO enable on all boards) Change-Id: I586b8c1eda4592b416c85383b65153c1d5ab0059 Reviewed-on: https://chromium-review.googlesource.com/271291 Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
54 lines
1.1 KiB
C
54 lines
1.1 KiB
C
/* Copyright (c) 2012 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.
|
|
*/
|
|
|
|
/* Embed firmware version number in the binary */
|
|
|
|
#include <stdint.h>
|
|
#include "common.h"
|
|
#include "ec_date.h"
|
|
#include "ec_version.h"
|
|
#include "version.h"
|
|
|
|
const struct version_struct __keep version_data
|
|
__attribute__((section(".rodata.ver"))) = {
|
|
CROS_EC_VERSION_COOKIE1,
|
|
CROS_EC_VERSION32,
|
|
CROS_EC_VERSION_COOKIE2
|
|
};
|
|
|
|
const char build_info[] __keep __attribute__((section(".rodata.buildinfo"))) =
|
|
CROS_EC_VERSION " " DATE " " BUILDER;
|
|
|
|
uint32_t ver_get_numcommits(void)
|
|
{
|
|
int i;
|
|
int numperiods = 0;
|
|
uint32_t ret = 0;
|
|
|
|
/*
|
|
* Version string is formatted like:
|
|
* name_major.branch.numcommits-hash[dirty]
|
|
* we want to return the numcommits as an int.
|
|
*/
|
|
for (i = 0; i < 32; i++) {
|
|
if (version_data.version[i] == '.') {
|
|
numperiods++;
|
|
if (numperiods == 2)
|
|
break;
|
|
}
|
|
}
|
|
|
|
i++;
|
|
for (; i < 32; i++) {
|
|
if (version_data.version[i] == '-')
|
|
break;
|
|
ret *= 10;
|
|
ret += version_data.version[i] - '0';
|
|
}
|
|
|
|
return (i == 32 ? 0 : ret);
|
|
}
|
|
|