BEAM file dis-assembler
Based on compiler/src/beam_disasm.erl
(special purpose BEAM dis-assembler
in the OTP Compiler application. used by HiPE).
Disassemble a_module.beam
in order to get a_module.S
which
can be (modified and then) compiled with erlc a_module.S
.
$ rebar3 escriptize
results in _build/default/bin/beam_disassemble
beam_disassemble path/to/beam_file1.beam path/to/beam_file2.beam ...
disassemble the BEAM(s) and create .S
file(s) in the current directory.
beam_disassemble
will try to validate the results (withcompile:file/2
)
beam_disassemble --regression-test
find all BEAM files in code path, disassemble and validate.
write regression_test.log
and .S
files of modules that failed
validation to the current directory.
"scratch an itch"-software: will not be maintained/supported
The format of assembler files is not documented, and can change between OTP releases.
When running the regression test on an OTP 19.3.1 installation, it was found that:
-
beam_type.S
fromlib/compiler-7.0.4/ebin/beam_type.beam
does not validate, but if abeam_type.beam
is created witherlc -I lib/compiler-7.0.4/src lib/compiler-7.0.4
and then disassembled, the result validates. -
sys_core_fold.S
fromlib/compiler-7.0.4/ebin/sys_core_fold.beam
does not validate, but ansys_core_fold.S
created byerlc -S lib/compiler-7.0.4/src/sys_core_fold.beam
does also fail to compile (identical error). -
public_key.S
fromlib/public_key-1.4/ebin/public_key.beam
does not validate, but anpublic_key.S
created byerlc -S -I lib/public_key-1.4/include lib/public_key-1.4/src/public_key.erl
does also fail to compile (identical error). -
test_server_node.S
fromlib/common_test-1.114/ebin/test_server_node.beam
does not validate, but antest_server_node.S
created byerlc -S -I lib/common_test-1.114/src lib/common_test-1.114/src/test_server_node.erl
does also fail to compile (identical error) -
wx_object.S
fromlib/wx-1.8/ebin/wx_object.beam
does not validate, but anwx_object.S
created byerlc -S -I lib/wx-1.8/include lib/wx-1.8/src/wx_object.erl
does also fail to compile (identical error).