summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--src/elfo.zig12
-rw-r--r--tmpbin0 -> 61772 bytes
3 files changed, 7 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index 2b27afe..9a778e5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ dirty-pin
zig-pkg
zig-out
*a.out
+.claude
diff --git a/src/elfo.zig b/src/elfo.zig
index 264ba4d..e07620c 100644
--- a/src/elfo.zig
+++ b/src/elfo.zig
@@ -19,7 +19,7 @@ pub fn main(init: std.process.Init.Minimal) !void {
_ = args.next(); // skip argv[0]
var buffer: [64]u8 = undefined;
- const stderr = try io.lockStderr(&buffer, .escape_codes);
+ const stderr = try io.lockStderr(&buffer, null);
// const hook = hooks.init(
// if (meta.gdb) .breakpoint else .none,
@@ -69,9 +69,9 @@ pub fn printElf(
var reader = f.reader(io, buffer);
const header = try std.elf.Header.read(&reader.interface);
- var handle: usize = undefined;
- defer _ = cs.cs_close(@ptrCast(&handle));
- const opts: struct { arch: u64, mode: u64 } = switch (header.machine) {
+ var cs_handle: usize = undefined;
+ defer _ = cs.cs_close(@ptrCast(&cs_handle));
+ const cs_opts: struct { arch: u64, mode: u64 } = switch (header.machine) {
.X86_64 => .{ .arch = cs.CS_ARCH_X86, .mode = cs.CS_MODE_64 },
// The arm mode isn't working with symbols on the .text section correctly
.ARM => .{ .arch = cs.CS_ARCH_ARM, .mode = if (header.is_64) cs.CS_MODE_64 else cs.CS_MODE_32 },
@@ -81,7 +81,7 @@ pub fn printElf(
},
};
- std.debug.assert(cs.cs_open(@intCast(opts.arch), @intCast(opts.mode), @ptrCast(&handle)) == cs.CS_ERR_OK);
+ std.debug.assert(cs.cs_open(@intCast(cs_opts.arch), @intCast(cs_opts.mode), @ptrCast(&cs_handle)) == cs.CS_ERR_OK);
const shstrtab = blk: {
var section_it = header.iterateSectionHeaders(&reader);
@@ -290,7 +290,7 @@ pub fn printElf(
// TODO: use iter API
// https://www.capstone-engine.org/iteration.html
// const count = cs.cs_disasm_iter(handle, section_slice.?.ptr, section_slice.?.len, section.sh_addr, @ptrCast(&insn));
- const count = cs.cs_disasm(handle, section_slice.?.ptr, section_slice.?.len, section.sh_addr, 0, @ptrCast(&insn));
+ const count = cs.cs_disasm(cs_handle, section_slice.?.ptr, section_slice.?.len, section.sh_addr, 0, @ptrCast(&insn));
break :blk insn[0..count];
};
diff --git a/tmp b/tmp
new file mode 100644
index 0000000..e2ee218
--- /dev/null
+++ b/tmp
Binary files differ