summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-07-14 16:19:58 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-07-14 16:19:58 +0200
commitec0810b91aba837f684ed15f0b8abfb03299f661 (patch)
tree42d8e318d5cb084d9103f569c442be6841305b5b /src/kernel
parentf31f7960bd260cb90ffdd766393d51bd85a547d1 (diff)
downloadabaos-ec0810b91aba837f684ed15f0b8abfb03299f661.tar.gz
abaos-ec0810b91aba837f684ed15f0b8abfb03299f661.tar.bz2
some linkage tweaking, the kernel is not linked against libssp (which
is using linux/glibc), we provide our own SSP guards leading to kernel_panic (for now). per default build the kernel with ld (as we need precise control how we link it) the libc tests are per default linked with the same compiler as provided with $(CC) using #include_next of gcc/clang to include the real stdint.h header file in stdint.h stub
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/kernel.c18
-rw-r--r--src/kernel/kernel.h11
2 files changed, 29 insertions, 0 deletions
diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c
index a472cde..be5da7c 100644
--- a/src/kernel/kernel.c
+++ b/src/kernel/kernel.c
@@ -419,4 +419,22 @@ static void print_memory_status( global_context_t *global_context )
}
+uintptr_t __stack_chk_guard = STACK_CHK_GUARD;
+__attribute__( ( noreturn ) )
+void __stack_chk_fail_local( void )
+{
+ kernel_panic( "Stack smashing detected!" );
+
+ // make gcc happy on noreturn does return
+ for( ;; );
+}
+
+__attribute__( ( noreturn ) )
+void __stack_chk_fail( void )
+{
+ kernel_panic( "Stack smashing detected!" );
+
+ // make gcc happy on noreturn does return
+ for( ;; );
+}
diff --git a/src/kernel/kernel.h b/src/kernel/kernel.h
index dc23fd6..87733c8 100644
--- a/src/kernel/kernel.h
+++ b/src/kernel/kernel.h
@@ -1,10 +1,21 @@
#ifndef KERNEL_H
#define KERNEL_H
+#include "stdint.h"
#include "stdio.h"
void kernel_main( void );
void kernel_panic( const char *format, ... );
void kernel_halt( void );
+#define STACK_CHK_GUARD 0xe2dee396
+
+extern uintptr_t __stack_chk_guard;
+
+__attribute__( ( noreturn ) )
+void __stack_chk_fail_local( void );
+
+__attribute__( ( noreturn ) )
+void __stack_chk_fail( void );
+
#endif // KERNEL_H