Skip to content

Commit

Permalink
test symtab swap and fix doc string
Browse files Browse the repository at this point in the history
  • Loading branch information
latonis committed Jan 13, 2024
1 parent e1dd0a0 commit 6ba9d16
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion yara-x/src/modules/macho/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ struct LoadCommand {

/// `SymtabCommand`: Represents a symbol table load command in the Mach-O file.
/// Fields: cmd, cmdsize, symoff, nsyms, stroff, strsize
///
#[derive(Debug, Default, Clone, Copy)]
struct SymtabCommand {
cmd: u32,
cmdsize: u32,
Expand Down
22 changes: 22 additions & 0 deletions yara-x/src/modules/macho/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,28 @@ fn test_swap_rpath_command() {
assert_eq!(command.cmdsize, 0x88776655);
}

#[test]
fn test_swap_symtab_command() {
let mut command = SymtabCommand {
cmd: 0x11223344,
cmdsize: 0x55667788,
symoff: 0x99AABBCC,
nsyms: 0xDDDDFFFF,
stroff: 0xEEEEEEEE,
strsize: 0x11111111,
..Default::default()
};

swap_symtab_command(&mut command);

assert_eq!(command.cmd, 0x44332211);
assert_eq!(command.cmdsize, 0x88776655);
assert_eq!(command.symoff, 0xCCBBAA99);
assert_eq!(command.nsyms, 0xFFFFDDDD);
assert_eq!(command.stroff, 0xEEEEEEEE);
assert_eq!(command.strsize, 0x11111111);
}

#[test]
fn test_swap_segment_command() {
let mut segment = SegmentCommand32 {
Expand Down

0 comments on commit 6ba9d16

Please sign in to comment.