Skip to content

Commit

Permalink
Fix endianness of coverage data on big endian systems
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Jul 29, 2022
1 parent c6af98b commit f2b7104
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion frida_mode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ instances run CMPLOG mode and instrumentation of the binary is less frequent
* `AFL_FRIDA_INST_DEBUG_FILE` - File to write raw assembly of original blocks
and their instrumented counterparts during block compilation.

```
Creating block for 0x7ffff7953313:
0x7ffff7953313 mov qword ptr [rax], 0
0x7ffff795331a add rsp, 8
Expand All @@ -166,7 +167,7 @@ Generated block 0x7ffff75e98e2
***
```
```
* `AFL_FRIDA_INST_CACHE_SIZE` - Set the size of the instrumentation cache used
as a look-up table to cache real to instrumented address block translations.
Default is 256Mb.
Expand Down
6 changes: 6 additions & 0 deletions frida_mode/src/instrument/instrument_coverage.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@ static void coverage_write_events(void *key, void *value, void *user_data) {

};

#if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
evt.offset = __builtin_bswap32(evt.offset);
evt.length = __builtin_bswap16(evt.length);
evt.module = __builtin_bswap16(evt.module);
#endif

coverage_write(fd, &evt, sizeof(coverage_event_t));

}
Expand Down

0 comments on commit f2b7104

Please sign in to comment.