lib: Add ASan stub

Add a Kconfig option to enable address sanitizer on x86 architecture.
Create ASan dummy functions. And add relevant gcc flags to compile
ramstage with ASan.

Change-Id: I6d87e48b6786f02dd46ea74e702f294082fd8891
Signed-off-by: Harshit Sharma <harshitsharmajs@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/42271
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
This commit is contained in:
Harshit Sharma
2020-06-09 20:25:16 -07:00
committed by Patrick Georgi
parent 693f4a4179
commit 2bcaba0fd4
3 changed files with 59 additions and 0 deletions

34
src/lib/asan.c Normal file
View File

@@ -0,0 +1,34 @@
#include <stddef.h>
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
#define DEFINE_ASAN_LOAD_STORE(size) \
void __asan_load##size(unsigned long addr) \
{} \
void __asan_load##size##_noabort(unsigned long addr) \
{} \
void __asan_store##size(unsigned long addr) \
{} \
void __asan_store##size##_noabort(unsigned long addr) \
{}
DEFINE_ASAN_LOAD_STORE(1);
DEFINE_ASAN_LOAD_STORE(2);
DEFINE_ASAN_LOAD_STORE(4);
DEFINE_ASAN_LOAD_STORE(8);
DEFINE_ASAN_LOAD_STORE(16);
void __asan_loadN(unsigned long addr, size_t size)
{}
void __asan_loadN_noabort(unsigned long addr, size_t size)
{}
void __asan_storeN(unsigned long addr, size_t size)
{}
void __asan_storeN_noabort(unsigned long addr, size_t size)
{}
void __asan_handle_no_return(void)
{}