1 |
706 |
jeremybenn |
------------------------------------------------------------------------------
|
2 |
|
|
-- --
|
3 |
|
|
-- GNAT COMPILER COMPONENTS --
|
4 |
|
|
-- --
|
5 |
|
|
-- S Y M B O L S --
|
6 |
|
|
-- --
|
7 |
|
|
-- S p e c --
|
8 |
|
|
-- --
|
9 |
|
|
-- Copyright (C) 2003-2007, Free Software Foundation, Inc. --
|
10 |
|
|
-- --
|
11 |
|
|
-- GNAT is free software; you can redistribute it and/or modify it under --
|
12 |
|
|
-- terms of the GNU General Public License as published by the Free Soft- --
|
13 |
|
|
-- ware Foundation; either version 3, or (at your option) any later ver- --
|
14 |
|
|
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
|
15 |
|
|
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
|
16 |
|
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
|
17 |
|
|
-- for more details. You should have received a copy of the GNU General --
|
18 |
|
|
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
|
19 |
|
|
-- http://www.gnu.org/licenses for a complete copy of the license. --
|
20 |
|
|
-- --
|
21 |
|
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
22 |
|
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
23 |
|
|
-- --
|
24 |
|
|
------------------------------------------------------------------------------
|
25 |
|
|
|
26 |
|
|
-- This package allows the creation of symbol files to be used for linking
|
27 |
|
|
-- libraries. The format of symbol files depends on the platform, so there is
|
28 |
|
|
-- several implementations of the body.
|
29 |
|
|
|
30 |
|
|
with GNAT.Dynamic_Tables;
|
31 |
|
|
|
32 |
|
|
with System.OS_Lib; use System.OS_Lib;
|
33 |
|
|
|
34 |
|
|
package Symbols is
|
35 |
|
|
|
36 |
|
|
type Policy is
|
37 |
|
|
-- Symbol policy
|
38 |
|
|
|
39 |
|
|
(Autonomous,
|
40 |
|
|
-- Create a symbol file without considering any reference
|
41 |
|
|
|
42 |
|
|
Compliant,
|
43 |
|
|
-- Either create a symbol file with the same major and minor IDs if
|
44 |
|
|
-- all symbols are already found in the reference file or with an
|
45 |
|
|
-- incremented minor ID, if not.
|
46 |
|
|
|
47 |
|
|
Controlled,
|
48 |
|
|
-- Fail if symbols are not the same as those in the reference file
|
49 |
|
|
|
50 |
|
|
Restricted,
|
51 |
|
|
-- Restrict the symbols to those in the symbol file. Fail if some
|
52 |
|
|
-- symbols in the symbol file are not exported from the object files.
|
53 |
|
|
|
54 |
|
|
Direct);
|
55 |
|
|
-- The reference symbol file is copied to the symbol file
|
56 |
|
|
|
57 |
|
|
type Symbol_Kind is (Data, Proc);
|
58 |
|
|
-- To distinguish between the different kinds of symbols
|
59 |
|
|
|
60 |
|
|
type Symbol_Data is record
|
61 |
|
|
Name : String_Access;
|
62 |
|
|
Kind : Symbol_Kind := Data;
|
63 |
|
|
Present : Boolean := True;
|
64 |
|
|
end record;
|
65 |
|
|
-- Data (name and kind) for each of the symbols
|
66 |
|
|
|
67 |
|
|
package Symbol_Table is new GNAT.Dynamic_Tables
|
68 |
|
|
(Table_Component_Type => Symbol_Data,
|
69 |
|
|
Table_Index_Type => Natural,
|
70 |
|
|
Table_Low_Bound => 0,
|
71 |
|
|
Table_Initial => 100,
|
72 |
|
|
Table_Increment => 100);
|
73 |
|
|
-- The symbol tables
|
74 |
|
|
|
75 |
|
|
Original_Symbols : Symbol_Table.Instance;
|
76 |
|
|
-- The symbols, if any, found in the reference symbol table
|
77 |
|
|
|
78 |
|
|
Complete_Symbols : Symbol_Table.Instance;
|
79 |
|
|
-- The symbols, if any, found in the objects files
|
80 |
|
|
|
81 |
|
|
procedure Initialize
|
82 |
|
|
(Symbol_File : String;
|
83 |
|
|
Reference : String;
|
84 |
|
|
Symbol_Policy : Policy;
|
85 |
|
|
Quiet : Boolean;
|
86 |
|
|
Version : String;
|
87 |
|
|
Success : out Boolean);
|
88 |
|
|
-- Initialize a symbol file. This procedure must be called before
|
89 |
|
|
-- Processing any object file. Depending on the platforms and the
|
90 |
|
|
-- circumstances, additional messages may be issued if Quiet is False.
|
91 |
|
|
|
92 |
|
|
package Processing is
|
93 |
|
|
|
94 |
|
|
-- This package, containing a single visible procedure Process, exists so
|
95 |
|
|
-- that it can be a subunits, for some platforms (such as VMS Alpha and
|
96 |
|
|
-- IA64), the body of package Symbols is common, while the subunit
|
97 |
|
|
-- Processing is not.
|
98 |
|
|
|
99 |
|
|
procedure Process
|
100 |
|
|
(Object_File : String;
|
101 |
|
|
Success : out Boolean);
|
102 |
|
|
-- Get the symbols from an object file. Success is set to True if the
|
103 |
|
|
-- object file exists and has the expected format.
|
104 |
|
|
|
105 |
|
|
end Processing;
|
106 |
|
|
|
107 |
|
|
procedure Finalize
|
108 |
|
|
(Quiet : Boolean;
|
109 |
|
|
Success : out Boolean);
|
110 |
|
|
-- Finalize the symbol file. This procedure should be called after
|
111 |
|
|
-- Initialize (once) and Process (one or more times). If Success is
|
112 |
|
|
-- True, the symbol file is written and closed, ready to be used for
|
113 |
|
|
-- linking the library. Depending on the platforms and the circumstances,
|
114 |
|
|
-- additional messages may be issued if Quiet is False.
|
115 |
|
|
|
116 |
|
|
end Symbols;
|