From ec0810b91aba837f684ed15f0b8abfb03299f661 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Fri, 14 Jul 2017 16:19:58 +0200 Subject: 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 --- tests/libc/Makefile | 4 ++-- tests/libc/kernel_stub.c | 7 +++++++ tests/libc/kernel_stub.h | 9 +++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/libc/Makefile b/tests/libc/Makefile index d9d2927..2d89940 100644 --- a/tests/libc/Makefile +++ b/tests/libc/Makefile @@ -2,8 +2,8 @@ CC := gcc DEFINES = -DOS_LINUX INCLUDES = -I. -I../../src/libc -I../../src/kernel -I/home/abaumann/cross-compilers/include CFLAGS := -std=c99 -m32 -ffreestanding -O0 -g -Wall -Werror $(INCLUDES) $(DEFINES) -LD := ld -LDFLAGS := +LD := $(CC) +LDFLAGS := NASMFLAGS := -f elf32 NASM := nasm diff --git a/tests/libc/kernel_stub.c b/tests/libc/kernel_stub.c index 610c3d3..cacab34 100644 --- a/tests/libc/kernel_stub.c +++ b/tests/libc/kernel_stub.c @@ -22,3 +22,10 @@ void kernel_panic( const char *format, ... ) exit( 255 ); } +uintptr_t __stack_chk_guard = STACK_CHK_GUARD; + +__attribute__( ( noreturn ) ) +void __stack_chk_fail_local( void ) +{ + abort( ); +} diff --git a/tests/libc/kernel_stub.h b/tests/libc/kernel_stub.h index 467ad20..65047f9 100644 --- a/tests/libc/kernel_stub.h +++ b/tests/libc/kernel_stub.h @@ -24,4 +24,13 @@ long syscall1( long n, long a1 ); long syscall2( long n, long a1, long a2 ); long syscall3( long n, long a1, long a2, long a3 ); +// SSP stub, we don't want to link against libssp + +#include +#include + +#define STACK_CHK_GUARD 0xe2dee396 + +extern uintptr_t __stack_chk_guard; + #endif -- cgit v1.2.3-54-g00ecf