From f823ef250462f40356e973c131d4f10b1323a43a Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Tue, 24 Jan 2012 00:18:36 +0100 Subject: [PATCH] Add "fake memcpy" lib so broken gcc can compile this --- firmware/l0dable/Makefile | 11 +++++++++-- firmware/l0dable/help/memcpy.c | 10 ++++++++++ firmware/l0dable/mktable.pl | 7 +++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 firmware/l0dable/help/memcpy.c diff --git a/firmware/l0dable/Makefile b/firmware/l0dable/Makefile index 873523b..ddf10f1 100644 --- a/firmware/l0dable/Makefile +++ b/firmware/l0dable/Makefile @@ -43,8 +43,8 @@ $(LDFILE): %.o : %.c $(CC) $(CFLAGS) -o $@ $< -%.elf: %.o $(FIRMWARE) $(LDFILE) - $(LD) $(LDFLAGS) -T $(LDFILE) -o $@ $< +%.elf: %.o $(FIRMWARE) $(LDFILE) libmemcpy.a + $(LD) $(LDFLAGS) -T $(LDFILE) -o $@ $< -L. -lmemcpy $(SIZE) $@ %.bin: %.elf @@ -85,6 +85,13 @@ $(OBJS): usetable.h usetable.h: ./mktable.pl +help/memcpy.o: help/memcpy.c + +libmemcpy.a: help/memcpy.o + $(AR) rcs $@ $< + $(RANLIB) $(RANLIBFLAGS) $@ + + .SUFFIXES: .PHONY: $(LDFILE) diff --git a/firmware/l0dable/help/memcpy.c b/firmware/l0dable/help/memcpy.c new file mode 100644 index 0000000..42e900d --- /dev/null +++ b/firmware/l0dable/help/memcpy.c @@ -0,0 +1,10 @@ +#include +#include "../usetable.h" + +#undef memcpy + +void * memcpy(void *dst, const void *src, size_t len){ + return + (*(void * (*)(void *, const void *, size_t ))(*(TheTable+_memcpy_nr))) + (dst, src, len); +}; diff --git a/firmware/l0dable/mktable.pl b/firmware/l0dable/mktable.pl index cceebe7..f55b9ee 100755 --- a/firmware/l0dable/mktable.pl +++ b/firmware/l0dable/mktable.pl @@ -5,6 +5,7 @@ use strict; my $DIR="l0dable"; +my $memcpy; if( -d "../$DIR"){ chdir(".."); @@ -105,10 +106,16 @@ for my $idx (0..$#symb){ print C "$_,"; }; print I "#define $_ ($types{$_}(TheTable[$idx]))"; + if($_ eq "memcpy" || $_ eq "memmove"){ + $memcpy=$idx + }; }; print C "};"; +if (defined($memcpy)){ + print I "#define _memcpy_nr $memcpy"; +}; close(I); close(H); close(C);