@@ -200,32 +200,31 @@ let resolve_stubs () =
200200 KB. collect References. slot unit >> = fun refs ->
201201 KB. collect Theory.Label. addr label >> =? fun addr ->
202202 KB. collect (Value.Tag. slot Sub. stub) label >> = fun is_stub ->
203- if not (Option. is_some is_stub) then KB. return None
204- else match References. lookup refs addr with
205- | Some (Name s ) -> KB. return (Some s)
206- | _ ->
207- plt_size label >> =? fun size ->
208- collect_insns size addr >> | fun bil ->
209- find_references bil |>
210- List. find_map ~f: (function
211- | Name s -> Some s
212- | Addr dst -> match References. lookup refs dst with
213- | Some (Name s ) -> Some s
214- | _ -> None )
203+ KB. guard (Option. is_some is_stub) >> = fun () ->
204+ match References. lookup refs addr with
205+ | Some (Name s ) -> KB. return (Some s)
206+ | _ ->
207+ plt_size label >> =? fun size ->
208+ collect_insns size addr >> | fun bil ->
209+ find_references bil |>
210+ List. find_map ~f: (function
211+ | Name s -> Some s
212+ | Addr dst -> match References. lookup refs dst with
213+ | Some (Name s ) -> Some s
214+ | _ -> None )
215215
216216let label_for_ref = function
217217 | Name s -> Theory.Label. for_name s
218218 | Addr x -> Theory.Label. for_addr x
219219
220220let mark_mips_stubs_as_functions () : unit =
221221 KB. promise Theory.Label. is_subroutine @@ fun label ->
222- KB. collect Theory.Label. addr label >> =? fun addr ->
223- KB. collect Theory.Label. unit label >> =? fun unit ->
224- KB. collect References. slot unit >> = fun refs ->
225- KB. collect Theory.Unit. target unit >> | fun target ->
226- let is_entry = (Theory.Target. matches target " mips" ) &&
227- Option. is_some (References. lookup refs addr) in
228- Option. some_if is_entry true
222+ let * unit = label-->? Theory.Label. unit in
223+ let * target = unit --> Theory.Unit. target in
224+ KB. guard (Theory.Target. matches target " mips" ) >> = fun () ->
225+ let * addr = label-->? Theory.Label. addr in
226+ KB. collect References. slot unit >> | fun refs ->
227+ Option. (some_if (is_some (References. lookup refs addr))) true
229228
230229let () = Extension. declare ~doc @@ fun _ctxt ->
231230 References. prepare () ;
0 commit comments