Skip to content

Commit

Permalink
Release commit created with Cranko.
Browse files Browse the repository at this point in the history
+++ cranko-release-info-v1
[[projects]]
qnames = ["elfx86exts", "cargo"]
version = "0.6.2"
age = 0

+++
  • Loading branch information
cranko committed Oct 22, 2023
2 parents a23036f + c3a1bca commit 1c92372
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 14 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# elfx86exts 0.6.2 (2023-10-22)

- Fix excessive memory consumption (@HanabishiRecca, #2, #90, #173). For a long
time, we have known that this program can consume surprisingly large amounts
of memory when processing large programs (well, and small ones too). It turns
out that if we simply disassemble one instruction at a time instead of in
bulk, not only do the memory requirements go way down, but the program is much
faster too! Thanks again to @HanabishiRecca for finally solving this
longstanding issue.


# elfx86exts 0.6.1 (2023-10-21)

- Ignore invalid instructions when parsing the executable (@HanabishiRecca,
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[package]
name = "elfx86exts"
version = "0.6.1"
version = "0.6.2"
authors = ["Peter Williams <peter@newton.cx>"]
description = "Decode x86 binaries (ELF or MachO) and print out which instruction set extensions they use."
homepage = "https://github.com/pkgw/elfx86exts"
Expand Down
35 changes: 23 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,21 +277,32 @@ fn main() {
}

let data = sect.data().expect("couldn't get section data");
let mut offset = 0;

let insns = cs
.disasm_all(data, sect.address())
.expect("couldn't disassemble section");
loop {
let rest = &data[offset..];

for insn in insns.iter() {
let Ok(detail) = cs.insn_detail(insn) else {
continue;
};
if rest.is_empty() {
break;
}

let insns = cs
.disasm_count(rest, 0, 1)
.expect("couldn't disassemble section");

for insn in insns.iter() {
offset += insn.bytes().len();

let Ok(detail) = cs.insn_detail(insn) else {
continue;
};

for group_code in detail.groups() {
if seen_groups.insert(group_code.0) {
if let Some(mnemonic) = insn.mnemonic() {
if let Some(desc) = describe_group(&group_code.0) {
println!("{} ({})", desc, mnemonic);
for group_code in detail.groups() {
if seen_groups.insert(group_code.0) {
if let Some(mnemonic) = insn.mnemonic() {
if let Some(desc) = describe_group(&group_code.0) {
println!("{} ({})", desc, mnemonic);
}
}
}
}
Expand Down

0 comments on commit 1c92372

Please sign in to comment.