ACPI AML decompiler w/ CFG recovery and structured pseudocode
29

Configure Feed

Select the types of activity you want to include in your feed.

Track lexical namespace scope ownership directly on IR blocks

+22
+6
src/ir.c
··· 24 24 free(node->child); 25 25 free(node->name); 26 26 free(node->path); 27 + free(node->scope); 27 28 free(node->str); 28 29 free(node->target); 29 30 free(node); ··· 80 81 void tobi_ir_set_path(tobi_ir *node, const char *s) { 81 82 free(node->path); 82 83 node->path = tobi_xstrdup(s ? s : ""); 84 + } 85 + 86 + void tobi_ir_set_scope(tobi_ir *node, const char *s) { 87 + free(node->scope); 88 + node->scope = tobi_xstrdup(s ? s : ""); 83 89 } 84 90 85 91 void tobi_ir_set_str(tobi_ir *node, const char *s) {
+3
src/ir.h
··· 45 45 size_t len; 46 46 char *name; 47 47 char *path; 48 + char *scope; 48 49 char *str; 49 50 char *target; 50 51 uint64_t value; ··· 73 74 void tobi_ir_set_name(tobi_ir *node, const char *s); 74 75 75 76 void tobi_ir_set_path(tobi_ir *node, const char *s); 77 + 78 + void tobi_ir_set_scope(tobi_ir *node, const char *s); 76 79 77 80 void tobi_ir_set_str(tobi_ir *node, const char *s); 78 81
+5
src/js.c
··· 38 38 tobi_sb_add(sb, "\"path\":"); 39 39 tobi_json_string(sb, n->path); 40 40 } 41 + if (n->scope) { 42 + comma(sb, &first); 43 + tobi_sb_add(sb, "\"scope\":"); 44 + tobi_json_string(sb, n->scope); 45 + } 41 46 if (n->str) { 42 47 comma(sb, &first); 43 48 tobi_sb_add(sb, "\"string\":");
+4
src/p.c
··· 238 238 239 239 static tobi_ir *parse_block_from_reader(parser *p, tobi_rd *sub, unsigned depth, size_t off) { 240 240 tobi_ir *block = tobi_ir_new(TOBI_IR_BLOCK, off, tobi_rd_left(sub)); 241 + tobi_ir_set_scope(block, p->scope); 241 242 (void)parse_term_list(p, sub, block, depth + 1); 242 243 return block; 243 244 } ··· 1944 1945 return 0; 1945 1946 } 1946 1947 out->root = tobi_ir_new(TOBI_IR_ROOT, out->meta.aml_off, out->meta.aml_len); 1948 + tobi_ir_set_scope(out->root, "\\"); 1947 1949 parser p; 1948 1950 memset(&p, 0, sizeof(p)); 1949 1951 p.diag = &out->diag; ··· 1972 1974 out->meta.signature[4] = '\0'; 1973 1975 memcpy(out->meta.source, "multi", 6); 1974 1976 out->root = tobi_ir_new(TOBI_IR_ROOT, 0, 0); 1977 + tobi_ir_set_scope(out->root, "\\"); 1975 1978 if (!inputs || count == 0) { 1976 1979 tobi_diag_add(&out->diag, TOBI_DIAG_ERROR, 0, "no AML inputs"); 1977 1980 return 0; ··· 2003 2006 } 2004 2007 tobi_ir *file = tobi_ir_new(TOBI_IR_BLOCK, metas[i].aml_off, metas[i].aml_len); 2005 2008 tobi_ir_set_name(file, inputs[i].name ? inputs[i].name : "<input>"); 2009 + tobi_ir_set_scope(file, "\\"); 2006 2010 tobi_rd rd; 2007 2011 tobi_rd_init(&rd, inputs[i].data + metas[i].aml_off, metas[i].aml_len, metas[i].aml_off); 2008 2012 (void)parse_term_list(&p, &rd, file, 0);
+4
test/t_ir.c
··· 6 6 tobi_ir *root = tobi_ir_new(TOBI_IR_ROOT, 0, 10); 7 7 tobi_ir *m = tobi_ir_new(TOBI_IR_METHOD, 2, 8); 8 8 tobi_ir_set_name(m, "MTH0"); 9 + tobi_ir_set_scope(root, "\\"); 9 10 tobi_ir_add(root, m); 10 11 tobi_ir_add(m, tobi_ir_new(TOBI_IR_BLOCK, 7, 3)); 12 + tobi_ir_set_scope(m->child[0], "\\MTH0"); 11 13 tobi_ir_assign_ids(root); 12 14 T_CHECK(root->kind == TOBI_IR_ROOT); 13 15 T_CHECK(root->id == 1 && root->parent_id == 0); ··· 16 18 T_CHECK(root->child[0]->id == 2 && root->child[0]->parent_id == root->id); 17 19 T_CHECK(root->child[0]->parent_index == 0); 18 20 T_CHECK(m->child[0]->id == 3 && m->child[0]->parent_id == m->id); 21 + T_CHECK(strcmp(root->scope, "\\") == 0); 22 + T_CHECK(strcmp(m->child[0]->scope, "\\MTH0") == 0); 19 23 T_CHECK(tobi_ir_find_child(root, TOBI_IR_METHOD) == m); 20 24 T_CHECK(tobi_ir_count_kind(root, TOBI_IR_METHOD) == 1); 21 25 tobi_ir *u = tobi_ir_new(TOBI_IR_UNKNOWN, 4, 1);