Skip to content
This repository was archived by the owner on Dec 3, 2023. It is now read-only.

dodrio/beam_rewriter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

beam_rewriter

Rewrite BEAM files with ease.

Notice #2

This project is abandoned, due to that I have found a way to remove source name references from BEAM files —— deterministic option of Erlang compiler.

Then, I have no need to modify Line chunk.

Notice #1

This project is still in development.

Right now, I'm stuck on the issue of "encoding/decoding chunk data". As described here, almost all the chunks have their own unique data format, but this documentation only covers a limited number of chunks, lacking the chunks what I need, such as Line chunk.

Before proceeding with the development, I need to understand the data format of all the chunks. However, with my limited experience of C or Erlang, it's difficult to dig the data format. Therefore, the development is indefinitely postponed.

If you have knowledge in this area, please feel free to reach out to me.

Build

$ mix escript.build

Then, the generated escript will be placed at escript/beam_rewriter.

Usage

Syntax

beam_rewriter <wildcard> \
  --substitute-chunk <chunk name> <pattern> <replacement> \
  --delete-chunk <chunk name>

Examples

# substitue string in a chunk
$ beam_rewriter ./parser.beam \
  --substitute-chunk Line "/nix/store" "/nix-store"

# delete a chunk
$ beam_rewriter ./parser.beam \
  --delete-chunk Dbgi \

# substitue string in a chunk, and delete a chunk
$ beam_rewriter ./parser.beam \
  --substitute-chunk Line "/nix/store" "/nix-store" \
  --delete-chunk Dbgi \

# specify files by a wildcard
$ beam_rewriter **/*.beam \
  --substitute-chunk Line "/nix/store" "/nix-store"

# specify files by a wildcard and multiple filenames
$ beam_rewriter *.beam lib/parser.beam lib/compiler.beam \
  --substitute-chunk Line "/nix/store" "/nix-store"

In pratice, you shouldn't delete arbitrary chunks. Here is just a demonstration of how to use this program.

References

License

MIT

About

Rewrite BEAM files with ease.

Resources

Stars

Watchers

Forks

Languages