Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excercise n1 #4

Merged
merged 1 commit into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
248 changes: 248 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4.0.26", features = ["derive"] }
regex = "1.7.0"
lazy_static = "1.4.0"
indoc = "1.0"
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,53 @@
Copyright 2022 SECO Mind Srl
SPDX-License-Identifier: Apache-2.0
-->

# disasm-util

`disasm-util` is a simple command line utility to parse the output of the `objdump` tool, part of
the GNU Binary Utilities.

## Supported inputs

Support is only provided for a specific configuration of `objdump`, the tool should be run as for
the following:
```
objdump -d --no-addresses --no-show-raw-insn
```
The required flags are:
- `-d`, `-disassemble`: print assembler mnemonics for the machine instructions.
- `--no-addresses`: when disassembling do not print addresses.
- `--no-show-raw-insn`: when disassembling do not print instruction's bytes.

See the [GNU Binutils](https://sourceware.org/binutils/docs-2.39/binutils/index.html) documentation
for more information.

## Usage

The utility is provided as a rust binary crate.
Building and executing the tool can be achieved by running the following from terminal:
```
cargo run -- <objdump_out_file>
```
This command requires `rust` to be installed on your system. See the
[rust documentation](https://doc.rust-lang.org/book/) for more information.

## Parsed output

The input file is parsed and saved to a new file with the same name as the imput file plus the
`-parsed` keyword appended at the end.
The parsed output is in the following format:
```
section 1 name:
symbol 1 name:
opcode instruction 1
symbol 2 name:
opcode instruction 2
opcode instruction 3
opcode instruction 4
section 2 name:
symbol 3 name:
opcode instruction 5
opcode instruction 6
```
Sections and symbols are alphabetically sorted.
Loading