diff options
| author | Jeffrey Yasskin <[email protected]> | 2010-07-10 15:43:48 +0800 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2010-07-16 08:13:07 +0800 |
| commit | 9c4bc7b872569a7d71622c9f56a11e81edec741d (patch) | |
| tree | a5256174cefc0d55df5c68596a7d845cf22d0a92 /src/boot | |
| parent | Merge branch 'master' of [email protected]:graydon/rust (diff) | |
| download | rust-9c4bc7b872569a7d71622c9f56a11e81edec741d.tar.xz rust-9c4bc7b872569a7d71622c9f56a11e81edec741d.zip | |
In Mach-O shared libraries, avoid counting an extra load command. Closes #99.
Diffstat (limited to 'src/boot')
| -rw-r--r-- | src/boot/be/macho.ml | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/boot/be/macho.ml b/src/boot/be/macho.ml index 7fccdfd3..cdb16ba3 100644 --- a/src/boot/be/macho.ml +++ b/src/boot/be/macho.ml @@ -591,6 +591,11 @@ let macho_header_32 (flags:file_flag list) (loadcmds:frag array) : frag = let load_commands_fixup = new_fixup "load commands" in + let count_non_mark so_far elem = + match elem with + MARK -> so_far + | _ -> so_far + 1 + in let cmds = DEF (load_commands_fixup, SEQ loadcmds) in SEQ [| @@ -598,7 +603,8 @@ let macho_header_32 WORD (TY_u32, IMM (cpu_type_code cpu)); WORD (TY_u32, IMM (cpu_subtype_code sub)); WORD (TY_u32, IMM (file_type_code ftype)); - WORD (TY_u32, IMM (Int64.of_int (Array.length loadcmds))); + WORD (TY_u32, + IMM (Int64.of_int (Array.fold_left count_non_mark 0 loadcmds))); WORD (TY_u32, F_SZ load_commands_fixup); WORD (TY_u32, IMM (fold_flags file_flag_code flags)); cmds |