1 (**************************************************************************)
2 (* *)
3 (* OCaml *)
4 (* *)
5 (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
6 (* *)
7 (* Copyright 2006 Institut National de Recherche en Informatique et *)
8 (* en Automatique. *)
9 (* *)
10 (* All rights reserved. This file is distributed under the terms of *)
11 (* the GNU Lesser General Public License version 2.1, with the *)
12 (* special exception on linking described in the file LICENSE. *)
13 (* *)
14 (**************************************************************************)
15
16 (* Symbol table information for .cmo and .cma files *)
17
18 open Misc
19
20 (* Relocation information *)
21
22 type reloc_info =
23 Reloc_literal of Lambda.structured_constant (* structured constant *)
24 | Reloc_getglobal of Ident.t (* reference to a global *)
25 | Reloc_setglobal of Ident.t (* definition of a global *)
26 | Reloc_primitive of string (* C primitive number *)
27
28 (* Descriptor for compilation units *)
29
30 type compilation_unit =
31 { cu_name: modname; (* Name of compilation unit *)
32 mutable cu_pos: int; (* Absolute position in file *)
33 cu_codesize: int; (* Size of code block *)
34 cu_reloc: (reloc_info * int) list; (* Relocation information *)
35 cu_imports: crcs; (* Names and CRC of intfs imported *)
36 cu_required_globals: Ident.t list; (* Compilation units whose
37 initialization side effects
38 must occur before this one. *)
39 cu_primitives: string list; (* Primitives declared inside *)
40 mutable cu_force_link: bool; (* Must be linked even if unref'ed *)
41 mutable cu_debug: int; (* Position of debugging info, or 0 *)
42 cu_debugsize: int } (* Length of debugging info *)
43
44 (* Format of a .cmo file:
45 magic number (Config.cmo_magic_number)
46 absolute offset of compilation unit descriptor
47 block of relocatable bytecode
48 debugging information if any
49 compilation unit descriptor *)
50
51 (* Descriptor for libraries *)
52
53 type library =
54 { lib_units: compilation_unit list; (* List of compilation units *)
55 lib_custom: bool; (* Requires custom mode linking? *)
56 lib_ccobjs: string list; (* C object files needed for -custom *)
57 lib_ccopts: string list; (* Extra opts to C compiler *)
58 lib_dllibs: string list } (* DLLs needed *)
59
60 (* Format of a .cma file:
61 magic number (Config.cma_magic_number)
62 absolute offset of library descriptor
63 object code for first library member
64 ...
65 object code for last library member
66 library descriptor *)
67