From 09a89bc626143492c40791d66c68af8b1fbf5e02 Mon Sep 17 00:00:00 2001 From: Bill Yang Date: Thu, 21 Mar 2024 10:40:46 -0700 Subject: [PATCH] add comment explaining why load_command search works --- util/fipstools/inject_hash/macho_parser/macho_parser.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/fipstools/inject_hash/macho_parser/macho_parser.c b/util/fipstools/inject_hash/macho_parser/macho_parser.c index 5a0958bcf61..04cd5b320aa 100644 --- a/util/fipstools/inject_hash/macho_parser/macho_parser.c +++ b/util/fipstools/inject_hash/macho_parser/macho_parser.c @@ -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];