about summary refs log tree commit diff stats
path: root/wrapperhelper/src
diff options
context:
space:
mode:
authorrajdakin <rajdakin@gmail.com>2024-11-25 16:13:04 +0100
committerGitHub <noreply@github.com>2024-11-25 16:13:04 +0100
commita71856801b2a9f36a8745d0285778e6654a3408d (patch)
tree51eeb8947ea7e321ff98f29b81c800446391924d /wrapperhelper/src
parent84608fc581546076d6a34ae18c864eb8cde6ddae (diff)
downloadbox64-a71856801b2a9f36a8745d0285778e6654a3408d.tar.gz
box64-a71856801b2a9f36a8745d0285778e6654a3408d.zip
[WRAPPERHELPER] Added the `--gst` option (#2072)
Diffstat (limited to 'wrapperhelper/src')
-rw-r--r--wrapperhelper/src/lang.c3
-rw-r--r--wrapperhelper/src/main.c12
-rw-r--r--wrapperhelper/src/parse.c9
3 files changed, 20 insertions, 4 deletions
diff --git a/wrapperhelper/src/lang.c b/wrapperhelper/src/lang.c
index 85c2096e..8dad5cb1 100644
--- a/wrapperhelper/src/lang.c
+++ b/wrapperhelper/src/lang.c
@@ -1176,7 +1176,8 @@ void type_print(type_t *typ) {
 void struct_print(const struct_t *st) {
 	printf("<" DISP_ADDR_FMT "n_uses=%zu> ", DISP_ADDR_ARG(st) st->nrefs);
 	if (st->is_simple) {
-		printf("<simple> ");
+		printf("<simple> %s %s <don't care>", st->is_struct ? "struct" : "union", st->tag ? string_content(st->tag) : "<no tag>");
+		return;
 	}
 	if (st->is_defined) {
 		printf(
diff --git a/wrapperhelper/src/main.c b/wrapperhelper/src/main.c
index f3938904..ae00ed78 100644
--- a/wrapperhelper/src/main.c
+++ b/wrapperhelper/src/main.c
@@ -13,8 +13,8 @@
 
 static void help(char *arg0) {
 	printf("Usage: %s --help\n"
-	       "       %s {-I/path/to/include}* [--prepare|--preproc|--proc] [--arch <arch>|-32|-64|--32|--64] <filename_in>\n"
-	       "       %s {-I/path/to/include}* [[--emu <arch>] [--target <arch>]|-32|-64|--32|--64] <filename_in> <filename_reqs> <filename_out>\n"
+	       "       %s {-I/path/to/include}* [--gst] [--prepare|--preproc|--proc] [--arch <arch>|-32|-64|--32|--64] <filename_in>\n"
+	       "       %s {-I/path/to/include}* [--gst] [[--emu <arch>] [--target <arch>]|-32|-64|--32|--64] <filename_in> <filename_reqs> <filename_out>\n"
 	       "\n"
 	       "  --prepare  Dump all preprocessor tokens (prepare phase)\n"
 	       "  --preproc  Dump all processor tokens (preprocessor phase)\n"
@@ -33,7 +33,9 @@ static void help(char *arg0) {
 	       "  -32  --32        Use the x86 architecture as arch/emulated, aarch64 as target\n"
 	       "  -64  --64        Use the x86_64 architecture as arch/emulated, aarch64 as target\n"
 	       "\n"
-	       "  <arch> is one of 'x86', 'x86_64', 'aarch64'\n",
+	       "  <arch> is one of 'x86', 'x86_64', 'aarch64'\n"
+	       "\n"
+	       "  --gst            Mark all structures with a tag starting with '_G' and ending with 'Class' as simple\n",
 	       arg0, arg0, arg0);
 }
 
@@ -50,6 +52,8 @@ enum bits_state {
 	BITS_64,
 };
 
+int is_gst = 0;
+
 int main(int argc, char **argv) {
 	setbuf(stdout, NULL);
 	if (!setlocale(LC_NUMERIC, "C")) {
@@ -75,6 +79,8 @@ int main(int argc, char **argv) {
 			ms = MAIN_PREPROC;
 		} else if (!strcmp(argv[i], "--proc")) {
 			ms = MAIN_PROC;
+		} else if (!strcmp(argv[i], "--gst")) {
+			is_gst = 1;
 		} else if (!strcmp(argv[i], "-pthread")) {
 			// Ignore
 		} else if (!strcmp(argv[i], "-I") && (i + 1 < argc)) {
diff --git a/wrapperhelper/src/parse.c b/wrapperhelper/src/parse.c
index 398fd75b..75060484 100644
--- a/wrapperhelper/src/parse.c
+++ b/wrapperhelper/src/parse.c
@@ -1431,6 +1431,8 @@ static int eval_expression(loginfo_t *li, machine_t *target, expr_t *e, khash_t(
 	}
 }
 
+extern int is_gst; // If 1, mark structures _G*Class as simple
+
 // declaration-specifier with storage != NULL
 // specifier-qualifier-list + static_assert-declaration with storage == NULL
 static int parse_declaration_specifier(machine_t *target, khash_t(struct_map) *struct_map, khash_t(type_map) *type_map, khash_t(type_map) *enum_map,
@@ -2047,6 +2049,13 @@ parse_cur_token_decl:
 			typ->val.st->nmembers = vector_size(st_members, members);
 			typ->val.st->members = vector_steal(st_members, members);
 			typ->val.st->is_defined = 1;
+			if (is_gst
+			       && typ->val.st->tag
+			       && (string_len(typ->val.st->tag) >= 7)
+			       && !strncmp(string_content(typ->val.st->tag), "_G", 2)
+			       && !strcmp(string_content(typ->val.st->tag) + string_len(typ->val.st->tag) - 5, "Class")) {
+				typ->val.st->is_simple = 1;
+			}
 			*tok = proc_next_token(prep);
 			goto parse_cur_token_decl;
 		} else {