2014-10-10 Robert Dewar <dewar@adacore.com>
[official-gcc.git] / gcc / ada / lib-writ.ads
blob91c16c0f081fdab1d1ff8ae027c533a4b19630ee
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- L I B . W R I T --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2014, 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 ------------------------------------------------------------------------------
26 -- This package contains the routines for writing the library information
28 package Lib.Writ is
30 -----------------------------------
31 -- Format of Library Information --
32 -----------------------------------
34 -- This section describes the format of the library information that is
35 -- associated with object files. The exact method of this association is
36 -- potentially implementation dependent and is described and implemented in
37 -- package ali. From the point of view of the description here, all we need
38 -- to know is that the information is represented as a string of characters
39 -- that is somehow associated with an object file, and can be retrieved. If
40 -- no library information exists for a given object file, then we take this
41 -- as equivalent to the non-existence of the object file, as if source file
42 -- has not been previously compiled.
44 -- The library information is written as a series of lines of the form:
46 -- Key_Character parameter parameter ...
48 -- The following sections describe the format of these lines in detail
50 --------------------------------------
51 -- Making Changes to the ALI Format --
52 --------------------------------------
54 -- A number of tools use ali.adb to parse ali files. This means that
55 -- changes to this format can cause old versions of these tools to be
56 -- incompatible with new versions of the compiler. Any changes to ali file
57 -- formats must be carefully evaluated to understand any such possible
58 -- conflicts, and in particular, it is very undesirable to create conflicts
59 -- between older versions of GPS and newer versions of the compiler.
61 -- If the following guidelines are respected, downward compatibility
62 -- problems (old tools reading new ali files) should be minimized:
64 -- The basic key character format must be kept
66 -- The V line must be the first line, this is checked by ali.adb even in
67 -- Ignore_Errors mode, and is used to verify that the file at hand is
68 -- indeed likely intended to be an ali file.
70 -- The P line must be present, though may be modified in contents
71 -- according to remaining guidelines. Again, ali.adb assumes the P
72 -- line is present even in Ignore_Errors mode.
74 -- New modifiers can generally be added (in particular adding new two
75 -- letter modifiers to the P or U lines is always safe)
77 -- Adding entirely new lines (with a new key letter) to the ali file is
78 -- always safe, at any point (other than before the V line), since such
79 -- lines will be ignored.
81 -- Following the guidelines in this section should ensure that this problem
82 -- is minimized and that old tools will be able to deal successfully with
83 -- new ali formats. Note that this does not apply to the compiler itself,
84 -- which always requires consistency between the ali files and the binder.
85 -- That is because one of the main functions of the binder is to ensure
86 -- consistency of the partition, and this can be compromised if the ali
87 -- files are inconsistent.
89 ------------------
90 -- Header Lines --
91 ------------------
93 -- The initial header lines in the file give information about the
94 -- compilation environment, and identify other special information such as
95 -- main program parameters.
97 -- ----------------
98 -- -- V Version --
99 -- ----------------
101 -- V "xxxxxxxxxxxxxxxx"
103 -- This line indicates the library output version, as defined in
104 -- Gnatvsn. It ensures that separate object modules of a program are
105 -- consistent. It has to be changed if anything changes which would
106 -- affect successful binding of separately compiled modules. Examples
107 -- of such changes are modifications in the format of the library info
108 -- described in this package, or modifications to calling sequences, or
109 -- to the way that data is represented.
111 -- Note: the V line absolutely must be the first line, and no change
112 -- to the ALI format should change this, since even in Ignore_Errors
113 -- mode, Scan_ALI insists on finding a V line.
115 -- ---------------------
116 -- -- M Main Program --
117 -- ---------------------
119 -- M type [priority] [T=time-slice] [C=cpu] W=?
121 -- This line appears only if the main unit for this file is suitable
122 -- for use as a main program. The parameters are:
124 -- type
126 -- P for a parameterless procedure
127 -- F for a function returning a value of integral type
128 -- (used for writing a main program returning an exit status)
130 -- priority
132 -- Present only if there was a valid pragma Priority in the
133 -- corresponding unit to set the main task priority. It is an
134 -- unsigned decimal integer.
136 -- T=time-slice
138 -- Present only if there was a valid pragma Time_Slice in the
139 -- corresponding unit. It is an unsigned decimal integer in the
140 -- range 0 .. 10**9 giving the time slice value in units of
141 -- milliseconds. The actual significance of this parameter is
142 -- target dependent.
144 -- C=cpu
146 -- Present only if there was a valid pragma CPU in the
147 -- corresponding unit to set the main task affinity. It is an
148 -- unsigned decimal integer.
150 -- W=?
152 -- This parameter indicates the wide character encoding method used
153 -- when compiling the main program file. The ? character is the
154 -- single character used in the -gnatW? switch. This is used to
155 -- provide the default wide-character encoding for Wide_Text_IO
156 -- files.
158 -- -----------------
159 -- -- A Argument --
160 -- -----------------
162 -- A argument
164 -- One of these lines appears for each of the arguments present in the
165 -- call to the gnat1 program. This can be used if it is necessary to
166 -- reconstruct this call (e.g. for fix and continue).
168 -- -------------------
169 -- -- P Parameters --
170 -- -------------------
172 -- P <<parameters>>
174 -- Indicates various information that applies to the compilation of the
175 -- corresponding source file. Parameters is a sequence of zero or more
176 -- two letter codes that indicate configuration pragmas and other
177 -- parameters that apply:
179 -- The arguments are as follows:
181 -- CE Compilation errors. If this is present it means that the ali
182 -- file resulted from a compilation with the -gnatQ switch set,
183 -- and illegalities were detected. The ali file contents may
184 -- not be completely reliable, but the format will be correct
185 -- and complete. Note that NO is always present if CE is
186 -- present.
188 -- DB Detect_Blocking pragma is in effect for all units in this
189 -- file.
191 -- Ex A valid Partition_Elaboration_Policy pragma applies to all
192 -- the units in this file, where x is the first character
193 -- (upper case) of the policy name (e.g. 'C' for Concurrent).
195 -- GP Set if this compilation was done in GNATprove mode, either
196 -- from direct use of GNATprove, or from use of -gnatdF.
198 -- Lx A valid Locking_Policy pragma applies to all the units in
199 -- this file, where x is the first character (upper case) of
200 -- the policy name (e.g. 'C' for Ceiling_Locking).
202 -- NO No object. This flag indicates that the units in this file
203 -- were not compiled to produce an object. This can occur as a
204 -- result of the use of -gnatc, or if no object can be produced
205 -- (e.g. when a package spec is compiled instead of the body,
206 -- or a subunit on its own). Note that in GNATprove mode, we
207 -- do produce an object. The object is not suitable for binding
208 -- and linking, but we do not set NO, instead we set GP.
210 -- NR No_Run_Time. Indicates that a pragma No_Run_Time applies
211 -- to all units in the file.
213 -- NS Normalize_Scalars pragma in effect for all units in
214 -- this file.
216 -- OH Pragma Default_Scalar_Storage_Order (High_Order_First) is
217 -- present in a configuration pragma file that applies.
219 -- OL Pragma Default_Scalar_Storage_Order (Low_Order_First) is
220 -- present in a configuration pragma file that applies.
222 -- Qx A valid Queueing_Policy pragma applies to all the units
223 -- in this file, where x is the first character (upper case)
224 -- of the policy name (e.g. 'P' for Priority_Queueing).
226 -- SL Indicates that the unit is an Interface to a Standalone
227 -- Library. Note that this indication is never given by the
228 -- compiler, but is added by the Project Manager in gnatmake
229 -- when an Interface ALI file is copied to the library
230 -- directory.
232 -- SS This unit references System.Secondary_Stack (that is,
233 -- the unit makes use of the secondary stack facilities).
235 -- Tx A valid Task_Dispatching_Policy pragma applies to all
236 -- the units in this file, where x is the first character
237 -- (upper case) of the corresponding policy name (e.g. 'F'
238 -- for FIFO_Within_Priorities).
240 -- UA Unreserve_All_Interrupts pragma was processed in one or
241 -- more units in this file
243 -- ZX Units in this file use zero-cost exceptions and have
244 -- generated exception tables. If ZX is not present, the
245 -- longjmp/setjmp exception scheme is in use.
247 -- Note that language defined units never output policy (Lx, Tx, Qx)
248 -- parameters. Language defined units must correctly handle all
249 -- possible cases. These values are checked for consistency by the
250 -- binder and then copied to the generated binder output file.
252 -- Note: The P line must be present. Even in Ignore_Errors mode, Scan_ALI
253 -- insists on finding a P line. So if changes are made to the ALI format,
254 -- they should not include removing the P line.
256 -- ---------------------
257 -- -- R Restrictions --
258 -- ---------------------
260 -- There are two forms for R lines, positional and named. The positional
261 -- notation is now considered obsolescent, it is not generated by the most
262 -- recent versions of the compiler except under control of the debug switch
263 -- -gnatdR, but is still recognized by the binder.
265 -- The recognition by the binder is to ease the transition, and better deal
266 -- with some cases of inconsistent builds using incompatible versions of
267 -- the compiler and binder. The named notation is the current preferred
268 -- approach.
270 -- Note that R lines are generated using the information in unit Rident,
271 -- and intepreted by the binder using the information in System.Rident.
272 -- Normally these two units should be effectively identical. However in
273 -- some cases of inconsistent builds, they may be different. This may lead
274 -- to binder diagnostics, which can be suppressed using the -C switch for
275 -- the binder, which results in ignoring unrecognized restrictions in the
276 -- ali files.
278 -- ---------------------------------------
279 -- -- R Restrictions (Positional Form) --
280 -- ---------------------------------------
282 -- The first R line records the status of restrictions generated by pragma
283 -- Restrictions encountered, as well as information on what the compiler
284 -- has been able to determine with respect to restrictions violations.
285 -- The format is:
287 -- R <<restriction-characters>> <<restriction-param-id-entries>>
289 -- The first parameter is a string of characters that records
290 -- information regarding restrictions that do not take parameter not
291 -- take parameter values. It is a string of characters, one character
292 -- for each value (in order) in All_Boolean_Restrictions. There are
293 -- three possible settings for each restriction:
295 -- r Restricted. Unit was compiled under control of a pragma
296 -- Restrictions for the corresponding restriction. In this case
297 -- the unit certainly does not violate the Restriction, since
298 -- this would have been detected by the compiler.
300 -- n Not used. The unit was not compiled under control of a pragma
301 -- Restrictions for the corresponding restriction, and does not
302 -- make any use of the referenced feature.
304 -- v Violated. The unit was not compiled under control of a pragma
305 -- Restrictions for the corresponding restriction, and it does
306 -- indeed use the referenced feature.
308 -- This information is used in the binder to check consistency, i.e. to
309 -- detect cases where one unit has "r" and another unit has "v", which
310 -- is not permitted, since these restrictions are partition-wide.
312 -- The second parameter, which immediately follows the first (with no
313 -- separating space) gives restriction information for identifiers for
314 -- which a parameter is given.
316 -- The parameter is a string of entries, one for each value in
317 -- Restrict.All_Parameter_Restrictions. Each entry has two components
318 -- in sequence, the first indicating whether or not there is a
319 -- restriction, and the second indicating whether or not the compiler
320 -- detected violations. In the boolean case it is not necessary to
321 -- separate these, since if a restriction is set, and violated, that is
322 -- an error. But in the parameter case, this is not true. For example,
323 -- we can have a unit with a pragma Restrictions (Max_Tasks => 4),
324 -- where the compiler can detect that there are exactly three tasks
325 -- declared. Both of these pieces of information must be passed to the
326 -- binder. The parameter of 4 is important in case the total number of
327 -- tasks in the partition is greater than 4. The parameter of 3 is
328 -- important in case some other unit has a restrictions pragma with
329 -- Max_Tasks=>2.
331 -- The component for the presence of restriction has one of two
332 -- possible forms:
334 -- n No pragma for this restriction is present in the set of units
335 -- for this ali file.
337 -- rN At least one pragma for this restriction is present in the
338 -- set of units for this ali file. The value N is the minimum
339 -- parameter value encountered in any such pragma. N is in the
340 -- range of Integer (a value larger than N'Last causes the
341 -- pragma to be ignored).
343 -- The component for the violation detection has one of three
344 -- possible forms:
346 -- n No violations were detected by the compiler
348 -- vN A violation was detected. N is either the maximum or total
349 -- count of violations (depending on the checking type) in all
350 -- the units represented by the ali file). Note that this
351 -- setting is only allowed for restrictions that are in
352 -- Checked_[Max|Sum]_Parameter_Restrictions. The value here is
353 -- known to be exact by the compiler and is in the range of
354 -- Natural.
356 -- vN+ A violation was detected. The compiler cannot determine
357 -- the exact count of violations, but it is at least N.
359 -- There are no spaces within the parameter string, so the entry
360 -- described above in the header of this section for Max_Tasks would
361 -- appear as the string r4v3.
363 -- Note: The restrictions line is required to be present. Even in
364 -- Ignore_Errors mode, Scan_ALI expects to find an R line and will
365 -- signal a fatal error if it is missing. This means that future
366 -- changes to the ALI file format must retain the R line.
368 -- ----------------------------------
369 -- -- R Restrictions (Named Form) --
370 -- ----------------------------------
372 -- The first R line for named form announces that named notation will be
373 -- used, and also assures that there is at least one R line present, which
374 -- makes parsing of ali files simpler. A blank line preceds the RN line.
376 -- RN
378 -- In named notation, the restrictions are given as a series of lines, one
379 -- per retrictions that is specified or violated (no information is present
380 -- for restrictions that are not specified or violated). In the following
381 -- name is the name of the restriction in all upper case.
383 -- For boolean restrictions, we have only two possibilities. A restrictions
384 -- pragma is present, or a violation is detected:
386 -- RR name
388 -- A restriction pragma is present for the named boolean restriction.
389 -- No violations were detected by the compiler (or the unit in question
390 -- would have been found to be illegal).
392 -- RV name
394 -- No restriction pragma is present for the named boolean restriction.
395 -- However, the compiler did detect one or more violations of this
396 -- restriction, which may require a binder consistency check. Note that
397 -- one case of a violation is the use of a Restriction_Set attribute for
398 -- the restriction that yielded False.
400 -- For the case of restrictions that take a parameter, we need both the
401 -- information from pragma if present, and the actual information about
402 -- what possible violations occur. For example, we can have a unit with
403 -- a pragma Restrictions (Max_Tasks => 4), where the compiler can detect
404 -- that there are exactly three tasks declared. Both of these pieces
405 -- of information must be passed to the binder. The parameter of 4 is
406 -- important in case the total number of tasks in the partition is greater
407 -- than 4. The parameter of 3 is important in case some other unit has a
408 -- restrictions pragma with Max_Tasks=>2.
410 -- RR name=N
412 -- A restriction pragma is present for the named restriction which is
413 -- one of the restrictions taking a parameter. The value N (a decimal
414 -- integer) is the value given in the restriction pragma.
416 -- RV name=N
418 -- A restriction pragma may or may not be present for the restriction
419 -- given by name (one of the restrictions taking a parameter). But in
420 -- either case, the compiler detected possible violations. N (a decimal
421 -- integer) is the maximum or total count of violations (depending
422 -- on the checking type) in all the units represented by the ali file).
423 -- The value here is known to be exact by the compiler and is in the
424 -- range of Natural. Note that if an RR line is present for the same
425 -- restriction, then the value in the RV line cannot exceed the value
426 -- in the RR line (since otherwise the compiler would have detected a
427 -- violation of the restriction).
429 -- RV name=N+
431 -- Similar to the above, but the compiler cannot determine the exact
432 -- count of violations, but it is at least N.
434 -- -------------------------------------------------
435 -- -- R Restrictions (No_Dependence Information) --
436 -- -------------------------------------------------
438 -- Subsequent R lines are present only if pragma Restriction No_Dependence
439 -- is used. There is one such line for each such pragma appearing in the
440 -- extended main unit. The format is:
442 -- R unit_name
444 -- Here the unit name is in all lower case. The components of the unit
445 -- name are separated by periods. The names themselves are in encoded
446 -- form, as documented in Namet.
448 -- -------------------------
449 -- -- I Interrupt States --
450 -- -------------------------
452 -- I interrupt-number interrupt-state line-number
454 -- This line records information from an Interrupt_State pragma. There
455 -- is one line for each separate pragma, and if no such pragmas are
456 -- used, then no I lines are present.
458 -- The interrupt-number is an unsigned positive integer giving the
459 -- value of the interrupt as defined in Ada.Interrupts.Names.
461 -- The interrupt-state is one of r/s/u for Runtime/System/User
463 -- The line number is an unsigned decimal integer giving the line
464 -- number of the corresponding Interrupt_State pragma. This is used
465 -- in consistency messages.
467 -- --------------------------------------
468 -- -- S Priority Specific Dispatching --
469 -- --------------------------------------
471 -- S policy_identifier first_priority last_priority line-number
473 -- This line records information from a Priority_Specific_Dispatching
474 -- pragma. There is one line for each separate pragma, and if no such
475 -- pragmas are used, then no S lines are present.
477 -- The policy_identifier is the first character (upper case) of the
478 -- corresponding policy name (e.g. 'F' for FIFO_Within_Priorities).
480 -- The first_priority and last_priority fields define the range of
481 -- priorities to which the specified dispatching policy apply.
483 -- The line number is an unsigned decimal integer giving the line
484 -- number of the corresponding Priority_Specific_Dispatching pragma.
485 -- This is used in consistency messages.
487 ----------------------------
488 -- Compilation Unit Lines --
489 ----------------------------
491 -- Following these header lines, a set of information lines appears for
492 -- each compilation unit that appears in the corresponding object file. In
493 -- particular, when a package body or subprogram body is compiled, there
494 -- will be two sets of information, one for the spec and one for the body,
495 -- with the entry for the body appearing first. This is the only case in
496 -- which a single ALI file contains more than one unit (in particular note
497 -- that subunits do *not* count as compilation units for this purpose, and
498 -- generate no library information, since they are inlined).
500 -- --------------------
501 -- -- U Unit Header --
502 -- --------------------
504 -- The lines for each compilation unit have the following form
506 -- U unit-name source-name version <<attributes>>
508 -- This line identifies the unit to which this section of the library
509 -- information file applies. The first three parameters are the unit
510 -- name in internal format, as described in package Uname, and the name
511 -- of the source file containing the unit.
513 -- Version is the version given as eight hexadecimal characters with
514 -- upper case letters. This value is the exclusive or of the source
515 -- checksums of the unit and all its semantically dependent units.
517 -- The <<attributes>> are a series of two letter codes indicating
518 -- information about the unit:
520 -- BD Unit does not have pragma Elaborate_Body, but the elaboration
521 -- circuit has determined that it would be a good idea if this
522 -- pragma were present, since the body of the package contains
523 -- elaboration code that modifies one or more variables in the
524 -- visible part of the package. The binder will try, but does
525 -- not promise, to keep the elaboration of the body close to
526 -- the elaboration of the spec.
528 -- DE Dynamic Elaboration. This unit was compiled with the dynamic
529 -- elaboration model, as set by either the -gnatE switch or
530 -- pragma Elaboration_Checks (Dynamic).
532 -- EB Unit has pragma Elaborate_Body, or is a generic instance that
533 -- has a body. Set for instances because RM 12.3(20) requires
534 -- that the body be immediately elaborated after the spec (we
535 -- would normally do that anyway, because elaborate spec and
536 -- body together whenever possible, and for an instance it is
537 -- always possible; however setting EB ensures that this is done
538 -- even when using the -p gnatbind switch).
540 -- EE Elaboration entity is present which must be set true when
541 -- the unit is elaborated. The name of the elaboration entity is
542 -- formed from the unit name in the usual way. If EE is present,
543 -- then this boolean must be set True as part of the elaboration
544 -- processing routine generated by the binder. Note that EE can
545 -- be set even if NE is set. This happens when the boolean is
546 -- needed solely for checking for the case of access before
547 -- elaboration.
549 -- GE Unit is a generic declaration, or corresponding body
551 -- IL Unit source uses a style with identifiers in all lower-case
552 -- IU (IL) or all upper case (IU). If the standard mixed-case usage
553 -- is detected, or the compiler cannot determine the style, then
554 -- no I parameter will appear.
556 -- IS Initialize_Scalars pragma applies to this unit, or else there
557 -- is at least one use of the Invalid_Value attribute.
559 -- KM Unit source uses a style with keywords in mixed case (KM)
560 -- KU or all upper case (KU). If the standard lower-case usage is
561 -- is detected, or the compiler cannot determine the style, then
562 -- no K parameter will appear.
564 -- NE Unit has no elaboration routine. All subprogram bodies and
565 -- specs are in this category. Package bodies and specs may or
566 -- may not have NE set, depending on whether or not elaboration
567 -- code is required. Set if N_Compilation_Unit node has flag
568 -- Has_No_Elaboration_Code set.
570 -- OL The units in this file are compiled with a local pragma
571 -- Optimize_Alignment, so no consistency requirement applies
572 -- to these units. All internal units have this status since
573 -- they have an automatic default of Optimize_Alignment (Off).
575 -- OO Optimize_Alignment (Off) is the default setting for all
576 -- units in this file. All files in the partition that specify
577 -- a default must specify the same default.
579 -- OS Optimize_Alignment (Space) is the default setting for all
580 -- units in this file. All files in the partition that specify
581 -- a default must specify the same default.
583 -- OT Optimize_Alignment (Time) is the default setting for all
584 -- units in this file. All files in the partition that specify
585 -- a default must specify the same default.
587 -- PF The unit has a library-level (package) finalizer
589 -- PK Unit is package, rather than a subprogram
591 -- PU Unit has pragma Pure
593 -- PR Unit has pragma Preelaborate
595 -- RA Unit declares a Remote Access to Class-Wide (RACW) type
597 -- RC Unit has pragma Remote_Call_Interface
599 -- RT Unit has pragma Remote_Types
601 -- SP Unit has pragma Shared_Passive.
603 -- SU Unit is a subprogram, rather than a package
605 -- The attributes may appear in any order, separated by spaces.
607 -- -----------------------------
608 -- -- W, Y and Z Withed Units --
609 -- -----------------------------
611 -- Following each U line, is a series of lines of the form
613 -- W unit-name [source-name lib-name] [E] [EA] [ED] [AD]
614 -- or
615 -- Y unit-name [source-name lib-name] [E] [EA] [ED] [AD]
616 -- or
617 -- Z unit-name [source-name lib-name] [E] [EA] [ED] [AD]
619 -- One W line is present for each unit that is mentioned in an explicit
620 -- non-limited with clause by the current unit. One Y line is present
621 -- for each unit that is mentioned in an explicit limited with clause
622 -- by the current unit. One Z line is present for each unit that is
623 -- only implicitly withed by the current unit. The first parameter is
624 -- the unit name in internal format. The second parameter is the file
625 -- name of the file that must be compiled to compile this unit. It is
626 -- usually the file for the body, except for packages which have no
627 -- body. For units that need a body, if the source file for the body
628 -- cannot be found, the file name of the spec is used instead. The
629 -- third parameter is the file name of the library information file
630 -- that contains the results of compiling this unit. The optional
631 -- modifiers are used as follows:
633 -- E pragma Elaborate applies to this unit
635 -- EA pragma Elaborate_All applies to this unit
637 -- ED Elaborate_Desirable set for this unit, which means that there
638 -- is no Elaborate, but the analysis suggests that Program_Error
639 -- may be raised if the Elaborate conditions cannot be satisfied.
640 -- The binder will attempt to treat ED as E if it can.
642 -- AD Elaborate_All_Desirable set for this unit, which means that
643 -- there is no Elaborate_All, but the analysis suggests that
644 -- Program_Error may be raised if the Elaborate_All conditions
645 -- cannot be satisfied. The binder will attempt to treat AD as
646 -- EA if it can.
648 -- The parameter source-name and lib-name are omitted for the case of a
649 -- generic unit compiled with earlier versions of GNAT which did not
650 -- generate object or ali files for generics. For compatibility in the
651 -- bootstrap path we continue to omit these entries for predefined
652 -- generic units, even though we do now generate object and ali files.
654 -- However, in SPARK mode, we always generate source-name and lib-name
655 -- parameters. Bootstrap issues do not apply there, and we need this
656 -- information to properly compute frame conditions of subprograms.
658 -- The parameter source-name and lib-name are also omitted for the W
659 -- lines that result from use of a Restriction_Set attribute which gets
660 -- a result of False from a No_Dependence check, in the case where the
661 -- unit is not in the semantic closure. In such a case, the bare W
662 -- line is generated, but no D (dependency) line. This will make the
663 -- binder do the consistency check, but not include the unit in the
664 -- partition closure (unless it is properly With'ed somewhere).
666 -- -----------------------
667 -- -- L Linker_Options --
668 -- -----------------------
670 -- Following the W lines (if any, or the U line if not), are an optional
671 -- series of lines that indicates the usage of the pragma Linker_Options in
672 -- the associated unit. For each appearance of a pragma Linker_Options (or
673 -- Link_With) in the unit, a line is present with the form:
675 -- L "string"
677 -- where string is the string from the unit line enclosed in quotes.
678 -- Within the quotes the following can occur:
680 -- c graphic characters in range 20-7E other than " or {
681 -- "" indicating a single " character
682 -- {hh} indicating a character whose code is hex hh (0-9,A-F)
683 -- {00} [ASCII.NUL] is used as a separator character
684 -- to separate multiple arguments of a single
685 -- Linker_Options pragma.
687 -- For further details, see Stringt.Write_String_Table_Entry. Note that
688 -- wide characters in the form {hhhh} cannot be produced, since pragma
689 -- Linker_Option accepts only String, not Wide_String.
691 -- The L lines are required to appear in the same order as the
692 -- corresponding Linker_Options (or Link_With) pragmas appear in the
693 -- source file, so that this order is preserved by the binder in
694 -- constructing the set of linker arguments.
696 -- Note: Linker_Options lines never appear in the ALI file generated for
697 -- a predefined generic unit, and there is cicuitry in Sem_Prag to enforce
698 -- this restriction, which is needed because of not generating source name
699 -- and lib name parameters on the with lines for such files, as explained
700 -- above in the section on with lines.
702 -- --------------
703 -- -- N Notes --
704 -- --------------
706 -- The final section of unit-specific lines contains notes which record
707 -- annotations inserted in source code for processing by external tools
708 -- using pragmas. For each occurrence of any of these pragmas, a line is
709 -- generated with the following syntax:
711 -- N x<sloc> [<arg_id>:]<arg> ...
713 -- x is one of:
714 -- A pragma Annotate
715 -- C pragma Comment
716 -- I pragma Ident
717 -- T pragma Title
718 -- S pragma Subtitle
720 -- <sloc> is the source location of the pragma in line:col[:filename]
721 -- format. The file name is omitted if it is the same as the current
722 -- unit (it therefore appears explicitly in the case of pragmas
723 -- occurring in subunits, which do not have U sections of their own).
725 -- Successive entries record the pragma_argument_associations.
727 -- If a pragma argument identifier is present, the entry is prefixed
728 -- with the pragma argument identifier <arg_id> followed by a colon.
730 -- <arg> represents the pragma argument, and has the following
731 -- conventions:
733 -- - identifiers are output verbatim
734 -- - static string expressions are output as literals encoded as
735 -- for L lines
736 -- - static integer expressions are output as decimal literals
737 -- - any other expression is replaced by the placeholder "<expr>"
739 ---------------------
740 -- Reference Lines --
741 ---------------------
743 -- The reference lines contain information about references from any of the
744 -- units in the compilation (including body version and version attributes,
745 -- linker options pragmas and source dependencies).
747 -- ------------------------------------
748 -- -- E External Version References --
749 -- ------------------------------------
751 -- One of these lines is present for each use of 'Body_Version or 'Version
752 -- in any of the units of the compilation. These are used by the linker to
753 -- determine which version symbols must be output. The format is simply:
755 -- E name
757 -- where name is the external name, i.e. the unit name with either a S or a
758 -- B for spec or body version referenced (Body_Version always references
759 -- the body, Version references the Spec, except in the case of a reference
760 -- to a subprogram with no separate spec). Upper half and wide character
761 -- codes are encoded using the same method as in Namet (Uhh for upper half,
762 -- Whhhh for wide character, where hh are hex digits).
764 -- ---------------------
765 -- -- D Dependencies --
766 -- ---------------------
768 -- The dependency lines indicate the source files on which the compiled
769 -- units depend. This is used by the binder for consistency checking.
770 -- These lines are also referenced by the cross-reference information.
772 -- D source-name time-stamp checksum (sub)unit-name line:file-name
774 -- source-name also includes preprocessing data file and preprocessing
775 -- definition file. These preprocessing files may be given as full
776 -- path names instead of simple file names. If a full path name
777 -- includes a directory with spaces, the path name is quoted (quote
778 -- characters (") added at start and end, and any internal quotes are
779 -- doubled).
781 -- The time-stamp field contains the time stamp of the corresponding
782 -- source file. See types.ads for details on time stamp representation.
784 -- The checksum is an 8-hex digit representation of the source file
785 -- checksum, with letters given in lower case.
787 -- If the unit is not a subunit, the (sub)unit name is the unit name in
788 -- internal format, as described in package Uname. If the unit is a
789 -- subunit, the (sub)unit name is the fully qualified name of the
790 -- subunit in all lower case letters.
792 -- The line:file-name entry is present only if a Source_Reference
793 -- pragma appeared in the source file identified by source-name. In
794 -- this case, it gives the information from this pragma. Note that this
795 -- allows cross-reference information to be related back to the
796 -- original file. Note: the reason the line number comes first is that
797 -- a leading digit immediately identifies this as a Source_Reference
798 -- entry, rather than a subunit-name.
800 -- A line number of zero for line: in this entry indicates that there
801 -- is more than one source reference pragma. In this case, the line
802 -- numbers in the cross-reference are correct, and refer to the
803 -- original line number, but there is no information that allows a
804 -- reader of the ALI file to determine the exact mapping of physical
805 -- line numbers back to the original source.
807 -- Files with a zero checksum and a non-zero time stamp are in general
808 -- files on which the compilation depends but which are not Ada files
809 -- with further dependencies. This includes preprocessor data files
810 -- and preprocessor definition files.
812 -- Note: blank lines are ignored when the library information is read,
813 -- and separate sections of the file are separated by blank lines to
814 -- ease readability. Blanks between fields are also ignored.
816 -- For entries corresponding to files that were not present (and thus
817 -- resulted in error messages), or for files that are not part of the
818 -- dependency set, both the time stamp and checksum are set to all zero
819 -- characters. These dummy entries are ignored by the binder in
820 -- dependency checking, but must be present for proper interpretation
821 -- of the cross-reference data.
823 --------------------------
824 -- Cross-Reference Data --
825 --------------------------
827 -- The cross-reference data follows the dependency lines. See the spec of
828 -- Lib.Xref in file lib-xref.ads for details on the format of this data.
830 ---------------------------------
831 -- Source Coverage Obligations --
832 ---------------------------------
834 -- The Source Coverage Obligation (SCO) information follows the cross-
835 -- reference data. See the spec of Par_SCO in file par_sco.ads for full
836 -- details of the format.
838 ---------------------------------------
839 -- SPARK Cross-Reference Information --
840 ---------------------------------------
842 -- The SPARK cross-reference information follows the SCO information. See
843 -- the spec of SPARK_Xrefs in file spark_xrefs.ads for full details of the
844 -- format.
846 -------------------------------
847 -- ALI File Generation for C --
848 -------------------------------
850 -- The C compiler can also generate ALI files for use by the IDE's in
851 -- providing navigation services in C. These ALI files are a subset of
852 -- the specification above, lacking all Ada-specific output. Primarily
853 -- the IDE uses the cross-reference sections of such files.
855 ----------------------
856 -- Global Variables --
857 ----------------------
859 -- The table defined here stores one entry for each Interrupt_State pragma
860 -- encountered either in the main source or in an ancillary with'ed source.
861 -- Since interrupt state values have to be consistent across all units in a
862 -- partition, we detect inconsistencies at compile time when we can.
864 type Interrupt_State_Entry is record
865 Interrupt_Number : Pos;
866 -- Interrupt number value
868 Interrupt_State : Character;
869 -- Set to r/s/u for Runtime/System/User
871 Pragma_Loc : Source_Ptr;
872 -- Location of pragma setting this value in place
873 end record;
875 package Interrupt_States is new Table.Table (
876 Table_Component_Type => Interrupt_State_Entry,
877 Table_Index_Type => Nat,
878 Table_Low_Bound => 1,
879 Table_Initial => 30,
880 Table_Increment => 200,
881 Table_Name => "Name_Interrupt_States");
883 -- The table structure defined here stores one entry for each
884 -- Priority_Specific_Dispatching pragma encountered either in the main
885 -- source or in an ancillary with'ed source. Since have to be consistent
886 -- across all units in a partition, we may as well detect inconsistencies
887 -- at compile time when we can.
889 type Specific_Dispatching_Entry is record
890 Dispatching_Policy : Character;
891 -- First character (upper case) of the corresponding policy name
893 First_Priority : Nat;
894 -- Lower bound of the priority range to which the specified dispatching
895 -- policy applies.
897 Last_Priority : Nat;
898 -- Upper bound of the priority range to which the specified dispatching
899 -- policy applies.
901 Pragma_Loc : Source_Ptr;
902 -- Location of pragma setting this value in place
903 end record;
905 package Specific_Dispatching is new Table.Table (
906 Table_Component_Type => Specific_Dispatching_Entry,
907 Table_Index_Type => Nat,
908 Table_Low_Bound => 1,
909 Table_Initial => 10,
910 Table_Increment => 100,
911 Table_Name => "Name_Priority_Specific_Dispatching");
913 -----------------
914 -- Subprograms --
915 -----------------
917 procedure Ensure_System_Dependency;
918 -- This procedure ensures that a dependency is created on system.ads. Even
919 -- if there is no semantic dependency, Targparm has read the file to
920 -- acquire target parameters, so we need a source dependency.
922 procedure Write_ALI (Object : Boolean);
923 -- This procedure writes the library information for the current main unit
924 -- The Object parameter is true if an object file is created, and false
925 -- otherwise. Note that the pseudo-object file generated in GNATProve mode
926 -- does count as an object file from this point of view.
928 -- Note: in the case where we are not generating code (-gnatc mode), this
929 -- routine only writes an ALI file if it cannot find an existing up to
930 -- date ALI file. If it *can* find an existing up to date ALI file, then
931 -- it reads this file and sets the Lib.Compilation_Arguments table from
932 -- the A lines in this file.
934 procedure Add_Preprocessing_Dependency (S : Source_File_Index);
935 -- Indicate that there is a dependency to be added on a preprocessing data
936 -- file or on a preprocessing definition file.
938 end Lib.Writ;