Skip to content

Commit

Permalink
add comment explaining why load_command search works
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Yang authored and billbo-yang committed Apr 10, 2024
1 parent 6418f50 commit a064787
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions util/fipstools/inject_hash/macho_parser/macho_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ int read_macho_file(const char *filename, machofile *macho) {
int const_found = 0;
int symtab_found = 0;

// mach-o/loader.h explains that cmdsize (and by extension sizeofcmds) must be a multiple of 8 on 64-bit systems. struct load_command will always be 8 bytes.
for (uint32_t i = 0; i < macho->macho_header.sizeofcmds / sizeof(struct load_command); i += load_commands[i].cmdsize / sizeof(struct load_command)) {
if (load_commands[i].cmd == LC_SEGMENT_64) {
struct segment_command_64 *segment = (struct segment_command_64 *)&load_commands[i];
Expand Down

0 comments on commit a064787

Please sign in to comment.