summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-02-10 12:09:38 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-02-10 12:09:38 (GMT)
commitdbd5e7fdfd43fba609fce3fafdcd38d704554d99 (patch)
tree5811a602d34993598eeea5ea56b1efc3b93f9c63
parent465488d5b231c2552116a305c48b5fcccea55a09 (diff)
Included indications to load the proper pool constants in Dalvik operands.
-rw-r--r--ChangeLog66
-rw-r--r--src/arch/dalvik/Makefile.am1
-rw-r--r--src/arch/dalvik/helpers.h43
-rw-r--r--src/arch/dalvik/opdefs/Makefile.am2
-rw-r--r--src/arch/dalvik/opdefs/array_24.d2
-rw-r--r--src/arch/dalvik/opdefs/check_1f.d2
-rw-r--r--src/arch/dalvik/opdefs/const_1a.d2
-rw-r--r--src/arch/dalvik/opdefs/const_1b.d2
-rw-r--r--src/arch/dalvik/opdefs/const_1c.d2
-rw-r--r--src/arch/dalvik/opdefs/filled_25.d2
-rw-r--r--src/arch/dalvik/opdefs/iget_52.d2
-rw-r--r--src/arch/dalvik/opdefs/iget_53.d2
-rw-r--r--src/arch/dalvik/opdefs/iget_54.d2
-rw-r--r--src/arch/dalvik/opdefs/iget_55.d2
-rw-r--r--src/arch/dalvik/opdefs/iget_56.d2
-rw-r--r--src/arch/dalvik/opdefs/iget_57.d2
-rw-r--r--src/arch/dalvik/opdefs/iget_58.d2
-rw-r--r--src/arch/dalvik/opdefs/instanceof_20.d2
-rw-r--r--src/arch/dalvik/opdefs/invoke_6e.d2
-rw-r--r--src/arch/dalvik/opdefs/invoke_6f.d2
-rw-r--r--src/arch/dalvik/opdefs/invoke_70.d2
-rw-r--r--src/arch/dalvik/opdefs/invoke_71.d2
-rw-r--r--src/arch/dalvik/opdefs/invoke_72.d2
-rw-r--r--src/arch/dalvik/opdefs/invoke_74.d2
-rw-r--r--src/arch/dalvik/opdefs/invoke_75.d2
-rw-r--r--src/arch/dalvik/opdefs/invoke_76.d2
-rw-r--r--src/arch/dalvik/opdefs/invoke_77.d2
-rw-r--r--src/arch/dalvik/opdefs/invoke_78.d2
-rw-r--r--src/arch/dalvik/opdefs/iput_59.d2
-rw-r--r--src/arch/dalvik/opdefs/iput_5a.d2
-rw-r--r--src/arch/dalvik/opdefs/iput_5b.d2
-rw-r--r--src/arch/dalvik/opdefs/iput_5c.d2
-rw-r--r--src/arch/dalvik/opdefs/iput_5d.d2
-rw-r--r--src/arch/dalvik/opdefs/iput_5e.d2
-rw-r--r--src/arch/dalvik/opdefs/iput_5f.d2
-rw-r--r--src/arch/dalvik/opdefs/new_22.d2
-rw-r--r--src/arch/dalvik/opdefs/new_23.d2
-rw-r--r--src/arch/dalvik/opdefs/sget_60.d2
-rw-r--r--src/arch/dalvik/opdefs/sget_61.d2
-rw-r--r--src/arch/dalvik/opdefs/sget_62.d2
-rw-r--r--src/arch/dalvik/opdefs/sget_63.d2
-rw-r--r--src/arch/dalvik/opdefs/sget_64.d2
-rw-r--r--src/arch/dalvik/opdefs/sget_65.d2
-rw-r--r--src/arch/dalvik/opdefs/sget_66.d2
-rw-r--r--src/arch/dalvik/opdefs/sput_67.d2
-rw-r--r--src/arch/dalvik/opdefs/sput_68.d2
-rw-r--r--src/arch/dalvik/opdefs/sput_69.d2
-rw-r--r--src/arch/dalvik/opdefs/sput_6a.d2
-rw-r--r--src/arch/dalvik/opdefs/sput_6b.d2
-rw-r--r--src/arch/dalvik/opdefs/sput_6c.d2
-rw-r--r--src/arch/dalvik/opdefs/sput_6d.d2
-rw-r--r--tools/d2c/format/grammar.y7
-rw-r--r--tools/d2c/format/manager.c37
-rw-r--r--tools/d2c/format/manager.h2
-rw-r--r--tools/d2c/format/tokens.l6
55 files changed, 193 insertions, 65 deletions
diff --git a/ChangeLog b/ChangeLog
index e9f09cc..ce0717f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,71 @@
16-02-10 Cyrille Bagard <nocbos@gmail.com>
+ * src/arch/dalvik/Makefile.am:
+ Add the new 'helpers.h' file to libarchdalvik_la_SOURCES.
+
+ * src/arch/dalvik/helpers.h:
+ New entry: provide some help when reading Dalvik operands.
+
+ * src/arch/dalvik/opdefs/Makefile.am:
+ Update the included headers in FIXED_C_INCLUDES.
+
+ * src/arch/dalvik/opdefs/array_24.d:
+ * src/arch/dalvik/opdefs/check_1f.d:
+ * src/arch/dalvik/opdefs/const_1a.d:
+ * src/arch/dalvik/opdefs/const_1b.d:
+ * src/arch/dalvik/opdefs/const_1c.d:
+ * src/arch/dalvik/opdefs/filled_25.d:
+ * src/arch/dalvik/opdefs/iget_52.d:
+ * src/arch/dalvik/opdefs/iget_53.d:
+ * src/arch/dalvik/opdefs/iget_54.d:
+ * src/arch/dalvik/opdefs/iget_55.d:
+ * src/arch/dalvik/opdefs/iget_56.d:
+ * src/arch/dalvik/opdefs/iget_57.d:
+ * src/arch/dalvik/opdefs/iget_58.d:
+ * src/arch/dalvik/opdefs/instanceof_20.d:
+ * src/arch/dalvik/opdefs/invoke_6e.d:
+ * src/arch/dalvik/opdefs/invoke_6f.d:
+ * src/arch/dalvik/opdefs/invoke_70.d:
+ * src/arch/dalvik/opdefs/invoke_71.d:
+ * src/arch/dalvik/opdefs/invoke_72.d:
+ * src/arch/dalvik/opdefs/invoke_74.d:
+ * src/arch/dalvik/opdefs/invoke_75.d:
+ * src/arch/dalvik/opdefs/invoke_76.d:
+ * src/arch/dalvik/opdefs/invoke_77.d:
+ * src/arch/dalvik/opdefs/invoke_78.d:
+ * src/arch/dalvik/opdefs/iput_59.d:
+ * src/arch/dalvik/opdefs/iput_5a.d:
+ * src/arch/dalvik/opdefs/iput_5b.d:
+ * src/arch/dalvik/opdefs/iput_5c.d:
+ * src/arch/dalvik/opdefs/iput_5d.d:
+ * src/arch/dalvik/opdefs/iput_5e.d:
+ * src/arch/dalvik/opdefs/iput_5f.d:
+ * src/arch/dalvik/opdefs/new_22.d:
+ * src/arch/dalvik/opdefs/new_23.d:
+ * src/arch/dalvik/opdefs/sget_60.d:
+ * src/arch/dalvik/opdefs/sget_61.d:
+ * src/arch/dalvik/opdefs/sget_62.d:
+ * src/arch/dalvik/opdefs/sget_63.d:
+ * src/arch/dalvik/opdefs/sget_64.d:
+ * src/arch/dalvik/opdefs/sget_65.d:
+ * src/arch/dalvik/opdefs/sget_66.d:
+ * src/arch/dalvik/opdefs/sput_67.d:
+ * src/arch/dalvik/opdefs/sput_68.d:
+ * src/arch/dalvik/opdefs/sput_69.d:
+ * src/arch/dalvik/opdefs/sput_6a.d:
+ * src/arch/dalvik/opdefs/sput_6b.d:
+ * src/arch/dalvik/opdefs/sput_6c.d:
+ * src/arch/dalvik/opdefs/sput_6d.d:
+ Include indications to load the proper pool constants in Dalvik operands.
+
+ * tools/d2c/format/grammar.y:
+ * tools/d2c/format/manager.c:
+ * tools/d2c/format/manager.h:
+ * tools/d2c/format/tokens.l:
+ Extend the compiler to handle extra arguments with the '@format' keyword.
+
+16-02-10 Cyrille Bagard <nocbos@gmail.com>
+
* src/analysis/disass/links.c:
Translate immediate values into targets with mode care.
diff --git a/src/arch/dalvik/Makefile.am b/src/arch/dalvik/Makefile.am
index 0f04dae..6ccbb5d 100644
--- a/src/arch/dalvik/Makefile.am
+++ b/src/arch/dalvik/Makefile.am
@@ -3,6 +3,7 @@ noinst_LTLIBRARIES = libarchdalvik.la
libarchdalvik_la_SOURCES = \
context.h context.c \
+ helpers.h \
instruction-def.h \
instruction-int.h \
instruction.h instruction.c \
diff --git a/src/arch/dalvik/helpers.h b/src/arch/dalvik/helpers.h
new file mode 100644
index 0000000..1b57d00
--- /dev/null
+++ b/src/arch/dalvik/helpers.h
@@ -0,0 +1,43 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * helpers.h - prototypes pour l'aide à la mise en place des opérandes Dalvik
+ *
+ * Copyright (C) 2016 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _ARCH_DALVIK_HELPERS_H
+#define _ARCH_DALVIK_HELPERS_H
+
+
+#include "operand.h"
+
+
+
+/**
+ * Glues purement internes.
+ */
+
+#define DALVIK_OPT_POOL_STRING DALVIK_OP_POOL(DPT_STRING)
+#define DALVIK_OPT_POOL_TYPE DALVIK_OP_POOL(DPT_TYPE)
+#define DALVIK_OPT_POOL_FIELD DALVIK_OP_POOL(DPT_FIELD)
+#define DALVIK_OPT_POOL_METH DALVIK_OP_POOL(DPT_METHOD)
+
+
+
+#endif /* _ARCH_DALVIK_HELPERS_H */
diff --git a/src/arch/dalvik/opdefs/Makefile.am b/src/arch/dalvik/opdefs/Makefile.am
index 115f75c..eebf04e 100644
--- a/src/arch/dalvik/opdefs/Makefile.am
+++ b/src/arch/dalvik/opdefs/Makefile.am
@@ -19,8 +19,8 @@ D2C_ENCODINGS = \
FIXED_C_INCLUDES = \
\n\#include \<stdint.h\> \
\n \
+ \n\#include \"..\/helpers.h\" \
\n\#include \"..\/instruction.h\" \
- \n\#include \"..\/operand.h\" \
\n\#include \"..\/processor.h\" \
\n\#include \"..\/..\/context.h\" \
\n\#include \"..\/..\/..\/analysis\/content.h\" \
diff --git a/src/arch/dalvik/opdefs/array_24.d b/src/arch/dalvik/opdefs/array_24.d
index b7dc4d4..00b7896 100644
--- a/src/arch/dalvik/opdefs/array_24.d
+++ b/src/arch/dalvik/opdefs/array_24.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 35c
+ @format 35c | pool_type
}
diff --git a/src/arch/dalvik/opdefs/check_1f.d b/src/arch/dalvik/opdefs/check_1f.d
index 7de7e56..0f59ba7 100644
--- a/src/arch/dalvik/opdefs/check_1f.d
+++ b/src/arch/dalvik/opdefs/check_1f.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 21c
+ @format 21c | pool_type
}
diff --git a/src/arch/dalvik/opdefs/const_1a.d b/src/arch/dalvik/opdefs/const_1a.d
index c6d3f62..22c11ae 100644
--- a/src/arch/dalvik/opdefs/const_1a.d
+++ b/src/arch/dalvik/opdefs/const_1a.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 21c
+ @format 21c | pool_string
}
diff --git a/src/arch/dalvik/opdefs/const_1b.d b/src/arch/dalvik/opdefs/const_1b.d
index e7c97e1..699cef6 100644
--- a/src/arch/dalvik/opdefs/const_1b.d
+++ b/src/arch/dalvik/opdefs/const_1b.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 31c
+ @format 31c | pool_string
}
diff --git a/src/arch/dalvik/opdefs/const_1c.d b/src/arch/dalvik/opdefs/const_1c.d
index 623fca0..c539ee9 100644
--- a/src/arch/dalvik/opdefs/const_1c.d
+++ b/src/arch/dalvik/opdefs/const_1c.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 21c
+ @format 21c | pool_type
}
diff --git a/src/arch/dalvik/opdefs/filled_25.d b/src/arch/dalvik/opdefs/filled_25.d
index 7bb4088..cf31e09 100644
--- a/src/arch/dalvik/opdefs/filled_25.d
+++ b/src/arch/dalvik/opdefs/filled_25.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 3rc
+ @format 3rc | pool_type
}
diff --git a/src/arch/dalvik/opdefs/iget_52.d b/src/arch/dalvik/opdefs/iget_52.d
index 6217ddb..ca5c140 100644
--- a/src/arch/dalvik/opdefs/iget_52.d
+++ b/src/arch/dalvik/opdefs/iget_52.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 22c
+ @format 22c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/iget_53.d b/src/arch/dalvik/opdefs/iget_53.d
index adf089e..3d458d9 100644
--- a/src/arch/dalvik/opdefs/iget_53.d
+++ b/src/arch/dalvik/opdefs/iget_53.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 22c
+ @format 22c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/iget_54.d b/src/arch/dalvik/opdefs/iget_54.d
index 45bc02c..343accc 100644
--- a/src/arch/dalvik/opdefs/iget_54.d
+++ b/src/arch/dalvik/opdefs/iget_54.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 22c
+ @format 22c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/iget_55.d b/src/arch/dalvik/opdefs/iget_55.d
index d5a37bc..dc9d7a4 100644
--- a/src/arch/dalvik/opdefs/iget_55.d
+++ b/src/arch/dalvik/opdefs/iget_55.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 22c
+ @format 22c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/iget_56.d b/src/arch/dalvik/opdefs/iget_56.d
index 5bffd30..92e4d6c 100644
--- a/src/arch/dalvik/opdefs/iget_56.d
+++ b/src/arch/dalvik/opdefs/iget_56.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 22c
+ @format 22c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/iget_57.d b/src/arch/dalvik/opdefs/iget_57.d
index 43ba4b6..b8864c7 100644
--- a/src/arch/dalvik/opdefs/iget_57.d
+++ b/src/arch/dalvik/opdefs/iget_57.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 22c
+ @format 22c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/iget_58.d b/src/arch/dalvik/opdefs/iget_58.d
index aba5271..85a3fb8 100644
--- a/src/arch/dalvik/opdefs/iget_58.d
+++ b/src/arch/dalvik/opdefs/iget_58.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 22c
+ @format 22c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/instanceof_20.d b/src/arch/dalvik/opdefs/instanceof_20.d
index 82136a2..7652c56 100644
--- a/src/arch/dalvik/opdefs/instanceof_20.d
+++ b/src/arch/dalvik/opdefs/instanceof_20.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 22c
+ @format 22c | pool_type
}
diff --git a/src/arch/dalvik/opdefs/invoke_6e.d b/src/arch/dalvik/opdefs/invoke_6e.d
index e9a679b..e7b3f0d 100644
--- a/src/arch/dalvik/opdefs/invoke_6e.d
+++ b/src/arch/dalvik/opdefs/invoke_6e.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 35c
+ @format 35c | pool_meth
}
diff --git a/src/arch/dalvik/opdefs/invoke_6f.d b/src/arch/dalvik/opdefs/invoke_6f.d
index 80834e2..9fa4666 100644
--- a/src/arch/dalvik/opdefs/invoke_6f.d
+++ b/src/arch/dalvik/opdefs/invoke_6f.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 35c
+ @format 35c | pool_meth
}
diff --git a/src/arch/dalvik/opdefs/invoke_70.d b/src/arch/dalvik/opdefs/invoke_70.d
index 0624fa3..6662ce3 100644
--- a/src/arch/dalvik/opdefs/invoke_70.d
+++ b/src/arch/dalvik/opdefs/invoke_70.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 35c
+ @format 35c | pool_meth
}
diff --git a/src/arch/dalvik/opdefs/invoke_71.d b/src/arch/dalvik/opdefs/invoke_71.d
index 7088d9f..f179dbd 100644
--- a/src/arch/dalvik/opdefs/invoke_71.d
+++ b/src/arch/dalvik/opdefs/invoke_71.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 35c
+ @format 35c | pool_meth
}
diff --git a/src/arch/dalvik/opdefs/invoke_72.d b/src/arch/dalvik/opdefs/invoke_72.d
index fc15dd6..6ad8e09 100644
--- a/src/arch/dalvik/opdefs/invoke_72.d
+++ b/src/arch/dalvik/opdefs/invoke_72.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 35c
+ @format 35c | pool_meth
}
diff --git a/src/arch/dalvik/opdefs/invoke_74.d b/src/arch/dalvik/opdefs/invoke_74.d
index 0703ea7..77b68de 100644
--- a/src/arch/dalvik/opdefs/invoke_74.d
+++ b/src/arch/dalvik/opdefs/invoke_74.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 3rc
+ @format 3rc | pool_meth
}
diff --git a/src/arch/dalvik/opdefs/invoke_75.d b/src/arch/dalvik/opdefs/invoke_75.d
index 351ccc7..e886dad 100644
--- a/src/arch/dalvik/opdefs/invoke_75.d
+++ b/src/arch/dalvik/opdefs/invoke_75.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 3rc
+ @format 3rc | pool_meth
}
diff --git a/src/arch/dalvik/opdefs/invoke_76.d b/src/arch/dalvik/opdefs/invoke_76.d
index cf00220..8156689 100644
--- a/src/arch/dalvik/opdefs/invoke_76.d
+++ b/src/arch/dalvik/opdefs/invoke_76.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 3rc
+ @format 3rc | pool_meth
}
diff --git a/src/arch/dalvik/opdefs/invoke_77.d b/src/arch/dalvik/opdefs/invoke_77.d
index 76aa1d0..b5707e2 100644
--- a/src/arch/dalvik/opdefs/invoke_77.d
+++ b/src/arch/dalvik/opdefs/invoke_77.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 3rc
+ @format 3rc | pool_meth
}
diff --git a/src/arch/dalvik/opdefs/invoke_78.d b/src/arch/dalvik/opdefs/invoke_78.d
index fd4d1ee..5589b38 100644
--- a/src/arch/dalvik/opdefs/invoke_78.d
+++ b/src/arch/dalvik/opdefs/invoke_78.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 3rc
+ @format 3rc | pool_meth
}
diff --git a/src/arch/dalvik/opdefs/iput_59.d b/src/arch/dalvik/opdefs/iput_59.d
index d4058c3..fd17db4 100644
--- a/src/arch/dalvik/opdefs/iput_59.d
+++ b/src/arch/dalvik/opdefs/iput_59.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 22c
+ @format 22c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/iput_5a.d b/src/arch/dalvik/opdefs/iput_5a.d
index 84ba41a..509868c 100644
--- a/src/arch/dalvik/opdefs/iput_5a.d
+++ b/src/arch/dalvik/opdefs/iput_5a.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 22c
+ @format 22c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/iput_5b.d b/src/arch/dalvik/opdefs/iput_5b.d
index 628bfc2..9ad7500 100644
--- a/src/arch/dalvik/opdefs/iput_5b.d
+++ b/src/arch/dalvik/opdefs/iput_5b.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 22c
+ @format 22c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/iput_5c.d b/src/arch/dalvik/opdefs/iput_5c.d
index 7121604..9ae86fa 100644
--- a/src/arch/dalvik/opdefs/iput_5c.d
+++ b/src/arch/dalvik/opdefs/iput_5c.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 22c
+ @format 22c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/iput_5d.d b/src/arch/dalvik/opdefs/iput_5d.d
index 96ff6c0..8a3830e 100644
--- a/src/arch/dalvik/opdefs/iput_5d.d
+++ b/src/arch/dalvik/opdefs/iput_5d.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 22c
+ @format 22c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/iput_5e.d b/src/arch/dalvik/opdefs/iput_5e.d
index 888ce46..5120675 100644
--- a/src/arch/dalvik/opdefs/iput_5e.d
+++ b/src/arch/dalvik/opdefs/iput_5e.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 22c
+ @format 22c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/iput_5f.d b/src/arch/dalvik/opdefs/iput_5f.d
index 5ed0a01..7fe2d80 100644
--- a/src/arch/dalvik/opdefs/iput_5f.d
+++ b/src/arch/dalvik/opdefs/iput_5f.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 22c
+ @format 22c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/new_22.d b/src/arch/dalvik/opdefs/new_22.d
index 4c13f0e..4af913c 100644
--- a/src/arch/dalvik/opdefs/new_22.d
+++ b/src/arch/dalvik/opdefs/new_22.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 21c
+ @format 21c | pool_type
}
diff --git a/src/arch/dalvik/opdefs/new_23.d b/src/arch/dalvik/opdefs/new_23.d
index ab61cd4..0a6a863 100644
--- a/src/arch/dalvik/opdefs/new_23.d
+++ b/src/arch/dalvik/opdefs/new_23.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 22c
+ @format 22c | pool_type
}
diff --git a/src/arch/dalvik/opdefs/sget_60.d b/src/arch/dalvik/opdefs/sget_60.d
index 803e09c..90090a2 100644
--- a/src/arch/dalvik/opdefs/sget_60.d
+++ b/src/arch/dalvik/opdefs/sget_60.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 21c
+ @format 21c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/sget_61.d b/src/arch/dalvik/opdefs/sget_61.d
index 9681de3..c3f132c 100644
--- a/src/arch/dalvik/opdefs/sget_61.d
+++ b/src/arch/dalvik/opdefs/sget_61.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 21c
+ @format 21c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/sget_62.d b/src/arch/dalvik/opdefs/sget_62.d
index 0a21e7c..97d41d9 100644
--- a/src/arch/dalvik/opdefs/sget_62.d
+++ b/src/arch/dalvik/opdefs/sget_62.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 21c
+ @format 21c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/sget_63.d b/src/arch/dalvik/opdefs/sget_63.d
index f0d7ab7..0dca873 100644
--- a/src/arch/dalvik/opdefs/sget_63.d
+++ b/src/arch/dalvik/opdefs/sget_63.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 21c
+ @format 21c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/sget_64.d b/src/arch/dalvik/opdefs/sget_64.d
index 7dc329e..507420e 100644
--- a/src/arch/dalvik/opdefs/sget_64.d
+++ b/src/arch/dalvik/opdefs/sget_64.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 21c
+ @format 21c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/sget_65.d b/src/arch/dalvik/opdefs/sget_65.d
index 8336764..5236314 100644
--- a/src/arch/dalvik/opdefs/sget_65.d
+++ b/src/arch/dalvik/opdefs/sget_65.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 21c
+ @format 21c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/sget_66.d b/src/arch/dalvik/opdefs/sget_66.d
index fc6440a..9f8b4fa 100644
--- a/src/arch/dalvik/opdefs/sget_66.d
+++ b/src/arch/dalvik/opdefs/sget_66.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 21c
+ @format 21c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/sput_67.d b/src/arch/dalvik/opdefs/sput_67.d
index e7157a5..149337a 100644
--- a/src/arch/dalvik/opdefs/sput_67.d
+++ b/src/arch/dalvik/opdefs/sput_67.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 21c
+ @format 21c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/sput_68.d b/src/arch/dalvik/opdefs/sput_68.d
index e6a8948..3709445 100644
--- a/src/arch/dalvik/opdefs/sput_68.d
+++ b/src/arch/dalvik/opdefs/sput_68.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 21c
+ @format 21c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/sput_69.d b/src/arch/dalvik/opdefs/sput_69.d
index f41e84c..89302eb 100644
--- a/src/arch/dalvik/opdefs/sput_69.d
+++ b/src/arch/dalvik/opdefs/sput_69.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 21c
+ @format 21c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/sput_6a.d b/src/arch/dalvik/opdefs/sput_6a.d
index 17aa26a..91f5f4f 100644
--- a/src/arch/dalvik/opdefs/sput_6a.d
+++ b/src/arch/dalvik/opdefs/sput_6a.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 21c
+ @format 21c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/sput_6b.d b/src/arch/dalvik/opdefs/sput_6b.d
index 8aa83ef..72338a0 100644
--- a/src/arch/dalvik/opdefs/sput_6b.d
+++ b/src/arch/dalvik/opdefs/sput_6b.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 21c
+ @format 21c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/sput_6c.d b/src/arch/dalvik/opdefs/sput_6c.d
index b863af4..1f0a7c5 100644
--- a/src/arch/dalvik/opdefs/sput_6c.d
+++ b/src/arch/dalvik/opdefs/sput_6c.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 21c
+ @format 21c | pool_field
}
diff --git a/src/arch/dalvik/opdefs/sput_6d.d b/src/arch/dalvik/opdefs/sput_6d.d
index 65ca067..d164858 100644
--- a/src/arch/dalvik/opdefs/sput_6d.d
+++ b/src/arch/dalvik/opdefs/sput_6d.d
@@ -25,6 +25,6 @@
@encoding() {
- @format 21c
+ @format 21c | pool_field
}
diff --git a/tools/d2c/format/grammar.y b/tools/d2c/format/grammar.y
index 062d616..5cae2f8 100644
--- a/tools/d2c/format/grammar.y
+++ b/tools/d2c/format/grammar.y
@@ -38,7 +38,7 @@ YY_DECL;
}
-%token OPS_TYPE
+%token OPS_TYPE OR
%type <string> OPS_TYPE
@@ -47,7 +47,10 @@ YY_DECL;
%%
-type : OPS_TYPE { set_operands_format_type(format, $1); }
+types : type
+ | type OR types
+
+type : OPS_TYPE { add_operands_format_type(format, $1); }
%%
diff --git a/tools/d2c/format/manager.c b/tools/d2c/format/manager.c
index 070b70c..a799af9 100644
--- a/tools/d2c/format/manager.c
+++ b/tools/d2c/format/manager.c
@@ -34,7 +34,8 @@
/* Mémorisation de la définition d'opérandes */
struct _operands_format
{
- char *type; /* Définitions des opérandes */
+ char **types; /* Définitions des opérandes */
+ size_t count; /* Quantité de définitions */
};
@@ -77,8 +78,13 @@ operands_format *create_operands_format(void)
void delete_operands_format(operands_format *format)
{
- if (format->type != NULL)
- free(format->type);
+ size_t i; /* Boucle de parcours */
+
+ for (i = 0; i < format->count; i++)
+ free(format->types[i]);
+
+ if (format->types != NULL)
+ free(format->types);
free(format);
@@ -98,12 +104,11 @@ void delete_operands_format(operands_format *format)
* *
******************************************************************************/
-void set_operands_format_type(operands_format *format, char *type)
+void add_operands_format_type(operands_format *format, char *type)
{
- if (format->type != NULL)
- free(format->type);
+ format->types = (char **)realloc(format->types, ++format->count * sizeof(char *));
- format->type = make_string_upper(type);
+ format->types[format->count - 1] = make_string_upper(type);
}
@@ -126,7 +131,9 @@ void set_operands_format_type(operands_format *format, char *type)
bool define_operands_loading(const operands_format *format, int fd, const char *arch, const char *prefix, bool *exit)
{
- if (format->type == NULL)
+ size_t i; /* Boucle de parcours */
+
+ if (format->count == 0)
{
fprintf(stderr, "Error: no type defined for operands.\n");
return false;
@@ -134,8 +141,18 @@ bool define_operands_loading(const operands_format *format, int fd, const char *
*exit = true;
- dprintf(fd, "\tif (!%s_read_operands(result, format, content, pos, endian, %s%s))\n",
- arch, prefix, format->type);
+ dprintf(fd, "\tif (!%s_read_operands(result, format, content, pos, endian, ", arch);
+
+ for (i = 0; i < format->count; i++)
+ {
+ if (i > 0)
+ dprintf(fd, " | ");
+
+ dprintf(fd, "%s%s", prefix, format->types[i]);
+
+ }
+
+ dprintf(fd, "))\n");
dprintf(fd, "\t\tgoto bad_exit;\n");
dprintf(fd, "\n");
diff --git a/tools/d2c/format/manager.h b/tools/d2c/format/manager.h
index 4555710..461e354 100644
--- a/tools/d2c/format/manager.h
+++ b/tools/d2c/format/manager.h
@@ -40,7 +40,7 @@ operands_format *create_operands_format(void);
void delete_operands_format(operands_format *);
/* Précise le type d'opérandes dont la définition est à charger. */
-void set_operands_format_type(operands_format *, char *);
+void add_operands_format_type(operands_format *, char *);
/* Définit le chargement des opérandes prévus par la définition. */
bool define_operands_loading(const operands_format *, int, const char *, const char *, bool *);
diff --git a/tools/d2c/format/tokens.l b/tools/d2c/format/tokens.l
index 12ca7f0..9dd9301 100644
--- a/tools/d2c/format/tokens.l
+++ b/tools/d2c/format/tokens.l
@@ -12,15 +12,13 @@
%option yylineno
%option noyy_top_state
-%x bsize
-
%%
-" " { }
+" " { }
[A-Za-z0-9_]* { yylvalp->string = strdup(yytext); return OPS_TYPE; }
-
+"|" { return OR; }
%%