aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-10 14:09:51 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-13 18:02:55 +0200
commit338f93fad2fb41198abb6fa6d8a9e4a28a86e55e (patch)
tree8db37933c3b7d3c51b5442565276ceab8a32c1de
parente7ff2c6b8ad26b53deb18cf6589d5dc88629b6bd (diff)
downloadsparse-338f93fad2fb41198abb6fa6d8a9e4a28a86e55e.tar.gz
sh: add minimal support
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--Makefile1
-rw-r--r--machine.h1
-rw-r--r--target-sh.c28
-rw-r--r--target.c2
-rw-r--r--target.h1
5 files changed, 33 insertions, 0 deletions
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;