Last active
September 27, 2019 16:17
-
-
Save thebabush/8e77373b1930c964f51d69e7bfe934ca to your computer and use it in GitHub Desktop.
Firefox/SpiderMonkey Code Cache Parser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| meta: | |
| id: spidermonkey | |
| endian: le | |
| seq: | |
| - id: build_id_length | |
| type: u4 | |
| - id: build_id | |
| type: str | |
| size: build_id_length | |
| encoding: UTF-8 | |
| - id: script | |
| type: xdr_script | |
| types: | |
| xdr_script: | |
| seq: | |
| - id: xdr_script_flags | |
| type: xdr_script_flags_bitfield | |
| - id: lineno | |
| type: u4 | |
| - id: column | |
| type: u4 | |
| - id: main_offset | |
| type: u4 | |
| - id: nfixed | |
| type: u4 | |
| - id: nslots | |
| type: u4 | |
| - id: body_scope_index | |
| type: u4 | |
| - id: source_start | |
| type: u4 | |
| - id: source_end | |
| type: u4 | |
| - id: to_string_start | |
| type: u4 | |
| - id: to_string_end | |
| type: u4 | |
| - id: immutable_flags | |
| type: u4 | |
| - id: script_source | |
| type: script_source | |
| if: xdr_script_flags.own_source | |
| - id: private_script_data | |
| type: private_script_data | |
| - id: shared_script_data | |
| type: shared_script_data | |
| private_script_data: | |
| seq: | |
| - id: ngcthings | |
| type: u4 | |
| - id: xdr_script_gc_thing | |
| type: xdr_script_gc_thing | |
| repeat: expr | |
| repeat-expr: ngcthings | |
| - id: code_marker | |
| contents: [0x9A, 0x98, 0x3B, 0xF8] | |
| #type: u4 | |
| shared_script_data: | |
| seq: | |
| - id: natoms | |
| type: u4 | |
| - id: code_length | |
| type: u4 | |
| - id: nute_length # fuck kaitai | |
| type: u4 | |
| - id: num_resume_offsets | |
| type: u4 | |
| - id: num_scope_notes | |
| type: u4 | |
| - id: num_try_notes | |
| type: u4 | |
| - id: main_offset | |
| type: u4 | |
| - id: nfixed | |
| type: u4 | |
| - id: nslots | |
| type: u4 | |
| - id: body_scope_index | |
| type: u4 | |
| - id: num_ic_entries | |
| type: u4 | |
| - id: fun_length | |
| type: u2 | |
| - id: num_bytecode_type_sets | |
| type: u2 | |
| - id: code | |
| size: code_length | |
| - id: notes | |
| size: nute_length | |
| - id: atoms | |
| type: xdr_atom | |
| repeat: expr | |
| repeat-expr: natoms | |
| - id: resume_offsets | |
| type: u4 | |
| repeat: expr | |
| repeat-expr: num_resume_offsets | |
| # scope notes | |
| # try notes | |
| xdr_script_flags_bitfield: | |
| seq: | |
| - id: unused_probably | |
| type: b6 | |
| - id: has_lazy_script | |
| type: b1 | |
| - id: own_source | |
| type: b1 | |
| script_source: | |
| seq: | |
| - id: ss | |
| type: xdr_data | |
| - id: have_source_map | |
| type: u1 | |
| # TODO: source map | |
| - id: have_display_url | |
| type: u1 | |
| # TODO: display url | |
| - id: have_filename | |
| type: u1 | |
| - id: filename | |
| type: c_string | |
| if: have_filename != 0 | |
| c_string: | |
| seq: | |
| - id: len64 | |
| type: u8 | |
| - id: s | |
| type: str | |
| size: len64 | |
| encoding: ascii | |
| xdr_data: | |
| seq: | |
| - id: tag | |
| type: u1 | |
| enum: xdr_data_type | |
| - id: uncompressed_length | |
| type: u4 | |
| if: tag == xdr_data_type::uncompressed_utf16_not_retrievable | |
| - id: uncompressed_utf16_not_retrievable | |
| type: str | |
| size: uncompressed_length * 2 | |
| encoding: utf-16 | |
| if: tag == xdr_data_type::uncompressed_utf16_not_retrievable | |
| xdr_atom: | |
| seq: | |
| - id: length_and_encoding | |
| type: u4 | |
| - id: str_utf16 | |
| type: str | |
| size: length * 2 | |
| encoding: utf-16 | |
| if: latin1 == 0 | |
| - id: str_latin1 | |
| type: str | |
| size: length | |
| encoding: latin1 | |
| if: latin1 == 1 | |
| instances: | |
| length: | |
| value: length_and_encoding >> 1 | |
| latin1: | |
| value: length_and_encoding & 0x01 | |
| xdr_script_gc_thing: | |
| seq: | |
| - id: tag_xored | |
| type: u4 | |
| - id: thing | |
| type: | |
| switch-on: tag | |
| cases: | |
| 'gc_thing_tag::scope': xdr_scope | |
| 'gc_thing_tag::object': xdr_inner_object | |
| instances: | |
| tag: | |
| value: tag_xored ^ 0x21AB218C | |
| enum: gc_thing_tag | |
| xdr_inner_object: | |
| seq: | |
| - id: clazzk_xored | |
| type: u4 | |
| - id: object | |
| type: | |
| switch-on: clazzk | |
| cases: | |
| 'class_kind::js_function': class_kind_js_function | |
| instances: | |
| clazzk: | |
| value: clazzk_xored ^ 0x21AB218C | |
| enum: class_kind | |
| class_kind_js_function: | |
| seq: | |
| - id: fun_enclosing_scope_index | |
| type: u4 | |
| - id: xdr_interpreted_function | |
| type: xdr_interpreted_function | |
| xdr_interpreted_function: | |
| seq: | |
| - id: first_word | |
| type: b27 | |
| - id: has_singleton_type | |
| type: b1 | |
| - id: is_lazy | |
| type: b1 | |
| - id: is_async | |
| type: b1 | |
| - id: is_generator | |
| type: b1 | |
| - id: has_atom | |
| type: b1 | |
| - id: atom | |
| type: xdr_atom | |
| - id: flags | |
| type: js_function_flags | |
| - id: nargs | |
| type: u2 | |
| - id: lazy_script | |
| type: xdr_lazy_script | |
| if: is_lazy | |
| - id: script | |
| type: xdr_script | |
| if: is_lazy == false | |
| - id: code_marker | |
| contents: [0x1F, 0xCA, 0x35, 0x9E] | |
| #type: u4 | |
| xdr_lazy_script: | |
| seq: | |
| - id: tbi | |
| type: u8 | |
| js_function_flags: | |
| seq: | |
| - id: to_be_completed0 | |
| type: b6 | |
| - id: konstructor | |
| type: b1 | |
| - id: interpreted | |
| type: b1 | |
| - id: to_be_completed1 | |
| type: b8 | |
| xdr_scope: | |
| seq: | |
| - id: scope_kind_xored | |
| type: u4 | |
| - id: enclosing_index | |
| type: u4 | |
| - id: scope | |
| type: | |
| switch-on: scope_kind | |
| cases: | |
| 'scope_kind::global': global_scope | |
| 'scope_kind::function': function_scope | |
| instances: | |
| scope_kind: | |
| value: scope_kind_xored ^ 0x21AB218C | |
| enum: scope_kind | |
| function_scope: | |
| seq: | |
| - id: scope | |
| type: xdr_sized_binding_names | |
| - id: needs_environment | |
| type: u1 | |
| - id: has_parameter_exprs | |
| type: u1 | |
| - id: is_field_initializer | |
| type: u1 | |
| - id: non_positional_formal_start | |
| type: u2 | |
| - id: var_start | |
| type: u2 | |
| - id: next_frame_slot | |
| type: u4 | |
| global_scope: | |
| seq: | |
| - id: scope | |
| type: xdr_sized_binding_names | |
| - id: let_start | |
| type: u4 | |
| - id: const_start | |
| type: u4 | |
| xdr_sized_binding_names: | |
| seq: | |
| - id: length | |
| type: u4 | |
| - id: trailing_names | |
| type: xdr_trailing_name | |
| repeat: expr | |
| repeat-expr: length | |
| xdr_trailing_name: | |
| seq: | |
| - id: u8 | |
| type: u1 | |
| - id: atom | |
| type: xdr_atom | |
| if: has_atom != 0 | |
| instances: | |
| has_atom: | |
| value: u8 & 1 # HasAtomMask | |
| enums: | |
| class_kind: | |
| 0x00: regexp_object | |
| 0x01: js_function | |
| 0x02: js_object | |
| 0x03: array_object | |
| gc_thing_tag: | |
| 0x00: object | |
| 0x01: scope | |
| xdr_data_type: | |
| 0x00: compressed_utf8_retrievable | |
| 0x01: uncompressed_utf8_retrievable | |
| 0x02: compressed_utf8_not_retrievable | |
| 0x03: uncompressed_utf8_not_retrievable | |
| 0x04: compressed_utf16_retrievable | |
| 0x05: uncompressed_utf16_retrievable | |
| 0x06: compressed_utf16_not_retrievable | |
| 0x07: uncompressed_utf16_not_retrievable | |
| 0x08: retrievable_utf8 | |
| 0x09: retrievable_utf16 | |
| 0x0A: missing | |
| 0x0B: bin_ast | |
| scope_kind: | |
| 0x00: function | |
| 0x01: function_body_var | |
| 0x02: parameter_expression_var | |
| 0x03: lexical | |
| 0x04: simple_catch | |
| 0x05: catch | |
| 0x06: named_lambda | |
| 0x07: strict_named_lambda | |
| 0x08: with | |
| 0x09: eval | |
| 0x0A: strict_eval | |
| 0x0B: global | |
| 0x0C: non_syntactic | |
| 0x0D: module | |
| 0x0E: wasm_instance | |
| 0x0F: wasm_function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment