From 470be69f873dc7b0c5c07fb892367e08a78c7bbd Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 30 Dec 2022 13:18:41 +0000 Subject: [PATCH] relocate main() to a single section so that it can be put at a fixed address --- crypto/chacha20/Makefile.cross | 6 +++--- crypto/chacha20/memmap | 11 ++++++++++- crypto/chacha20/src/svp64test.c | 5 ++++- crypto/chacha20/src/xchacha20.c | 2 ++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/crypto/chacha20/Makefile.cross b/crypto/chacha20/Makefile.cross index 9ff32d29..fb79bb85 100755 --- a/crypto/chacha20/Makefile.cross +++ b/crypto/chacha20/Makefile.cross @@ -5,13 +5,13 @@ AS = $(CROSS)as CC = $(CROSS)gcc LD = $(CROSS)ld OBJCOPY = $(CROSS)objcopy -CFLAGS = -O3 -Wall -Wextra +CFLAGS = -O3 -Wall -Wextra -mno-vsx AFLAGS ?= -mpwr9 SRCDIR = src -SOURCES := $(SRCDIR)/xchacha20.c $(SRCDIR)/svp64test.c +SOURCES := $(SRCDIR)/svp64test.c $(SRCDIR)/xchacha20.c OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(SRCDIR)/%.o) OBJ = chacha20test.bin @@ -19,7 +19,7 @@ OBJ = chacha20test.bin export DUMP = /tmp/out # commented for luke's convenience -#export SILENCELOG = 1 +# export SILENCELOG = 1 all: tests diff --git a/crypto/chacha20/memmap b/crypto/chacha20/memmap index 052ccb0c..da68813a 100644 --- a/crypto/chacha20/memmap +++ b/crypto/chacha20/memmap @@ -1,11 +1,20 @@ MEMORY { - ram : ORIGIN = 0x20000000, LENGTH = 512M + ram : ORIGIN = 0x20001000, LENGTH = 512M + fixedaddr : ORIGIN = 0x20000000, LENGTH = 0x1000 } + SECTIONS { + .fixedaddr : + { + . = ALIGN(4); + __fixedaddr_start__ = .; + *(.fixedaddr*) + __fixedaddr_end__ = .; + } > fixedaddr .text : { *(.text*) } > ram .bss : { *(.text*) } > ram } diff --git a/crypto/chacha20/src/svp64test.c b/crypto/chacha20/src/svp64test.c index 88402b86..3e081137 100644 --- a/crypto/chacha20/src/svp64test.c +++ b/crypto/chacha20/src/svp64test.c @@ -75,6 +75,9 @@ int check_cpp(void){ return(0); } -int main(void){ +#define LOCATE_FUNC __attribute__((__section__(".fixedaddr"))) + +int LOCATE_FUNC main(int argc, char **argv[]){ return check_cpp(); } + diff --git a/crypto/chacha20/src/xchacha20.c b/crypto/chacha20/src/xchacha20.c index 2b29f60b..aa9c9043 100644 --- a/crypto/chacha20/src/xchacha20.c +++ b/crypto/chacha20/src/xchacha20.c @@ -130,6 +130,8 @@ void xchacha_encrypt_bytes(XChaCha_ctx *ctx, const uint8_t *m, uint8_t *c, uint3 uint8_t tmp[64]; uint32_t i; + return; + if (!bytes) return; j0 = ctx->input[0]; -- 2.30.2