From 338f93fad2fb41198abb6fa6d8a9e4a28a86e55e Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Fri, 10 Jul 2020 14:09:51 +0200 Subject: sh: add minimal support Signed-off-by: Luc Van Oostenryck --- Makefile | 1 + machine.h | 1 + target-sh.c | 28 ++++++++++++++++++++++++++++ target.c | 2 ++ target.h | 1 + 5 files changed, 33 insertions(+) create mode 100644 target-sh.c diff --git a/Makefile b/Makefile index 7fc93dfc..46bdb0e6 100644 --- a/Makefile +++ b/Makefile @@ -82,6 +82,7 @@ LIB_OBJS += target-nios2.o LIB_OBJS += target-ppc.o LIB_OBJS += target-riscv.o LIB_OBJS += target-s390.o +LIB_OBJS += target-sh.o LIB_OBJS += target-sparc.o LIB_OBJS += target-x86.o LIB_OBJS += target-xtensa.o diff --git a/machine.h b/machine.h index 030c422f..170bdb50 100644 --- a/machine.h +++ b/machine.h @@ -39,6 +39,7 @@ enum machine { MACH_MICROBLAZE, MACH_NDS32, MACH_NIOS2, + MACH_SH, MACH_XTENSA, MACH_UNKNOWN }; diff --git a/target-sh.c b/target-sh.c new file mode 100644 index 00000000..db517ccb --- /dev/null +++ b/target-sh.c @@ -0,0 +1,28 @@ +#include "symbol.h" +#include "target.h" +#include "machine.h" + + +static void init_sh(const struct target *self) +{ + int64_ctype = &llong_ctype; + uint64_ctype = &ullong_ctype; + wchar_ctype = &long_ctype; +} + +static void predefine_sh(const struct target *self) +{ + predefine_weak("__SH4__"); + predefine_weak("__sh__"); +} + +const struct target target_sh = { + .mach = MACH_SH, + .bitness = ARCH_LP32, + .big_endian = false, + + .bits_in_longdouble = 64, + + .init = init_sh, + .predefine = predefine_sh, +}; diff --git a/target.c b/target.c index f744de8d..857ae367 100644 --- a/target.c +++ b/target.c @@ -75,6 +75,7 @@ static const struct target *targets[] = { [MACH_RISCV64] = &target_riscv64, [MACH_S390] = &target_s390, [MACH_S390X] = &target_s390x, + [MACH_SH] = &target_sh, [MACH_SPARC32] = &target_sparc32, [MACH_SPARC64] = &target_sparc64, [MACH_X86_64] = &target_x86_64, @@ -110,6 +111,7 @@ enum machine target_parse(const char *name) { "sparc", MACH_SPARC32, 0, }, { "x86_64", MACH_X86_64, 64, }, { "x86-64", MACH_X86_64, 64, }, + { "sh", MACH_SH, 32, }, { "xtensa", MACH_XTENSA, 32, }, { NULL }, }; diff --git a/target.h b/target.h index 4fbdfbdf..8eb52806 100644 --- a/target.h +++ b/target.h @@ -98,6 +98,7 @@ extern const struct target target_riscv32; extern const struct target target_riscv64; extern const struct target target_s390; extern const struct target target_s390x; +extern const struct target target_sh; extern const struct target target_sparc32; extern const struct target target_sparc64; extern const struct target target_i386; -- cgit 1.2.3-korg