Mach-O (macOS / iOS) binary reader in pure OCaml
0

Configure Feed

Select the types of activity you want to include in your feed.

mach-o: restore hexadecimal magic in rejection messages

The optint migration switched the not-a-Mach-O and bad-magic messages to Optint.pp, which prints decimal; a magic is only recognisable in hex, and the README's documented output says so. Print the unsigned value with 0x%08x as before, and compare magics with Optint.equal rather than the polymorphic operators.

+5 -4
+5 -4
lib/mach_o.ml
··· 367 367 in 368 368 let* () = 369 369 guard 370 - (u32_le data off <> mh_magic_64) 370 + (not (Optint.equal (u32_le data off) mh_magic_64)) 371 371 "fat slice is not a 64-bit Mach-O" 372 372 in 373 373 Ok off ··· 376 376 slice for a fat binary. *) 377 377 let thin_base data ~len = 378 378 let magic = u32_le data 0 in 379 - if magic = mh_magic_64 then Ok 0 379 + if Optint.equal magic mh_magic_64 then Ok 0 380 380 else 381 381 let fat = u32_be_word data 0 in 382 382 if Optint.equal fat fat_magic then pick_fat data ~len ~is64:false 383 383 else if Optint.equal fat fat_magic_64 then pick_fat data ~len ~is64:true 384 - else err "not a 64-bit Mach-O (magic %a)" Optint.pp magic 384 + else err "not a 64-bit Mach-O (magic 0x%08x)" (Optint.to_unsigned_int magic) 385 385 386 386 (* Read the defined symbols, after bounds-checking the table extents. *) 387 387 let read_symtab data ~len = function ··· 403 403 let* () = 404 404 Fmt.kstr 405 405 (guard (not (Optint.equal hdr.magic mh_magic_64))) 406 - "bad Mach magic %a" Optint.pp hdr.magic 406 + "bad Mach magic 0x%08x" 407 + (Optint.to_unsigned_int hdr.magic) 407 408 in 408 409 let lc_off = base + header_size in 409 410 let end_lc = lc_off + hdr.sizeofcmds in