PR#5033: tools/objinfo made more general.

tools/dumpapprox removed, now subsumed by tools/objinfo.
Introduced asmcomp/cmx_format.mli and used consistently in asmcomp,
  tools/objinfo, and otherlibs/dynlink
Note: ocamlbuild -based build procedure not updated yet.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10424 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Xavier Leroy 2010-05-19 11:29:38 +00:00
parent fc2dea6d3d
commit 2adec7d747
21 changed files with 401 additions and 332 deletions

99
.depend
View File

@ -472,20 +472,23 @@ bytecomp/typeopt.cmx: typing/types.cmx typing/typedtree.cmx \
parsing/asttypes.cmi bytecomp/typeopt.cmi
asmcomp/asmgen.cmi: bytecomp/lambda.cmi asmcomp/cmm.cmi
asmcomp/asmlibrarian.cmi:
asmcomp/asmlink.cmi: asmcomp/compilenv.cmi
asmcomp/asmlink.cmi: asmcomp/cmx_format.cmi
asmcomp/asmpackager.cmi:
asmcomp/clambda.cmi: bytecomp/lambda.cmi typing/ident.cmi \
asmcomp/debuginfo.cmi parsing/asttypes.cmi
asmcomp/closure.cmi: bytecomp/lambda.cmi asmcomp/clambda.cmi
asmcomp/cmmgen.cmi: asmcomp/cmx_format.cmi asmcomp/cmm.cmi \
asmcomp/clambda.cmi
asmcomp/cmm.cmi: typing/ident.cmi asmcomp/debuginfo.cmi
asmcomp/cmmgen.cmi: asmcomp/compilenv.cmi asmcomp/cmm.cmi asmcomp/clambda.cmi
asmcomp/cmx_format.cmi: asmcomp/clambda.cmi
asmcomp/codegen.cmi: asmcomp/cmm.cmi
asmcomp/coloring.cmi:
asmcomp/comballoc.cmi: asmcomp/mach.cmi
asmcomp/compilenv.cmi: typing/ident.cmi asmcomp/clambda.cmi
asmcomp/compilenv.cmi: typing/ident.cmi asmcomp/cmx_format.cmi \
asmcomp/clambda.cmi
asmcomp/debuginfo.cmi: parsing/location.cmi bytecomp/lambda.cmi
asmcomp/emit.cmi: asmcomp/linearize.cmi asmcomp/cmm.cmi
asmcomp/emitaux.cmi: asmcomp/debuginfo.cmi
asmcomp/emit.cmi: asmcomp/linearize.cmi asmcomp/cmm.cmi
asmcomp/interf.cmi: asmcomp/mach.cmi
asmcomp/linearize.cmi: asmcomp/reg.cmi asmcomp/mach.cmi asmcomp/debuginfo.cmi
asmcomp/liveness.cmi: asmcomp/mach.cmi
@ -496,8 +499,8 @@ asmcomp/printlinear.cmi: asmcomp/linearize.cmi
asmcomp/printmach.cmi: asmcomp/reg.cmi asmcomp/mach.cmi
asmcomp/proc.cmi: asmcomp/reg.cmi asmcomp/mach.cmi
asmcomp/reg.cmi: asmcomp/cmm.cmi
asmcomp/reload.cmi: asmcomp/mach.cmi
asmcomp/reloadgen.cmi: asmcomp/reg.cmi asmcomp/mach.cmi
asmcomp/reload.cmi: asmcomp/mach.cmi
asmcomp/schedgen.cmi: asmcomp/mach.cmi asmcomp/linearize.cmi
asmcomp/scheduling.cmi: asmcomp/linearize.cmi
asmcomp/selectgen.cmi: utils/tbl.cmi asmcomp/reg.cmi asmcomp/mach.cmi \
@ -526,31 +529,35 @@ asmcomp/asmgen.cmx: bytecomp/translmod.cmx asmcomp/split.cmx \
asmcomp/comballoc.cmx asmcomp/coloring.cmx asmcomp/cmmgen.cmx \
asmcomp/cmm.cmx asmcomp/closure.cmx utils/clflags.cmx asmcomp/asmgen.cmi
asmcomp/asmlibrarian.cmo: utils/misc.cmi utils/config.cmi \
asmcomp/compilenv.cmi utils/clflags.cmi asmcomp/clambda.cmi \
utils/ccomp.cmi asmcomp/asmlink.cmi asmcomp/asmlibrarian.cmi
asmcomp/compilenv.cmi asmcomp/cmx_format.cmi utils/clflags.cmi \
asmcomp/clambda.cmi utils/ccomp.cmi asmcomp/asmlink.cmi \
asmcomp/asmlibrarian.cmi
asmcomp/asmlibrarian.cmx: utils/misc.cmx utils/config.cmx \
asmcomp/compilenv.cmx utils/clflags.cmx asmcomp/clambda.cmx \
utils/ccomp.cmx asmcomp/asmlink.cmx asmcomp/asmlibrarian.cmi
asmcomp/compilenv.cmx asmcomp/cmx_format.cmi utils/clflags.cmx \
asmcomp/clambda.cmx utils/ccomp.cmx asmcomp/asmlink.cmx \
asmcomp/asmlibrarian.cmi
asmcomp/asmlink.cmo: bytecomp/runtimedef.cmi asmcomp/proc.cmi utils/misc.cmi \
parsing/location.cmi asmcomp/emitaux.cmi asmcomp/emit.cmi \
utils/consistbl.cmi utils/config.cmi asmcomp/compilenv.cmi \
asmcomp/cmmgen.cmi utils/clflags.cmi utils/ccomp.cmi asmcomp/asmgen.cmi \
asmcomp/asmlink.cmi
asmcomp/cmx_format.cmi asmcomp/cmmgen.cmi utils/clflags.cmi \
utils/ccomp.cmi asmcomp/asmgen.cmi asmcomp/asmlink.cmi
asmcomp/asmlink.cmx: bytecomp/runtimedef.cmx asmcomp/proc.cmx utils/misc.cmx \
parsing/location.cmx asmcomp/emitaux.cmx asmcomp/emit.cmx \
utils/consistbl.cmx utils/config.cmx asmcomp/compilenv.cmx \
asmcomp/cmmgen.cmx utils/clflags.cmx utils/ccomp.cmx asmcomp/asmgen.cmx \
asmcomp/asmlink.cmi
asmcomp/cmx_format.cmi asmcomp/cmmgen.cmx utils/clflags.cmx \
utils/ccomp.cmx asmcomp/asmgen.cmx asmcomp/asmlink.cmi
asmcomp/asmpackager.cmo: typing/typemod.cmi bytecomp/translmod.cmi \
utils/misc.cmi parsing/location.cmi bytecomp/lambda.cmi typing/ident.cmi \
typing/env.cmi utils/config.cmi asmcomp/compilenv.cmi utils/clflags.cmi \
asmcomp/clambda.cmi utils/ccomp.cmi asmcomp/asmlink.cmi \
asmcomp/asmgen.cmi asmcomp/asmpackager.cmi
typing/env.cmi utils/config.cmi asmcomp/compilenv.cmi \
asmcomp/cmx_format.cmi utils/clflags.cmi asmcomp/clambda.cmi \
utils/ccomp.cmi asmcomp/asmlink.cmi asmcomp/asmgen.cmi \
asmcomp/asmpackager.cmi
asmcomp/asmpackager.cmx: typing/typemod.cmx bytecomp/translmod.cmx \
utils/misc.cmx parsing/location.cmx bytecomp/lambda.cmx typing/ident.cmx \
typing/env.cmx utils/config.cmx asmcomp/compilenv.cmx utils/clflags.cmx \
asmcomp/clambda.cmx utils/ccomp.cmx asmcomp/asmlink.cmx \
asmcomp/asmgen.cmx asmcomp/asmpackager.cmi
typing/env.cmx utils/config.cmx asmcomp/compilenv.cmx \
asmcomp/cmx_format.cmi utils/clflags.cmx asmcomp/clambda.cmx \
utils/ccomp.cmx asmcomp/asmlink.cmx asmcomp/asmgen.cmx \
asmcomp/asmpackager.cmi
asmcomp/clambda.cmo: bytecomp/lambda.cmi typing/ident.cmi \
asmcomp/debuginfo.cmi parsing/asttypes.cmi asmcomp/clambda.cmi
asmcomp/clambda.cmx: bytecomp/lambda.cmx typing/ident.cmx \
@ -563,20 +570,22 @@ asmcomp/closure.cmx: utils/tbl.cmx bytecomp/switch.cmx typing/primitive.cmx \
utils/misc.cmx bytecomp/lambda.cmx typing/ident.cmx asmcomp/debuginfo.cmx \
asmcomp/compilenv.cmx utils/clflags.cmx asmcomp/clambda.cmx \
parsing/asttypes.cmi asmcomp/closure.cmi
asmcomp/cmmgen.cmo: typing/types.cmi bytecomp/switch.cmi asmcomp/proc.cmi \
typing/primitive.cmi utils/misc.cmi bytecomp/lambda.cmi typing/ident.cmi \
asmcomp/debuginfo.cmi utils/config.cmi asmcomp/compilenv.cmi \
asmcomp/cmx_format.cmi asmcomp/cmm.cmi utils/clflags.cmi \
asmcomp/clambda.cmi parsing/asttypes.cmi asmcomp/arch.cmo \
asmcomp/cmmgen.cmi
asmcomp/cmmgen.cmx: typing/types.cmx bytecomp/switch.cmx asmcomp/proc.cmx \
typing/primitive.cmx utils/misc.cmx bytecomp/lambda.cmx typing/ident.cmx \
asmcomp/debuginfo.cmx utils/config.cmx asmcomp/compilenv.cmx \
asmcomp/cmx_format.cmi asmcomp/cmm.cmx utils/clflags.cmx \
asmcomp/clambda.cmx parsing/asttypes.cmi asmcomp/arch.cmx \
asmcomp/cmmgen.cmi
asmcomp/cmm.cmo: typing/ident.cmi asmcomp/debuginfo.cmi asmcomp/arch.cmo \
asmcomp/cmm.cmi
asmcomp/cmm.cmx: typing/ident.cmx asmcomp/debuginfo.cmx asmcomp/arch.cmx \
asmcomp/cmm.cmi
asmcomp/cmmgen.cmo: typing/types.cmi bytecomp/switch.cmi asmcomp/proc.cmi \
typing/primitive.cmi utils/misc.cmi bytecomp/lambda.cmi typing/ident.cmi \
asmcomp/debuginfo.cmi utils/config.cmi asmcomp/compilenv.cmi \
asmcomp/cmm.cmi utils/clflags.cmi asmcomp/clambda.cmi \
parsing/asttypes.cmi asmcomp/arch.cmo asmcomp/cmmgen.cmi
asmcomp/cmmgen.cmx: typing/types.cmx bytecomp/switch.cmx asmcomp/proc.cmx \
typing/primitive.cmx utils/misc.cmx bytecomp/lambda.cmx typing/ident.cmx \
asmcomp/debuginfo.cmx utils/config.cmx asmcomp/compilenv.cmx \
asmcomp/cmm.cmx utils/clflags.cmx asmcomp/clambda.cmx \
parsing/asttypes.cmi asmcomp/arch.cmx asmcomp/cmmgen.cmi
asmcomp/codegen.cmo: asmcomp/split.cmi asmcomp/spill.cmi asmcomp/reload.cmi \
asmcomp/reg.cmi asmcomp/printmach.cmi asmcomp/printlinear.cmi \
asmcomp/printcmm.cmi asmcomp/liveness.cmi asmcomp/linearize.cmi \
@ -594,13 +603,21 @@ asmcomp/comballoc.cmo: asmcomp/reg.cmi asmcomp/mach.cmi utils/config.cmi \
asmcomp/comballoc.cmx: asmcomp/reg.cmx asmcomp/mach.cmx utils/config.cmx \
asmcomp/comballoc.cmi
asmcomp/compilenv.cmo: utils/misc.cmi typing/ident.cmi typing/env.cmi \
utils/config.cmi asmcomp/clambda.cmi asmcomp/compilenv.cmi
utils/config.cmi asmcomp/cmx_format.cmi asmcomp/clambda.cmi \
asmcomp/compilenv.cmi
asmcomp/compilenv.cmx: utils/misc.cmx typing/ident.cmx typing/env.cmx \
utils/config.cmx asmcomp/clambda.cmx asmcomp/compilenv.cmi
utils/config.cmx asmcomp/cmx_format.cmi asmcomp/clambda.cmx \
asmcomp/compilenv.cmi
asmcomp/debuginfo.cmo: parsing/location.cmi bytecomp/lambda.cmi \
asmcomp/debuginfo.cmi
asmcomp/debuginfo.cmx: parsing/location.cmx bytecomp/lambda.cmx \
asmcomp/debuginfo.cmi
asmcomp/emitaux.cmo: asmcomp/reg.cmi asmcomp/linearize.cmi \
asmcomp/debuginfo.cmi asmcomp/cmm.cmi asmcomp/arch.cmo \
asmcomp/emitaux.cmi
asmcomp/emitaux.cmx: asmcomp/reg.cmx asmcomp/linearize.cmx \
asmcomp/debuginfo.cmx asmcomp/cmm.cmx asmcomp/arch.cmx \
asmcomp/emitaux.cmi
asmcomp/emit.cmo: asmcomp/reg.cmi asmcomp/proc.cmi utils/misc.cmi \
asmcomp/mach.cmi asmcomp/linearize.cmi asmcomp/emitaux.cmi \
asmcomp/debuginfo.cmi utils/config.cmi asmcomp/compilenv.cmi \
@ -609,12 +626,6 @@ asmcomp/emit.cmx: asmcomp/reg.cmx asmcomp/proc.cmx utils/misc.cmx \
asmcomp/mach.cmx asmcomp/linearize.cmx asmcomp/emitaux.cmx \
asmcomp/debuginfo.cmx utils/config.cmx asmcomp/compilenv.cmx \
asmcomp/cmm.cmx utils/clflags.cmx asmcomp/arch.cmx asmcomp/emit.cmi
asmcomp/emitaux.cmo: asmcomp/reg.cmi asmcomp/linearize.cmi \
asmcomp/debuginfo.cmi asmcomp/cmm.cmi asmcomp/arch.cmo \
asmcomp/emitaux.cmi
asmcomp/emitaux.cmx: asmcomp/reg.cmx asmcomp/linearize.cmx \
asmcomp/debuginfo.cmx asmcomp/cmm.cmx asmcomp/arch.cmx \
asmcomp/emitaux.cmi
asmcomp/interf.cmo: asmcomp/reg.cmi asmcomp/proc.cmi utils/misc.cmi \
asmcomp/mach.cmi asmcomp/interf.cmi
asmcomp/interf.cmx: asmcomp/reg.cmx asmcomp/proc.cmx utils/misc.cmx \
@ -655,14 +666,14 @@ asmcomp/proc.cmx: asmcomp/reg.cmx utils/misc.cmx asmcomp/mach.cmx \
asmcomp/proc.cmi
asmcomp/reg.cmo: asmcomp/cmm.cmi asmcomp/reg.cmi
asmcomp/reg.cmx: asmcomp/cmm.cmx asmcomp/reg.cmi
asmcomp/reload.cmo: asmcomp/reloadgen.cmi asmcomp/reg.cmi asmcomp/mach.cmi \
asmcomp/cmm.cmi utils/clflags.cmi asmcomp/arch.cmo asmcomp/reload.cmi
asmcomp/reload.cmx: asmcomp/reloadgen.cmx asmcomp/reg.cmx asmcomp/mach.cmx \
asmcomp/cmm.cmx utils/clflags.cmx asmcomp/arch.cmx asmcomp/reload.cmi
asmcomp/reloadgen.cmo: asmcomp/reg.cmi utils/misc.cmi asmcomp/mach.cmi \
asmcomp/reloadgen.cmi
asmcomp/reloadgen.cmx: asmcomp/reg.cmx utils/misc.cmx asmcomp/mach.cmx \
asmcomp/reloadgen.cmi
asmcomp/reload.cmo: asmcomp/reloadgen.cmi asmcomp/reg.cmi asmcomp/mach.cmi \
asmcomp/cmm.cmi utils/clflags.cmi asmcomp/arch.cmo asmcomp/reload.cmi
asmcomp/reload.cmx: asmcomp/reloadgen.cmx asmcomp/reg.cmx asmcomp/mach.cmx \
asmcomp/cmm.cmx utils/clflags.cmx asmcomp/arch.cmx asmcomp/reload.cmi
asmcomp/schedgen.cmo: asmcomp/reg.cmi utils/misc.cmi asmcomp/mach.cmi \
asmcomp/linearize.cmi asmcomp/cmm.cmi asmcomp/arch.cmo \
asmcomp/schedgen.cmi
@ -693,8 +704,8 @@ asmcomp/split.cmx: asmcomp/reg.cmx utils/misc.cmx asmcomp/mach.cmx \
asmcomp/split.cmi
driver/compile.cmi: typing/env.cmi
driver/errors.cmi:
driver/main.cmi:
driver/main_args.cmi:
driver/main.cmi:
driver/optcompile.cmi: typing/env.cmi
driver/opterrors.cmi:
driver/optmain.cmi:
@ -727,6 +738,8 @@ driver/errors.cmx: utils/warnings.cmx typing/typetexp.cmx typing/typemod.cmx \
parsing/location.cmx parsing/lexer.cmx typing/includemod.cmx \
typing/env.cmx typing/ctype.cmx bytecomp/bytepackager.cmx \
bytecomp/bytelink.cmx bytecomp/bytelibrarian.cmx driver/errors.cmi
driver/main_args.cmo: utils/warnings.cmi driver/main_args.cmi
driver/main_args.cmx: utils/warnings.cmx driver/main_args.cmi
driver/main.cmo: utils/warnings.cmi utils/misc.cmi driver/main_args.cmi \
driver/errors.cmi utils/config.cmi driver/compile.cmi utils/clflags.cmi \
bytecomp/bytepackager.cmi bytecomp/bytelink.cmi \
@ -735,8 +748,6 @@ driver/main.cmx: utils/warnings.cmx utils/misc.cmx driver/main_args.cmx \
driver/errors.cmx utils/config.cmx driver/compile.cmx utils/clflags.cmx \
bytecomp/bytepackager.cmx bytecomp/bytelink.cmx \
bytecomp/bytelibrarian.cmx driver/main.cmi
driver/main_args.cmo: utils/warnings.cmi driver/main_args.cmi
driver/main_args.cmx: utils/warnings.cmx driver/main_args.cmi
driver/optcompile.cmo: utils/warnings.cmi typing/unused_var.cmi \
typing/typemod.cmi typing/typedtree.cmi bytecomp/translmod.cmi \
typing/stypes.cmi bytecomp/simplif.cmi typing/printtyp.cmi \

View File

@ -620,10 +620,10 @@ clean::
# Tools
ocamltools: ocamlc ocamlyacc ocamllex
ocamltools: ocamlc ocamlyacc ocamllex asmcomp/cmx_format.cmi
cd tools; $(MAKE) all
ocamltoolsopt.opt: ocamlc.opt ocamlyacc ocamllex
ocamltoolsopt.opt: ocamlc.opt ocamlyacc ocamllex asmcomp/cmx_format.cmi
cd tools; $(MAKE) opt.opt
partialclean::

View File

@ -551,9 +551,9 @@ clean::
# Tools
ocamltools:
ocamltools: asmcomp/cmx_format.cmi
cd tools ; $(MAKEREC) all
ocamltoolsopt.opt:
ocamltoolsopt.opt: asmcomp/cmx_format.cmi
cd tools ; $(MAKEREC) opt.opt
partialclean::
cd tools ; $(MAKEREC) clean

View File

@ -16,7 +16,7 @@
open Misc
open Config
open Compilenv
open Cmx_format
type error =
File_not_found of string

View File

@ -17,6 +17,7 @@
open Sys
open Misc
open Config
open Cmx_format
open Compilenv
type error =
@ -144,8 +145,8 @@ let extract_missing_globals () =
!mg
type file =
| Unit of string * Compilenv.unit_infos * Digest.t
| Library of string * Compilenv.library_infos
| Unit of string * unit_infos * Digest.t
| Library of string * library_infos
let read_file obj_name =
let file_name =
@ -156,12 +157,12 @@ let read_file obj_name =
if Filename.check_suffix file_name ".cmx" then begin
(* This is a .cmx file. It must be linked in any case.
Read the infos to see which modules it requires. *)
let (info, crc) = Compilenv.read_unit_info file_name in
let (info, crc) = read_unit_info file_name in
Unit (file_name,info,crc)
end
else if Filename.check_suffix file_name ".cmxa" then begin
let infos =
try Compilenv.read_library_info file_name
try read_library_info file_name
with Compilenv.Error(Not_a_unit_info _) ->
raise(Error(Not_an_object_file file_name))
in
@ -241,7 +242,7 @@ let make_shared_startup_file ppf units filename =
compile_phrase (Cmmgen.plugin_header units);
compile_phrase
(Cmmgen.global_table
(List.map (fun (ui,_) -> ui.Compilenv.ui_symbol) units));
(List.map (fun (ui,_) -> ui.ui_symbol) units));
(* this is to force a reference to all units, otherwise the linker
might drop some of them (in case of libraries) *)

View File

@ -22,7 +22,7 @@ val link_shared: formatter -> string list -> string -> unit
val call_linker_shared: string list -> string -> unit
val check_consistency: string -> Compilenv.unit_infos -> Digest.t -> unit
val check_consistency: string -> Cmx_format.unit_infos -> Digest.t -> unit
val extract_crc_interfaces: unit -> (string * Digest.t) list
val extract_crc_implementations: unit -> (string * Digest.t) list

View File

@ -19,7 +19,7 @@ open Printf
open Misc
open Lambda
open Clambda
open Compilenv
open Cmx_format
type error =
Illegal_renaming of string * string

View File

@ -22,6 +22,7 @@ open Types
open Lambda
open Clambda
open Cmm
open Cmx_format
(* Local binding of complex expressions *)
@ -1960,9 +1961,9 @@ let generic_functions shared units =
let (apply,send,curry) =
List.fold_left
(fun (apply,send,curry) ui ->
List.fold_right IntSet.add ui.Compilenv.ui_apply_fun apply,
List.fold_right IntSet.add ui.Compilenv.ui_send_fun send,
List.fold_right IntSet.add ui.Compilenv.ui_curry_fun curry)
List.fold_right IntSet.add ui.ui_apply_fun apply,
List.fold_right IntSet.add ui.ui_send_fun send,
List.fold_right IntSet.add ui.ui_curry_fun curry)
(IntSet.empty,IntSet.empty,IntSet.empty)
units in
let apply = if shared then apply else IntSet.union apply default_apply in
@ -2060,28 +2061,13 @@ let predef_exception name =
let mapflat f l = List.flatten (List.map f l)
type dynunit = {
name: string;
crc: Digest.t;
imports_cmi: (string * Digest.t) list;
imports_cmx: (string * Digest.t) list;
defines: string list;
}
type dynheader = {
magic: string;
units: dynunit list;
}
let dyn_magic_number = "Caml2007D001"
let plugin_header units =
let mk (ui,crc) =
{ name = ui.Compilenv.ui_name;
crc = crc;
imports_cmi = ui.Compilenv.ui_imports_cmi;
imports_cmx = ui.Compilenv.ui_imports_cmx;
defines = ui.Compilenv.ui_defines
{ dynu_name = ui.ui_name;
dynu_crc = crc;
dynu_imports_cmi = ui.ui_imports_cmi;
dynu_imports_cmx = ui.ui_imports_cmx;
dynu_defines = ui.ui_defines
} in
global_data "caml_plugin_header"
{ magic = dyn_magic_number; units = List.map mk units }
{ dynu_magic = Config.cmxs_magic_number; dynu_units = List.map mk units }

View File

@ -19,7 +19,7 @@ val compunit: int -> Clambda.ulambda -> Cmm.phrase list
val apply_function: int -> Cmm.phrase
val send_function: int -> Cmm.phrase
val curry_function: int -> Cmm.phrase list
val generic_functions: bool -> Compilenv.unit_infos list -> Cmm.phrase list
val generic_functions: bool -> Cmx_format.unit_infos list -> Cmm.phrase list
val entry_point: string list -> Cmm.phrase
val global_table: string list -> Cmm.phrase
val reference_symbols: string list -> Cmm.phrase
@ -29,4 +29,4 @@ val frame_table: string list -> Cmm.phrase
val data_segment_table: string list -> Cmm.phrase
val code_segment_table: string list -> Cmm.phrase
val predef_exception: string -> Cmm.phrase
val plugin_header: (Compilenv.unit_infos * Digest.t) list -> Cmm.phrase
val plugin_header: (Cmx_format.unit_infos * Digest.t) list -> Cmm.phrase

63
asmcomp/cmx_format.mli Normal file
View File

@ -0,0 +1,63 @@
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Gallium, INRIA Rocquencourt *)
(* *)
(* Copyright 2010 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id: compilenv.mli 9547 2010-01-22 12:48:24Z doligez $ *)
(* Format of .cmx, .cmxa and .cmxs files *)
(* Each .o file has a matching .cmx file that provides the following infos
on the compilation unit:
- list of other units imported, with CRCs of their .cmx files
- approximation of the structure implemented
(includes descriptions of known functions: arity and direct entry
points)
- list of currying functions and application functions needed
The .cmx file contains these infos (as an externed record) plus a CRC
of these infos *)
type unit_infos =
{ mutable ui_name: string; (* Name of unit implemented *)
mutable ui_symbol: string; (* Prefix for symbols *)
mutable ui_defines: string list; (* Unit and sub-units implemented *)
mutable ui_imports_cmi: (string * Digest.t) list; (* Interfaces imported *)
mutable ui_imports_cmx: (string * Digest.t) list; (* Infos imported *)
mutable ui_approx: Clambda.value_approximation; (* Approx of the structure *)
mutable ui_curry_fun: int list; (* Currying functions needed *)
mutable ui_apply_fun: int list; (* Apply functions needed *)
mutable ui_send_fun: int list; (* Send functions needed *)
mutable ui_force_link: bool } (* Always linked *)
(* Each .a library has a matching .cmxa file that provides the following
infos on the library: *)
type library_infos =
{ lib_units: (unit_infos * Digest.t) list; (* List of unit infos w/ CRCs *)
lib_ccobjs: string list; (* C object files needed *)
lib_ccopts: string list } (* Extra opts to C compiler *)
(* Each .cmxs dynamically-loaded plugin contains a symbol
"caml_plugin_header" containing the following info
(as an externed record) *)
type dynunit = {
dynu_name: string;
dynu_crc: Digest.t;
dynu_imports_cmi: (string * Digest.t) list;
dynu_imports_cmx: (string * Digest.t) list;
dynu_defines: string list;
}
type dynheader = {
dynu_magic: string;
dynu_units: dynunit list;
}

View File

@ -17,6 +17,7 @@
open Config
open Misc
open Clambda
open Cmx_format
type error =
Not_a_unit_info of string
@ -25,36 +26,6 @@ type error =
exception Error of error
(* Each .o file has a matching .cmx file that provides the following infos
on the compilation unit:
- list of other units imported, with CRCs of their .cmx files
- approximation of the structure implemented
(includes descriptions of known functions: arity and direct entry
points)
- list of currying functions and application functions needed
The .cmx file contains these infos (as an externed record) plus a CRC
of these infos *)
type unit_infos =
{ mutable ui_name: string; (* Name of unit implemented *)
mutable ui_symbol: string; (* Prefix for symbols *)
mutable ui_defines: string list; (* Unit and sub-units implemented *)
mutable ui_imports_cmi: (string * Digest.t) list; (* Interfaces imported *)
mutable ui_imports_cmx: (string * Digest.t) list; (* Infos imported *)
mutable ui_approx: value_approximation; (* Approx of the structure *)
mutable ui_curry_fun: int list; (* Currying functions needed *)
mutable ui_apply_fun: int list; (* Apply functions needed *)
mutable ui_send_fun: int list; (* Send functions needed *)
mutable ui_force_link: bool } (* Always linked *)
(* Each .a library has a matching .cmxa file that provides the following
infos on the library: *)
type library_infos =
{ lib_units: (unit_infos * Digest.t) list; (* List of unit infos w/ CRCs *)
lib_ccobjs: string list; (* C object files needed *)
lib_ccopts: string list } (* Extra opts to C compiler *)
let global_infos_table =
(Hashtbl.create 17 : (string, unit_infos option) Hashtbl.t)

View File

@ -15,36 +15,7 @@
(* Compilation environments for compilation units *)
open Clambda
(* Each .o file has a matching .cmx file that provides the following infos
on the compilation unit:
- list of other units imported, with CRCs of their .cmx files
- approximation of the structure implemented
(includes descriptions of known functions: arity and direct entry
points)
- list of currying functions and application functions needed
The .cmx file contains these infos (as an externed record) plus a CRC
of these infos *)
type unit_infos =
{ mutable ui_name: string; (* Name of unit implemented *)
mutable ui_symbol: string; (* Prefix for symbols *)
mutable ui_defines: string list; (* Unit and sub-units implemented *)
mutable ui_imports_cmi: (string * Digest.t) list; (* Interfaces imported *)
mutable ui_imports_cmx: (string * Digest.t) list; (* Infos imported *)
mutable ui_approx: value_approximation; (* Approx of the structure *)
mutable ui_curry_fun: int list; (* Currying functions needed *)
mutable ui_apply_fun: int list; (* Apply functions needed *)
mutable ui_send_fun: int list; (* Send functions needed *)
mutable ui_force_link: bool } (* Always linked *)
(* Each .a library has a matching .cmxa file that provides the following
infos on the library: *)
type library_infos =
{ lib_units: (unit_infos * Digest.t) list; (* List of unit infos w/ CRCs *)
lib_ccobjs: string list; (* C object files needed *)
lib_ccopts: string list } (* Extra opts to C compiler *)
open Cmx_format
val reset: ?packname:string -> string -> unit
(* Reset the environment and record the name of the unit being

11
configure vendored
View File

@ -1543,6 +1543,17 @@ else
echo "TK_LINK=" >> Makefile
fi
# Look for BFD library
if ./hasgot -i bfd.h -lbfd -ldl; then
echo "BFD library found."
echo "#define HAS_LIBBFD" >> s.h
echo "LIBBFD_LINK=-lbfd -ldl" >> Makefile
else
echo "BFD library not found, 'objinfo' will be unable to display info on .cmxs files"
echo "LIBBFD_LINK=" >> Makefile
fi
# Final twiddling of compiler options to work around known bugs
nativeccprofopts="$nativecccompopts"

View File

@ -19,7 +19,7 @@ include ../../config/Makefile
CAMLC=../../boot/ocamlrun ../../ocamlc
CAMLOPT=../../ocamlcompopt.sh
INCLUDES=-I ../../utils -I ../../typing -I ../../bytecomp
INCLUDES=-I ../../utils -I ../../typing -I ../../bytecomp -I ../../asmcomp
COMPFLAGS=-warn-error A -I ../../stdlib $(INCLUDES)
OBJS=dynlinkaux.cmo dynlink.cmo

View File

@ -40,22 +40,14 @@ type error =
exception Error of error
(* Copied from other places to avoid dependencies *)
open Cmx_format
type dynunit = {
name: string;
crc: Digest.t;
imports_cmi: (string * Digest.t) list;
imports_cmx: (string * Digest.t) list;
defines: string list;
}
(* Copied from config.ml to avoid dependencies *)
let cmxs_magic_number = "Caml2007D001"
type dynheader = {
magic: string;
units: dynunit list;
}
let dyn_magic_number = "Caml2007D001"
(* Copied from compilenv.ml to avoid dependencies *)
let cmx_not_found_crc =
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
let dll_filename fname =
if Filename.is_implicit fname then Filename.concat (Sys.getcwd ()) fname
@ -70,12 +62,10 @@ let read_file filename priv =
then raise (Error (Cannot_open_dll (Obj.magic res)));
let header : dynheader = Marshal.from_string data 0 in
if header.magic <> dyn_magic_number
if header.dynu_magic <> cmxs_magic_number
then raise(Error(Not_a_bytecode_file dll));
(dll, handle, header.units)
(dll, handle, header.dynu_units)
let cmx_not_found_crc =
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
(* Management of interface and implementation CRCs *)
@ -127,7 +117,7 @@ let init () =
let add_check_ifaces allow_ext filename ui ifaces =
List.fold_left
(fun ifaces (name, crc) ->
if name = ui.name
if name = ui.dynu_name
then StrMap.add name (crc,filename) ifaces
else
try
@ -138,7 +128,7 @@ let add_check_ifaces allow_ext filename ui ifaces =
with Not_found ->
if allow_ext then StrMap.add name (crc,filename) ifaces
else raise (Error(Unavailable_unit name))
) ifaces ui.imports_cmi
) ifaces ui.dynu_imports_cmi
let check_implems filename ui implems =
List.iter
@ -168,7 +158,7 @@ let check_implems filename ui implems =
| Loaded -> ()
with Not_found ->
raise (Error(Unavailable_unit name))
) ui.imports_cmx
) ui.dynu_imports_cmx
let loadunits filename handle units state =
let new_ifaces =
@ -179,10 +169,10 @@ let loadunits filename handle units state =
List.fold_left
(fun accu ui ->
check_implems filename ui accu;
StrMap.add ui.name (ui.crc,filename,Loaded) accu)
StrMap.add ui.dynu_name (ui.dynu_crc,filename,Loaded) accu)
state.implems units in
let defines = List.flatten (List.map (fun ui -> ui.defines) units) in
let defines = List.flatten (List.map (fun ui -> ui.dynu_defines) units) in
ndl_run handle "_shared_startup";
List.iter (ndl_run handle) defines;

View File

@ -23,8 +23,9 @@ INCLUDES=-I ../utils -I ../parsing -I ../typing -I ../bytecomp -I ../asmcomp \
COMPFLAGS= -warn-error A $(INCLUDES)
LINKFLAGS=$(INCLUDES)
all: ocamldep ocamlprof ocamlcp ocamlmktop ocamlmklib scrapelabels addlabels \
dumpobj
all: ocamldep ocamlprof ocamlcp ocamlmktop ocamlmklib dumpobj
# scrapelabels addlabels
.PHONY: all
opt.opt: ocamldep.opt
@ -154,8 +155,8 @@ scrapelabels: $(SCRAPELABELS)
lexer301.ml: lexer301.mll
$(CAMLLEX) lexer301.mll
install::
cp scrapelabels $(LIBDIR)
#install::
# cp scrapelabels $(LIBDIR)
clean::
rm -f scrapelabels lexer301.ml
@ -170,8 +171,8 @@ addlabels: addlabels.cmo
$(CAMLC) $(LINKFLAGS) -w sl -o addlabels \
$(ADDLABELS_IMPORTS) addlabels.cmo
install::
cp addlabels $(LIBDIR)
#install::
# cp addlabels $(LIBDIR)
clean::
rm -f addlabels
@ -225,21 +226,29 @@ clean::
beforedepend:: opnames.ml
# Dump .cmx files
# Display info on compiled files
dumpapprox: dumpapprox.cmo
$(CAMLC) $(LINKFLAGS) -o dumpapprox config.cmo dumpapprox.cmo
objinfo_lib.cma: ocamlmklib objinfo_lib.cmo objinfo_stubs$(EXT_OBJ)
../boot/ocamlrun ./ocamlmklib -ocamlc '$(CAMLC)' \
-o objinfo_lib objinfo_lib.cmo objinfo_stubs$(EXT_OBJ) $(LIBBFD_LINK)
clean::
rm -f dumpapprox
objinfo_stubs$(EXT_OBJ): objinfo_stubs.c
$(BYTECC) $(BYTECCCOMPOPTS) $(SHAREDCCCOMPOPTS) -c objinfo_stubs.c
# Print imported interfaces for .cmo files
OBJINFO=../utils/config.cmo ../bytecomp/bytesections.cmo \
objinfo_lib.cma objinfo.cmo
objinfo: objinfo.cmo
$(CAMLC) $(LINKFLAGS) -o objinfo config.cmo objinfo.cmo
objinfo: $(OBJINFO)
$(CAMLC) -o objinfo $(OBJINFO)
install::
cp objinfo $(BINDIR)/ocamlobjinfo$(EXE)
if test -f dllobjinfo_lib$(EXT_DLL); then \
cp dllobjinfo_lib$(EXT_DLL) $(STUBLIBDIR)/; fi
clean::
rm -f objinfo
rm -f objinfo_stubs$(EXT_OBJ) libobjinfo_lib$(EXT_LIB) dllobjinfo_lib$(EXT_DLL)
# Scan object files for required primitives
@ -266,7 +275,7 @@ clean::
$(CAMLOPT) $(COMPFLAGS) -c $<
clean::
rm -f *.cmo *.cmi
rm -f *.cmo *.cmi *.cma
depend: beforedepend
$(CAMLRUN) ./ocamldep $(INCLUDES) *.mli *.ml > .depend

View File

@ -1,97 +0,0 @@
(***********************************************************************)
(* *)
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id$ *)
(* Dump a .cmx file *)
open Config
open Format
open Clambda
open Compilenv
let print_digest ppf d =
for i = 0 to String.length d - 1 do
print_string(Printf.sprintf "%02x" (Char.code d.[i]))
done
let rec print_approx ppf = function
Value_closure(fundesc, approx) ->
printf "@[<2>function %s@ arity %i" fundesc.fun_label fundesc.fun_arity;
if fundesc.fun_closed then begin
printf "@ (closed)"
end;
if fundesc.fun_inline <> None then begin
printf "@ (inline)"
end;
printf "@ -> @ %a@]" print_approx approx
| Value_tuple approx ->
let tuple ppf approx =
for i = 0 to Array.length approx - 1 do
if i > 0 then printf ";@ ";
printf "%i: %a" i print_approx approx.(i)
done in
printf "@[<hov 1>(%a)@]" tuple approx
| Value_unknown ->
print_string "_"
| Value_integer n ->
print_int n
| Value_constptr n ->
print_int n; print_string "p"
let print_name_crc (name, crc) =
printf "@ %s (%a)" name print_digest crc
let print_infos (ui, crc) =
printf "Name: %s@." ui.ui_name;
printf "CRC of implementation: %a@." print_digest crc;
printf "@[<hov 2>Globals defined:";
List.iter (fun s -> printf "@ %s" s) ui.ui_defines;
printf "@]@.";
let pr_imports ppf imps = List.iter print_name_crc imps in
printf "@[<v 2>Interfaces imported:%a@]@." pr_imports ui.ui_imports_cmi;
printf "@[<v 2>Implementations imported:%a@]@." pr_imports ui.ui_imports_cmx;
printf "@[<v 2>Approximation:@ %a@]@." print_approx ui.ui_approx;
let pr_funs ppf fns =
List.iter (fun arity -> printf "@ %i" arity) fns in
printf "@[<2>Currying functions:%a@]@." pr_funs ui.ui_curry_fun;
printf "@[<2>Apply functions:%a@]@." pr_funs ui.ui_apply_fun
let print_unit_info filename =
let ic = open_in_bin filename in
try
let buffer = String.create (String.length cmx_magic_number) in
really_input ic buffer 0 (String.length cmx_magic_number);
if buffer = cmx_magic_number then begin
let ui = (input_value ic : unit_infos) in
let crc = Digest.input ic in
close_in ic;
print_infos (ui, crc)
end else if buffer = cmxa_magic_number then begin
let li = (input_value ic : library_infos) in
close_in ic;
List.iter print_infos li.lib_units
end else begin
close_in ic;
prerr_endline "Wrong magic number";
exit 2
end
with End_of_file | Failure _ ->
close_in ic;
prerr_endline "Error reading file";
exit 2
let main () =
print_unit_info Sys.argv.(1);
exit 0
let _ = main ()

View File

@ -3,92 +3,241 @@
(* Objective Caml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* Mehdi Dogguy, PPS laboratory, University Paris Diderot *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* en Automatique. Modifications Copyright 2010 Mehdi Dogguy, *)
(* used and distributed as part of Objective Caml by permission from *)
(* the author. This file is distributed under the terms of the *)
(* Q Public License version 1.0. *)
(* *)
(***********************************************************************)
(* $Id$ *)
(* Dump a compilation unit description *)
(* Dump info on .cmi, .cmo, .cmx, .cma, .cmxa, .cmxs files
and on bytecode executables. *)
open Printf
open Config
open Cmo_format
open Clambda
let print_digest d =
for i = 0 to String.length d - 1 do
Printf.printf "%02x" (Char.code d.[i])
done
let input_stringlist ic len =
let get_string_list sect len =
let rec fold s e acc =
if e != len then
if sect.[e] = '\000' then
fold (e+1) (e+1) (String.sub sect s (e-s) :: acc)
else fold s (e+1) acc
else acc
in fold 0 0 []
in
let sect = String.create len in
let _ = really_input ic sect 0 len in
get_string_list sect len
let print_info cu =
print_string " Unit name: "; print_string cu.cu_name; print_newline();
print_string " Interfaces imported:"; print_newline();
List.iter
(fun (name, digest) ->
print_string "\t"; print_digest digest; print_string "\t";
print_string name; print_newline())
cu.cu_imports;
print_string " Uses unsafe features: ";
begin match cu.cu_primitives with
[] -> print_string "no"; print_newline()
| l -> print_string "YES"; print_newline();
print_string " Primitives declared in this module:";
print_newline();
List.iter
(fun name -> print_string "\t"; print_string name; print_newline())
l
end
let print_name_crc (name, crc) =
printf "\t%s\t%s\n" (Digest.to_hex crc) name
let print_spaced_string s = print_char ' '; print_string s
let print_line name =
printf "\t%s\n" name
let print_library_info lib =
print_string " Force custom: ";
print_string (if lib.lib_custom then "YES" else "no");
print_newline();
print_string " Extra C object files:";
let print_cmo_infos cu =
printf "Unit name: %s\n" cu.cu_name;
print_string "Interfaces imported:\n";
List.iter print_name_crc cu.cu_imports;
printf "Uses unsafe features: ";
match cu.cu_primitives with
| [] -> printf "no\n"
| l ->
printf "YES\n";
printf "Primitives declared in this module:\n";
List.iter print_line l
let rec print_approx_infos ppf = function
Value_closure(fundesc, approx) ->
Format.fprintf ppf "@[<2>function %s@ arity %i"
fundesc.fun_label fundesc.fun_arity;
if fundesc.fun_closed then begin
Format.fprintf ppf "@ (closed)"
end;
if fundesc.fun_inline <> None then begin
Format.fprintf ppf "@ (inline)"
end;
Format.fprintf ppf "@ -> @ %a@]" print_approx_infos approx
| Value_tuple approx ->
let tuple ppf approx =
for i = 0 to Array.length approx - 1 do
if i > 0 then Format.fprintf ppf ";@ ";
Format.fprintf ppf "%i: %a" i print_approx_infos approx.(i)
done in
Format.fprintf ppf "@[<hov 1>(%a)@]" tuple approx
| Value_unknown ->
Format.fprintf ppf "_"
| Value_integer n ->
Format.fprintf ppf "%d" n
| Value_constptr n ->
Format.fprintf ppf "%dp" n
let print_spaced_string s =
printf " %s" s
let print_cma_infos (lib : Cmo_format.library) =
printf "Force custom: %s\n" (if lib.lib_custom then "YES" else "no");
printf "Extra C object files:";
(* PR#4949: print in linking order *)
List.iter print_spaced_string (List.rev lib.lib_ccobjs); print_newline();
print_string " Extra C options:";
List.iter print_spaced_string lib.lib_ccopts; print_newline();
List.iter print_info lib.lib_units
List.iter print_spaced_string (List.rev lib.lib_ccobjs);
printf "\nExtra C options:";
List.iter print_spaced_string lib.lib_ccopts;
printf "\n";
print_string "Extra dynamically-loaded libraries:";
List.iter print_spaced_string lib.lib_dllibs;
printf "\n";
List.iter print_cmo_infos lib.lib_units
let print_intf_info name sign comps crcs =
print_string " Module name: "; print_string name; print_newline();
print_string " Interfaces imported:"; print_newline();
let print_cmi_infos name sign comps crcs =
printf "Unit name: %s\n" name;
printf "Interfaces imported:\n";
List.iter print_name_crc crcs
let print_general_infos name crc defines cmi cmx =
printf "Name: %s\n" name;
printf "CRC of implementation: %s\n" (Digest.to_hex crc);
printf "Globals defined:\n";
List.iter print_line defines;
printf "Interfaces imported:\n";
List.iter print_name_crc cmi;
printf "Implementations imported:\n";
List.iter print_name_crc cmx
open Cmx_format
let print_cmx_infos (ui, crc) =
print_general_infos
ui.ui_name crc ui.ui_defines ui.ui_imports_cmi ui.ui_imports_cmx;
printf "Approximation:\n";
Format.fprintf Format.std_formatter " %a@." print_approx_infos ui.ui_approx;
let pr_funs _ fns =
List.iter (fun arity -> printf " %d" arity) fns in
printf "Currying functions:%a\n" pr_funs ui.ui_curry_fun;
printf "Apply functions:%a\n" pr_funs ui.ui_apply_fun
let print_cmxs_infos header =
List.iter
(fun (name, digest) ->
print_string "\t"; print_digest digest; print_string "\t";
print_string name; print_newline())
crcs
(fun ui ->
print_general_infos
ui.dynu_name
ui.dynu_crc
ui.dynu_defines
ui.dynu_imports_cmi
ui.dynu_imports_cmx)
header.dynu_units
let p_title title = printf "%s:\n" title
let p_section title = function
| [] -> ()
| l ->
p_title title;
List.iter print_name_crc l
let p_list title print = function
| [] -> ()
| l ->
p_title title;
List.iter print l
let dump_byte ic =
Bytesections.read_toc ic;
let toc = Bytesections.toc () in
let toc = List.sort Pervasives.compare toc in
List.iter
(fun (section, _) ->
try
let len = Bytesections.seek_section ic section in
if len > 0 then match section with
| "CRCS" ->
p_section
"Imported units"
(input_value ic : (string * Digest.t) list)
| "DLLS" ->
p_list
"Used DLLs"
print_line
(input_stringlist ic len)
| "DLPT" ->
p_list
"Additional DLL paths"
print_line
(input_stringlist ic len)
| "PRIM" ->
p_list
"Primitives used"
print_line
(input_stringlist ic len)
| _ -> ()
with _ -> ()
)
toc
let dump_obj filename =
print_string "File "; print_string filename; print_newline();
printf "File %s\n" filename;
let ic = open_in_bin filename in
let buffer = String.create (String.length cmo_magic_number) in
really_input ic buffer 0 (String.length cmo_magic_number);
if buffer = cmo_magic_number then begin
let len_magic_number = String.length cmo_magic_number in
let magic_number = String.create len_magic_number in
really_input ic magic_number 0 len_magic_number;
if magic_number = cmo_magic_number then begin
let cu_pos = input_binary_int ic in
seek_in ic cu_pos;
let cu = (input_value ic : compilation_unit) in
close_in ic;
print_info cu
end else
if buffer = cma_magic_number then begin
print_cmo_infos cu
end else if magic_number = cma_magic_number then begin
let toc_pos = input_binary_int ic in
seek_in ic toc_pos;
let toc = (input_value ic : library) in
close_in ic;
print_library_info toc
end else
if buffer = cmi_magic_number then begin
print_cma_infos toc
end else if magic_number = cmi_magic_number then begin
let (name, sign, comps) = input_value ic in
let crcs = input_value ic in
close_in ic;
print_intf_info name sign comps crcs
print_cmi_infos name sign comps crcs
end else if magic_number = cmx_magic_number then begin
let ui = (input_value ic : unit_infos) in
let crc = Digest.input ic in
close_in ic;
print_cmx_infos (ui, crc)
end else if magic_number = cmxa_magic_number then begin
let li = (input_value ic : library_infos) in
close_in ic;
List.iter print_cmx_infos li.lib_units
end else begin
prerr_endline "Not an object file"; exit 2
let pos_trailer = in_channel_length ic - len_magic_number in
let _ = seek_in ic pos_trailer in
let _ = really_input ic magic_number 0 len_magic_number in
if magic_number = Config.exec_magic_number then begin
dump_byte ic;
close_in ic
end else if Filename.check_suffix filename ".cmxs" then begin
let offset = Objinfo_lib.get_cmxs_info filename in
begin match offset with
| -2L -> printf "Cannot display info on .cmxs files\n"
| -1L -> printf "Failed to read table of contents\n"; exit 2
| _ ->
let _ = LargeFile.seek_in ic offset in
let header = (input_value ic : dynheader) in
if header.dynu_magic = Config.cmxs_magic_number then
print_cmxs_infos header
else begin
printf "Wrong magic number\n"; exit 2
end
end;
close_in ic
end else begin
printf "Not an OCaml object file\n"; exit 2
end
end
let main() =

View File

@ -68,6 +68,7 @@ and cmx_magic_number = "Caml1999Y011"
and cmxa_magic_number = "Caml1999Z010"
and ast_impl_magic_number = "Caml1999M013"
and ast_intf_magic_number = "Caml1999N012"
and cmxs_magic_number = "Caml2007D001"
let load_path = ref ([] : string list)

View File

@ -72,6 +72,8 @@ val ast_intf_magic_number: string
(* Magic number for file holding an interface syntax tree *)
val ast_impl_magic_number: string
(* Magic number for file holding an implementation syntax tree *)
val cmxs_magic_number: string
(* Magic number for dynamically-loadable plugins *)
val max_tag: int
(* Biggest tag that can be stored in the header of a regular block. *)

View File

@ -57,6 +57,7 @@ and cmx_magic_number = "Caml1999Y011"
and cmxa_magic_number = "Caml1999Z010"
and ast_impl_magic_number = "Caml1999M013"
and ast_intf_magic_number = "Caml1999N012"
and cmxs_magic_number = "Caml2007D001"
let load_path = ref ([] : string list)