diff --git a/Makefile b/Makefile index 9c17c39..9c4918c 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ all: - arm-none-eabi-gcc -ggdb -mcpu=Cortex-M4 -mthumb -r -Tlibpqscheme.ld -fPIC -nostartfiles -o libpqscheme_test.elf libpqscheme_test.c -Iruntime_mps2/out/an386/pack/include + arm-none-eabi-gcc -ggdb -mcpu=Cortex-M4 -mthumb -Tlibpqscheme.ld -nostartfiles -o libpqscheme_test.elf libpqscheme_test.c -Iruntime_mps2/out/an386/pack/include -L/home/kris/repos/pqshield/epcc/out/armv7e-m/lib -I/home/kris/repos/pqshield/epcc/out/armv7e-m/inc -lmlkem -lsha3 -lcommon arm-none-eabi-gcc -ggdb -mcpu=Cortex-M4 -mthumb -Truntime_mps2/out/an386/pack/lib/mps2.ld -nostartfiles -o runner.elf runner.c -Lruntime_mps2/out/an386/pack/lib -lmps2-an386_runtime -Iruntime_mps2/out/an386/pack/include arm-none-eabi-ar rcs runner runner.elf - arm-none-eabi-objcopy -O binary libpqscheme_test.elf libpqscheme_test.bin + run: qemu-system-arm \ -M mps2-an386 \ @@ -12,11 +12,10 @@ run: -nographic \ -kernel runner.elf \ -semihosting \ - -device loader,file=libpqscheme_test.elf,addr=0x20000000 + -device loader,file=libpqscheme_test.bin,addr=0x20000000 # -S -gdb tcp::1234 # -monitor unix:/tmp/qemu-monitor,server,nowait - clean: rm -rf *.o *.a *.elf *.bin rm -rf runner diff --git a/libpqscheme.ld b/libpqscheme.ld index 690f53b..edbf1a2 100644 --- a/libpqscheme.ld +++ b/libpqscheme.ld @@ -1,23 +1,26 @@ MEMORY { - FLASH (rx) : ORIGIN = 0x00300000, LENGTH = 0x00100000 /* Runner */ - RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 16K + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 16K } SECTIONS { - .magic_header : { + .magic_header : ALIGN(4) { LONG(0x88DAD0F2) /* Magic header containing */ LONG(ADDR(.text)) /* Entry point */ } > RAM - .text : { + .text : ALIGN(4) { *(.text) *(.rodata) } > RAM - .data : { + .data : ALIGN(4) { *(.data) } > RAM + .bss : ALIGN(4) { + *(.bss) + *(COMMON) + } > RAM } diff --git a/libpqscheme_test.c b/libpqscheme_test.c index dd444e4..06cdccd 100644 --- a/libpqscheme_test.c +++ b/libpqscheme_test.c @@ -1,7 +1,10 @@ +#include #include +int run(); -__attribute__((section(".text"))) int cryptographic_test() { +__attribute__((used, section(".text"))) int cryptographic_test() { // Run unit tests for cryptographic scheme - //while(1); // Debug loop - return 7; + return 7 + run(); } + +int run() { return (int)epcc_sha3_serialized_size(); } diff --git a/runner.c b/runner.c index 12df443..4c22fe5 100644 --- a/runner.c +++ b/runner.c @@ -16,7 +16,8 @@ void execute_library_function() { while ((uint32_t)ptr < RAM_END) { if (*ptr == LIB_MAGIC) { printf("Found libpqscheme_test 0x%X!\n", ptr); - entry_point = RAM_START + (*(ptr + 1)); + entry_point = (*(ptr + 1)); + printf("Calling function at 0x%X\n", entry_point); entry_point |= 1; // Ensure thumb mod func_t test_func = (func_t)(entry_point); if (test_func) {