mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
fix(core & legacy): better styled compiler checks
This commit is contained in:
parent
6b849b1d4d
commit
6ea4b7b211
@ -21,6 +21,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "compiler_traits.h"
|
||||
#include "display.h"
|
||||
#include "flash.h"
|
||||
#include "image.h"
|
||||
@ -36,20 +37,6 @@
|
||||
#include "messages.h"
|
||||
// #include "mpu.h"
|
||||
|
||||
/*
|
||||
* Avoid accidental build with gcc versions having broken stack protector 9.2.1 - 10.2
|
||||
*/
|
||||
#if defined(__GNUC__) && !defined(__llvm__)
|
||||
|
||||
#define GCC_VERSION (__GNUC__ * 10000 \
|
||||
+ __GNUC_MINOR__ * 100 \
|
||||
+ __GNUC_PATCHLEVEL__)
|
||||
|
||||
#if GCC_VERSION >= 90201 && GCC_VERSION <= 100200
|
||||
#error "ARM GCC versions 9.2.1 - 10.2 have broken stack smash protector, preventing build"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
const uint8_t BOOTLOADER_KEY_M = 2;
|
||||
const uint8_t BOOTLOADER_KEY_N = 3;
|
||||
static const uint8_t * const BOOTLOADER_KEYS[] = {
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "bl_check.h"
|
||||
#include "button.h"
|
||||
#include "common.h"
|
||||
#include "compiler_traits.h"
|
||||
#include "display.h"
|
||||
#include "flash.h"
|
||||
#include "mpu.h"
|
||||
@ -53,20 +54,6 @@
|
||||
// from util.s
|
||||
extern void shutdown_privileged(void);
|
||||
|
||||
/*
|
||||
* Avoid accidental build with gcc versions having broken stack protector 9.2.1 - 10.2
|
||||
*/
|
||||
#if defined(__GNUC__) && !defined(__llvm__)
|
||||
|
||||
#define GCC_VERSION (__GNUC__ * 10000 \
|
||||
+ __GNUC_MINOR__ * 100 \
|
||||
+ __GNUC_PATCHLEVEL__)
|
||||
|
||||
#if GCC_VERSION >= 90201 && GCC_VERSION <= 100200
|
||||
#error "ARM GCC versions 9.2.1 - 10.2 have broken stack smash protector, preventing build"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int main(void) {
|
||||
random_delays_init();
|
||||
|
||||
|
38
core/embed/trezorhal/compiler_traits.h
Normal file
38
core/embed/trezorhal/compiler_traits.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is part of the Trezor project, https://trezor.io/
|
||||
*
|
||||
* Copyright (c) SatoshiLabs
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __COMPILER_TRAITS_H__
|
||||
#define __COMPILER_TRAITS_H__
|
||||
|
||||
/*
|
||||
* Avoid accidental build with gcc versions having broken stack protector 9.2.1 - 10.2
|
||||
*/
|
||||
#if defined(__GNUC__) && !defined(__llvm__)
|
||||
|
||||
#define GCC_VERSION (__GNUC__ * 10000 \
|
||||
+ __GNUC_MINOR__ * 100 \
|
||||
+ __GNUC_PATCHLEVEL__)
|
||||
|
||||
#if GCC_VERSION >= 90201 && GCC_VERSION <= 100200
|
||||
#pragma message "Only remove this GCC check if you are sure your compiler is patched or not used for production."
|
||||
#error "ARM GCC versions 9.2.1 - 10.2 have broken stack smash protector, aborting build."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "bootloader.h"
|
||||
#include "buttons.h"
|
||||
#include "compiler_traits.h"
|
||||
#include "layout.h"
|
||||
#include "memory.h"
|
||||
#include "oled.h"
|
||||
|
39
legacy/compiler_traits.h
Normal file
39
legacy/compiler_traits.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of the Trezor project, https://trezor.io/
|
||||
*
|
||||
* Copyright (c) SatoshiLabs
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __COMPILER_TRAITS_H__
|
||||
#define __COMPILER_TRAITS_H__
|
||||
|
||||
/*
|
||||
* Avoid accidental build with gcc versions having broken stack protector 9.2.1 - 10.2
|
||||
*/
|
||||
#if defined(__GNUC__) && !defined(__llvm__)
|
||||
|
||||
#define GCC_VERSION (__GNUC__ * 10000 \
|
||||
+ __GNUC_MINOR__ * 100 \
|
||||
+ __GNUC_PATCHLEVEL__)
|
||||
|
||||
#if GCC_VERSION >= 90201 && GCC_VERSION <= 100200
|
||||
#pragma message "Only remove this GCC check if you are sure your compiler is patched or not used for production."
|
||||
#error "ARM GCC versions 9.2.1 - 10.2 have broken stack smash protector, aborting build."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "bl_check.h"
|
||||
#include "buttons.h"
|
||||
#include "common.h"
|
||||
#include "compiler_traits.h"
|
||||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
#include "layout.h"
|
||||
@ -38,20 +39,6 @@
|
||||
#include "otp.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Avoid accidental build with gcc versions having broken stack protector 9.2.1 - 10.2
|
||||
*/
|
||||
#if defined(__GNUC__) && !defined(__llvm__)
|
||||
|
||||
#define GCC_VERSION (__GNUC__ * 10000 \
|
||||
+ __GNUC_MINOR__ * 100 \
|
||||
+ __GNUC_PATCHLEVEL__)
|
||||
|
||||
#if GCC_VERSION >= 90201 && GCC_VERSION <= 100200
|
||||
#error "ARM GCC versions 9.2.1 - 10.2 have broken stack smash protector, preventing build"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Screen timeout */
|
||||
uint32_t system_millis_lock_start = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user