010Editor template for .abc (Open/HarmonyOS Ark Bytecode) files
Note: this is NOT a disassembler for the bytecode, but a parser for the file format that contains the bytecode. (Think .dex vs Dalvik bytecode)
For a disassembler, see https://gitee.com/openharmony/arkcompiler_runtime_core/blob/master/README.md#disassembler-ark_disasm.
- Parsing of
LiteralArraycan be flawed due to poor documentation. By the documentation (seeReferencessection for a link), aLiteralArrayhas two fields:num_literalswhich indicates the number of literals thisLiteralArraycontains (somehow the number must be divided by 2 to get the actual number), andliteralswhich is an array ofLiteral. TheLiteralstruct, as it turns out, follows a Tag-Value format, which means the first field is a tag determining how the second field should be interpreted. Unfortunately, the tags are not documented at all. I had to extract them from the source code, but I'm not 100% sure if I understood everything in the relevant code correctly, especially theLiteralTag::ARRAY_*tags, given that this is such a huge project. - Parsing of methods referred to by
MethodRegionIndexis still problematic, so this part of code has been commented out. - Parsing of
ProtoandMethodHandleis not implemented yet. - Parsing of
LineNumberProgramis flawed too, as the operands in a line number program are not handled at all, and as such a0x0operand would be misinterpreted as marking the end of the program. - Should be fixed already (if I was looking at the right place in the code!).
Parsing ofValueofanytype is not implemented. TheValuestruct is used when aField, in itsfield_data, has aTaggedValuewith the tagVALUE(bit of a tongue twister).Valuefollows a Tag-Value format too (but the "tag" is indicated by a field namedtype_idxinField), whose tag is - surprise surprise - poorly documented. Luckily, this time the code is simpler, except for the0x0btag, which means the type of the value isany. I have no idea what this type means and how it should be interpreted.
- Official documentation for the .abc format (Careful, a few things in it are not accurate or up-to-date)
arkcompiler\runtime_core\libpandafile\literal_data_accessor.harkcompiler\ets_runtime\ecmascript\jspandafile\js_pandafile.cpp- FieldTag:
arkcompiler\runtime_core\libpandafile\field_data_accessor.cpp - LiteralTag:
arkcompiler\runtime_core\libpandafile\literal_data_accessor-inl.h - Official ABC static defect scanner
- 2024/7/27: Added support for abc version >= 12.0.1.0
- 2024/9/28: Fixed size of
modulerecord_literalarrs; better handling ofconstant_pool