Skip to content

Commit 38da75d

Browse files
jyasskingraydon
authored andcommitted
---
yaml --- r: 275 b: refs/heads/master c: 29d0458 h: refs/heads/master i: 273: 88fe0f2 271: bdb2264 v: v3
1 parent 04b825e commit 38da75d

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 9c4bc7b872569a7d71622c9f56a11e81edec741d
2+
refs/heads/master: 29d0458814b942cf7a86b68d7a33e88731e55331

trunk/src/boot/be/macho.ml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ let iflog (sess:Session.sess) (thunk:(unit -> unit)) : unit =
1515
else ()
1616
;;
1717

18+
let filter_marks (orig:frag array) : frag array =
19+
let not_mark (elem:frag) =
20+
match elem with
21+
MARK -> None
22+
| x -> Some x
23+
in arr_map_partial orig not_mark
24+
;;
25+
1826
let (cpu_arch_abi64:int64) = 0x01000000L
1927
;;
2028

@@ -591,20 +599,14 @@ let macho_header_32
591599
(flags:file_flag list)
592600
(loadcmds:frag array) : frag =
593601
let load_commands_fixup = new_fixup "load commands" in
594-
let count_non_mark so_far elem =
595-
match elem with
596-
MARK -> so_far
597-
| _ -> so_far + 1
598-
in
599602
let cmds = DEF (load_commands_fixup, SEQ loadcmds) in
600603
SEQ
601604
[|
602605
WORD (TY_u32, IMM mh_magic);
603606
WORD (TY_u32, IMM (cpu_type_code cpu));
604607
WORD (TY_u32, IMM (cpu_subtype_code sub));
605608
WORD (TY_u32, IMM (file_type_code ftype));
606-
WORD (TY_u32,
607-
IMM (Int64.of_int (Array.fold_left count_non_mark 0 loadcmds)));
609+
WORD (TY_u32, IMM (Int64.of_int (Array.length loadcmds)));
608610
WORD (TY_u32, F_SZ load_commands_fixup);
609611
WORD (TY_u32, IMM (fold_flags file_flag_code flags));
610612
cmds
@@ -873,8 +875,10 @@ let emit_file
873875

874876
let load_commands =
875877
[|
876-
macho_segment_command "__PAGEZERO" zero_segment_fixup
877-
[] [] [||];
878+
if sess.Session.sess_library_mode
879+
then MARK
880+
else (macho_segment_command "__PAGEZERO" zero_segment_fixup
881+
[] [] [||]);
878882

879883
macho_segment_command "__TEXT" text_segment_fixup
880884
[VM_PROT_READ; VM_PROT_EXECUTE]
@@ -949,7 +953,7 @@ let emit_file
949953
CPU_SUBTYPE_X86_ALL
950954
(if sess.Session.sess_library_mode then MH_DYLIB else MH_EXECUTE)
951955
[ MH_BINDATLOAD; MH_DYLDLINK; MH_TWOLEVEL ]
952-
load_commands
956+
(filter_marks load_commands)
953957
in
954958

955959
let objfile_start e start_fixup rust_start_fixup main_fn_fixup =

0 commit comments

Comments
 (0)