Debian Codegraph @

gcc/ada/lib-writ.ads

raw
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-2025, 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 contains the routines for writing the library information
27
28 package Lib.Writ is
29
30 -----------------------------------
31 -- Format of Library Information --
32 -----------------------------------
33
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.
43
44 -- The library information is written as a series of lines of the form:
45
46 -- Key_Character parameter parameter ...
47
48 -- The following sections describe the format of these lines in detail
49
50 --------------------------------------
51 -- Making Changes to the ALI Format --
52 --------------------------------------
53
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 GNAT Studio and newer versions of the
60 -- compiler.
61
62 -- If the following guidelines are respected, downward compatibility
63 -- problems (old tools reading new ali files) should be minimized:
64
65 -- The basic key character format must be kept
66
67 -- The V line must be the first line, this is checked by ali.adb even in
68 -- Ignore_Errors mode, and is used to verify that the file at hand is
69 -- indeed likely intended to be an ali file.
70
71 -- The P line must be present, though may be modified in contents
72 -- according to remaining guidelines. Again, ali.adb assumes the P
73 -- line is present even in Ignore_Errors mode.
74
75 -- New modifiers can generally be added (in particular adding new two
76 -- letter modifiers to the P or U lines is always safe)
77
78 -- Adding entirely new lines (with a new key letter) to the ali file is
79 -- always safe, at any point (other than before the V line), since such
80 -- lines will be ignored.
81
82 -- Following the guidelines in this section should ensure that this problem
83 -- is minimized and that old tools will be able to deal successfully with
84 -- new ali formats. Note that this does not apply to the compiler itself,
85 -- which always requires consistency between the ali files and the binder.
86 -- That is because one of the main functions of the binder is to ensure
87 -- consistency of the partition, and this can be compromised if the ali
88 -- files are inconsistent.
89
90 ------------------
91 -- Header Lines --
92 ------------------
93
94 -- The initial header lines in the file give information about the
95 -- compilation environment, and identify other special information such as
96 -- main program parameters.
97
98 -- ----------------
99 -- -- V Version --
100 -- ----------------
101
102 -- V "xxxxxxxxxxxxxxxx"
103 --
104 -- This line indicates the library output version, as defined in
105 -- Gnatvsn. It ensures that separate object modules of a program are
106 -- consistent. It has to be changed if anything changes which would
107 -- affect successful binding of separately compiled modules. Examples
108 -- of such changes are modifications in the format of the library info
109 -- described in this package, or modifications to calling sequences, or
110 -- to the way that data is represented.
111
112 -- Note: the V line absolutely must be the first line, and no change
113 -- to the ALI format should change this, since even in Ignore_Errors
114 -- mode, Scan_ALI insists on finding a V line.
115
116 -- ---------------------
117 -- -- M Main Program --
118 -- ---------------------
119
120 -- M type [priority] [T=time-slice] [C=cpu] W=?
121
122 -- This line appears only if the main unit for this file is suitable
123 -- for use as a main program. The parameters are:
124
125 -- type
126
127 -- P for a parameterless procedure
128 -- F for a function returning a value of integral type
129 -- (used for writing a main program returning an exit status)
130
131 -- priority
132
133 -- Present only if there was a valid pragma Priority in the
134 -- corresponding unit to set the main task priority. It is an
135 -- unsigned decimal integer.
136
137 -- T=time-slice
138
139 -- Present only if there was a valid pragma Time_Slice in the
140 -- corresponding unit. It is an unsigned decimal integer in the
141 -- range 0 .. 10**9 giving the time slice value in units of
142 -- milliseconds. The actual significance of this parameter is
143 -- target dependent.
144
145 -- C=cpu
146
147 -- Present only if there was a valid pragma CPU in the
148 -- corresponding unit to set the main task affinity. It is an
149 -- unsigned decimal integer.
150
151 -- W=?
152
153 -- This parameter indicates the wide character encoding method used
154 -- when compiling the main program file. The ? character is the
155 -- single character used in the -gnatW? switch. This is used to
156 -- provide the default wide-character encoding for Wide_Text_IO
157 -- files.
158
159 -- -----------------
160 -- -- A Argument --
161 -- -----------------
162
163 -- A argument
164
165 -- One of these lines appears for each of the arguments present in the
166 -- call to the gnat1 program. This can be used if it is necessary to
167 -- reconstruct this call (e.g. for fix and continue).
168
169 -- -------------------
170 -- -- P Parameters --
171 -- -------------------
172
173 -- P <<parameters>>
174
175 -- Indicates various information that applies to the compilation of the
176 -- corresponding source file. Parameters is a sequence of zero or more
177 -- two letter codes that indicate configuration pragmas and other
178 -- parameters that apply:
179
180 -- The arguments are as follows:
181
182 -- CE Compilation errors. If this is present it means that the ali
183 -- file resulted from a compilation with the -gnatQ switch set,
184 -- and illegalities were detected. The ali file contents may
185 -- not be completely reliable, but the format will be correct
186 -- and complete. Note that NO is always present if CE is
187 -- present.
188
189 -- DB Detect_Blocking pragma is in effect for all units in this
190 -- file.
191
192 -- Ex A valid Partition_Elaboration_Policy pragma applies to all
193 -- the units in this file, where x is the first character
194 -- (upper case) of the policy name (e.g. 'C' for Concurrent).
195
196 -- FX Units in this file use front-end exceptions, with explicit
197 -- handlers to trigger AT-END actions on exception paths.
198
199 -- GP Set if this compilation was done in GNATprove mode, either
200 -- from direct use of GNATprove, or from use of -gnatdF.
201
202 -- ID Interrupts_System_By_Default pragma applies to this
203 -- partition. No handlers will be installed by default,
204 -- including signal handlers. This is a configuration
205 -- pragma.
206
207 -- Lx A valid Locking_Policy pragma applies to all the units in
208 -- this file, where x is the first character (upper case) of
209 -- the policy name (e.g. 'C' for Ceiling_Locking).
210
211 -- NO No object. This flag indicates that the units in this file
212 -- were not compiled to produce an object. This can occur as a
213 -- result of the use of -gnatc, or if no object can be produced
214 -- (e.g. when a package spec is compiled instead of the body,
215 -- or a subunit on its own). Note that in GNATprove mode, we
216 -- do produce an object. The object is not suitable for binding
217 -- and linking, but we do not set NO, instead we set GP.
218
219 -- NR No_Run_Time. Indicates that a pragma No_Run_Time applies
220 -- to all units in the file.
221
222 -- NS Normalize_Scalars pragma in effect for all units in
223 -- this file.
224
225 -- OH Pragma Default_Scalar_Storage_Order (High_Order_First) is
226 -- present in a configuration pragma file that applies.
227
228 -- OL Pragma Default_Scalar_Storage_Order (Low_Order_First) is
229 -- present in a configuration pragma file that applies.
230
231 -- Qx A valid Queuing_Policy pragma applies to all the units in
232 -- this file, where x is the first character (upper case) of
233 -- the policy name (e.g. 'P' for Priority_Queuing).
234
235 -- SL Indicates that the unit is an Interface to a Standalone
236 -- Library. Note that this indication is never given by the
237 -- compiler, but is added by the Project Manager in gnatmake
238 -- when an Interface ALI file is copied to the library
239 -- directory.
240
241 -- SS This unit references System.Secondary_Stack (that is,
242 -- the unit makes use of the secondary stack facilities).
243
244 -- Tx A valid Task_Dispatching_Policy pragma applies to all
245 -- the units in this file, where x is the first character
246 -- (upper case) of the corresponding policy name (e.g. 'F'
247 -- for FIFO_Within_Priorities).
248
249 -- UA Unreserve_All_Interrupts pragma was processed in one or
250 -- more units in this file
251
252 -- ZX Units in this file use zero-cost exceptions and have
253 -- generated exception tables. If ZX is not present, the
254 -- longjmp/setjmp exception scheme is in use.
255
256 -- Note that library units from the GNAT runtime library should never
257 -- output policy (Lx, Tx, Qx) parameters. They must correctly handle
258 -- all possible cases to be usable in all contexts. These values are
259 -- checked for consistency by the binder and then copied to the
260 -- generated binder output file.
261
262 -- Note: The P line must be present. Even in Ignore_Errors mode, Scan_ALI
263 -- insists on finding a P line. So if changes are made to the ALI format,
264 -- they should not include removing the P line.
265
266 -- ---------------------
267 -- -- R Restrictions --
268 -- ---------------------
269
270 -- There are two forms for R lines, positional and named. The positional
271 -- notation is now considered obsolescent, it is not generated by the most
272 -- recent versions of the compiler except under control of the debug switch
273 -- -gnatdR, but is still recognized by the binder.
274
275 -- The recognition by the binder is to ease the transition, and better deal
276 -- with some cases of inconsistent builds using incompatible versions of
277 -- the compiler and binder. The named notation is the current preferred
278 -- approach.
279
280 -- Note that R lines are generated using the information in unit Rident,
281 -- and intepreted by the binder using the information in System.Rident.
282 -- Normally these two units should be effectively identical. However in
283 -- some cases of inconsistent builds, they may be different. This may lead
284 -- to binder diagnostics, which can be suppressed using the -C switch for
285 -- the binder, which results in ignoring unrecognized restrictions in the
286 -- ali files.
287
288 -- ---------------------------------------
289 -- -- R Restrictions (Positional Form) --
290 -- ---------------------------------------
291
292 -- The first R line records the status of restrictions generated by pragma
293 -- Restrictions encountered, as well as information on what the compiler
294 -- has been able to determine with respect to restrictions violations.
295 -- The format is:
296
297 -- R <<restriction-characters>> <<restriction-param-id-entries>>
298
299 -- The first parameter is a string of characters that records
300 -- information regarding restrictions that do not take parameter not
301 -- take parameter values. It is a string of characters, one character
302 -- for each value (in order) in All_Boolean_Restrictions. There are
303 -- three possible settings for each restriction:
304
305 -- r Restricted. Unit was compiled under control of a pragma
306 -- Restrictions for the corresponding restriction. In this case
307 -- the unit certainly does not violate the Restriction, since
308 -- this would have been detected by the compiler.
309
310 -- n Not used. The unit was not compiled under control of a pragma
311 -- Restrictions for the corresponding restriction, and does not
312 -- make any use of the referenced feature.
313
314 -- v Violated. The unit was not compiled under control of a pragma
315 -- Restrictions for the corresponding restriction, and it does
316 -- indeed use the referenced feature.
317
318 -- This information is used in the binder to check consistency, i.e. to
319 -- detect cases where one unit has "r" and another unit has "v", which
320 -- is not permitted, since these restrictions are partition-wide.
321
322 -- The second parameter, which immediately follows the first (with no
323 -- separating space) gives restriction information for identifiers for
324 -- which a parameter is given.
325
326 -- The parameter is a string of entries, one for each value in
327 -- Restrict.All_Parameter_Restrictions. Each entry has two components
328 -- in sequence, the first indicating whether or not there is a
329 -- restriction, and the second indicating whether or not the compiler
330 -- detected violations. In the boolean case it is not necessary to
331 -- separate these, since if a restriction is set, and violated, that is
332 -- an error. But in the parameter case, this is not true. For example,
333 -- we can have a unit with a pragma Restrictions (Max_Tasks => 4),
334 -- where the compiler can detect that there are exactly three tasks
335 -- declared. Both of these pieces of information must be passed to the
336 -- binder. The parameter of 4 is important in case the total number of
337 -- tasks in the partition is greater than 4. The parameter of 3 is
338 -- important in case some other unit has a restrictions pragma with
339 -- Max_Tasks=>2.
340
341 -- The component for the presence of restriction has one of two
342 -- possible forms:
343
344 -- n No pragma for this restriction is present in the set of units
345 -- for this ali file.
346
347 -- rN At least one pragma for this restriction is present in the
348 -- set of units for this ali file. The value N is the minimum
349 -- parameter value encountered in any such pragma. N is in the
350 -- range of Integer (a value larger than N'Last causes the
351 -- pragma to be ignored).
352
353 -- The component for the violation detection has one of three
354 -- possible forms:
355
356 -- n No violations were detected by the compiler
357
358 -- vN A violation was detected. N is either the maximum or total
359 -- count of violations (depending on the checking type) in all
360 -- the units represented by the ali file). Note that this
361 -- setting is only allowed for restrictions that are in
362 -- Checked_[Max|Sum]_Parameter_Restrictions. The value here is
363 -- known to be exact by the compiler and is in the range of
364 -- Natural.
365
366 -- vN+ A violation was detected. The compiler cannot determine
367 -- the exact count of violations, but it is at least N.
368
369 -- There are no spaces within the parameter string, so the entry
370 -- described above in the header of this section for Max_Tasks would
371 -- appear as the string r4v3.
372
373 -- Note: The restrictions line is required to be present. Even in
374 -- Ignore_Errors mode, Scan_ALI expects to find an R line and will
375 -- signal a fatal error if it is missing. This means that future
376 -- changes to the ALI file format must retain the R line.
377
378 -- ----------------------------------
379 -- -- R Restrictions (Named Form) --
380 -- ----------------------------------
381
382 -- The first R line for named form announces that named notation will be
383 -- used, and also assures that there is at least one R line present, which
384 -- makes parsing of ali files simpler. A blank line preceds the RN line.
385
386 -- RN
387
388 -- In named notation, the restrictions are given as a series of lines,
389 -- one per restrictions that is specified or violated (no information is
390 -- present for restrictions that are not specified or violated). In the
391 -- following name is the name of the restriction in all upper case.
392
393 -- For boolean restrictions, we have only two possibilities. A restrictions
394 -- pragma is present, or a violation is detected:
395
396 -- RR name
397
398 -- A restriction pragma is present for the named boolean restriction.
399 -- No violations were detected by the compiler (or the unit in question
400 -- would have been found to be illegal).
401
402 -- RV name
403
404 -- No restriction pragma is present for the named boolean restriction.
405 -- However, the compiler did detect one or more violations of this
406 -- restriction, which may require a binder consistency check. Note that
407 -- one case of a violation is the use of a Restriction_Set attribute for
408 -- the restriction that yielded False.
409
410 -- For the case of restrictions that take a parameter, we need both the
411 -- information from pragma if present, and the actual information about
412 -- what possible violations occur. For example, we can have a unit with
413 -- a pragma Restrictions (Max_Tasks => 4), where the compiler can detect
414 -- that there are exactly three tasks declared. Both of these pieces
415 -- of information must be passed to the binder. The parameter of 4 is
416 -- important in case the total number of tasks in the partition is greater
417 -- than 4. The parameter of 3 is important in case some other unit has a
418 -- restrictions pragma with Max_Tasks=>2.
419
420 -- RR name=N
421
422 -- A restriction pragma is present for the named restriction which is
423 -- one of the restrictions taking a parameter. The value N (a decimal
424 -- integer) is the value given in the restriction pragma.
425
426 -- RV name=N
427
428 -- A restriction pragma may or may not be present for the restriction
429 -- given by name (one of the restrictions taking a parameter). But in
430 -- either case, the compiler detected possible violations. N (a decimal
431 -- integer) is the maximum or total count of violations (depending
432 -- on the checking type) in all the units represented by the ali file).
433 -- The value here is known to be exact by the compiler and is in the
434 -- range of Natural. Note that if an RR line is present for the same
435 -- restriction, then the value in the RV line cannot exceed the value
436 -- in the RR line (since otherwise the compiler would have detected a
437 -- violation of the restriction).
438
439 -- RV name=N+
440
441 -- Similar to the above, but the compiler cannot determine the exact
442 -- count of violations, but it is at least N.
443
444 -- -------------------------------------------------
445 -- -- R Restrictions (No_Dependence Information) --
446 -- -------------------------------------------------
447
448 -- Subsequent R lines are present only if pragma Restriction No_Dependence
449 -- is used. There is one such line for each such pragma appearing in the
450 -- extended main unit. The format is:
451
452 -- R unit_name
453
454 -- Here the unit name is in all lower case. The components of the unit
455 -- name are separated by periods. The names themselves are in encoded
456 -- form, as documented in Namet.
457
458 -- -------------------------
459 -- -- I Interrupt States --
460 -- -------------------------
461
462 -- I interrupt-number interrupt-state line-number
463
464 -- This line records information from an Interrupt_State pragma. There
465 -- is one line for each separate pragma, and if no such pragmas are
466 -- used, then no I lines are present.
467
468 -- The interrupt-number is an unsigned positive integer giving the
469 -- value of the interrupt as defined in Ada.Interrupts.Names.
470
471 -- The interrupt-state is one of r/s/u for Runtime/System/User
472
473 -- The line number is an unsigned decimal integer giving the line
474 -- number of the corresponding Interrupt_State pragma. This is used
475 -- in consistency messages.
476
477 -- --------------------------------------
478 -- -- S Priority Specific Dispatching --
479 -- --------------------------------------
480
481 -- S policy_identifier first_priority last_priority line-number
482
483 -- This line records information from a Priority_Specific_Dispatching
484 -- pragma. There is one line for each separate pragma, and if no such
485 -- pragmas are used, then no S lines are present.
486
487 -- The policy_identifier is the first character (upper case) of the
488 -- corresponding policy name (e.g. 'F' for FIFO_Within_Priorities).
489
490 -- The first_priority and last_priority fields define the range of
491 -- priorities to which the specified dispatching policy apply.
492
493 -- The line number is an unsigned decimal integer giving the line
494 -- number of the corresponding Priority_Specific_Dispatching pragma.
495 -- This is used in consistency messages.
496
497 ----------------------------
498 -- Compilation Unit Lines --
499 ----------------------------
500
501 -- Following these header lines, a set of information lines appears for
502 -- each compilation unit that appears in the corresponding object file. In
503 -- particular, when a package body or subprogram body is compiled, there
504 -- will be two sets of information, one for the spec and one for the body,
505 -- with the entry for the body appearing first. This is the only case in
506 -- which a single ALI file contains more than one unit (in particular note
507 -- that subunits do *not* count as compilation units for this purpose, and
508 -- generate no library information, since they are inlined).
509
510 -- --------------------
511 -- -- U Unit Header --
512 -- --------------------
513
514 -- The lines for each compilation unit have the following form
515
516 -- U unit-name source-name version <<attributes>>
517
518 -- This line identifies the unit to which this section of the library
519 -- information file applies. The first three parameters are the unit
520 -- name in internal format, as described in package Uname, and the name
521 -- of the source file containing the unit.
522
523 -- Version is the version given as eight hexadecimal characters with
524 -- upper case letters. This value is the exclusive or of the source
525 -- checksums of the unit and all its semantically dependent units.
526
527 -- The <<attributes>> are a series of two letter codes indicating
528 -- information about the unit:
529
530 -- BD Unit does not have pragma Elaborate_Body, but the elaboration
531 -- circuit has determined that it would be a good idea if this
532 -- pragma were present, since the body of the package contains
533 -- elaboration code that modifies one or more variables in the
534 -- visible part of the package. The binder will try, but does
535 -- not promise, to keep the elaboration of the body close to
536 -- the elaboration of the spec.
537
538 -- DE Dynamic Elaboration. This unit was compiled with the dynamic
539 -- elaboration model, as set by either the -gnatE switch or
540 -- pragma Elaboration_Checks (Dynamic).
541 --
542 -- EB Unit has pragma Elaborate_Body, or is a generic instance that
543 -- has a body. Set for instances because RM 12.3(20) requires
544 -- that the body be immediately elaborated after the spec (we
545 -- would normally do that anyway, because elaborate spec and
546 -- body together whenever possible, and for an instance it is
547 -- always possible; however setting EB ensures that this is done
548 -- even when using the -p gnatbind switch).
549
550 -- EE Elaboration entity is present which must be set true when
551 -- the unit is elaborated. The name of the elaboration entity is
552 -- formed from the unit name in the usual way. If EE is present,
553 -- then this boolean must be set True as part of the elaboration
554 -- processing routine generated by the binder. Note that EE can
555 -- be set even if NE is set. This happens when the boolean is
556 -- needed solely for checking for the case of access before
557 -- elaboration.
558
559 -- GE Unit is a generic declaration, or corresponding body
560 --
561 -- IL Unit source uses a style with identifiers in all lower-case
562 -- IU (IL) or all upper case (IU). If the standard mixed-case usage
563 -- is detected, or the compiler cannot determine the style, then
564 -- no I parameter will appear.
565
566 -- IS Initialize_Scalars pragma applies to this unit, or else there
567 -- is at least one use of the Invalid_Value attribute.
568
569 -- KM Unit source uses a style with keywords in mixed case (KM)
570 -- KU or all upper case (KU). If the standard lower-case usage is
571 -- is detected, or the compiler cannot determine the style, then
572 -- no K parameter will appear.
573
574 -- NE Unit has no elaboration routine. All subprogram bodies and
575 -- specs are in this category. Package bodies and specs may or
576 -- may not have NE set, depending on whether or not elaboration
577 -- code is required. Set if N_Compilation_Unit node has flag
578 -- Has_No_Elaboration_Code set.
579
580 -- OL The units in this file are compiled with a local pragma
581 -- Optimize_Alignment, so no consistency requirement applies
582 -- to these units. All internal units have this status since
583 -- they have an automatic default of Optimize_Alignment (Off).
584 --
585 -- OO Optimize_Alignment (Off) is the default setting for all
586 -- units in this file. All files in the partition that specify
587 -- a default must specify the same default.
588
589 -- OS Optimize_Alignment (Space) is the default setting for all
590 -- units in this file. All files in the partition that specify
591 -- a default must specify the same default.
592
593 -- OT Optimize_Alignment (Time) is the default setting for all
594 -- units in this file. All files in the partition that specify
595 -- a default must specify the same default.
596
597 -- PF The unit has a library-level (package) finalizer
598
599 -- PK Unit is package, rather than a subprogram
600
601 -- PU Unit has pragma Pure
602
603 -- PR Unit has pragma Preelaborate
604
605 -- RA Unit declares a Remote Access to Class-Wide (RACW) type
606
607 -- RC Unit has pragma Remote_Call_Interface
608
609 -- RT Unit has pragma Remote_Types
610
611 -- SE Compilation of unit encountered one or more serious errors.
612 -- Normally the generation of an ALI file is suppressed if there
613 -- is a serious error, but this can be overridden with -gnatQ.
614
615 -- SP Unit has pragma Shared_Passive
616
617 -- SU Unit is a subprogram, rather than a package
618
619 -- The attributes may appear in any order, separated by spaces
620
621 -- -----------------------------
622 -- -- W, Y and Z Withed Units --
623 -- -----------------------------
624
625 -- Following each U line, is a series of lines of the form
626
627 -- W unit-name [source-name lib-name] [E] [EA] [ED] [AD]
628 -- or
629 -- Y unit-name [source-name lib-name] [E] [EA] [ED] [AD]
630 -- or
631 -- Z unit-name [source-name lib-name] [E] [EA] [ED] [AD]
632
633 -- One W line is present for each unit that is mentioned in an explicit
634 -- nonlimited with clause by the current unit. One Y line is present
635 -- for each unit that is mentioned in an explicit limited with clause
636 -- by the current unit. One Z line is present for each unit that is
637 -- only implicitly withed by the current unit. The first parameter is
638 -- the unit name in internal format. The second parameter is the file
639 -- name of the file that must be compiled to compile this unit. It is
640 -- usually the file for the body, except for packages which have no
641 -- body. For units that need a body, if the source file for the body
642 -- cannot be found, the file name of the spec is used instead. The
643 -- third parameter is the file name of the library information file
644 -- that contains the results of compiling this unit. The optional
645 -- modifiers are used as follows:
646
647 -- E pragma Elaborate applies to this unit
648
649 -- EA pragma Elaborate_All applies to this unit
650
651 -- ED Elaborate_Desirable set for this unit, which means that there
652 -- is no Elaborate, but the analysis suggests that Program_Error
653 -- may be raised if the Elaborate conditions cannot be satisfied.
654 -- The binder will attempt to treat ED as E if it can.
655
656 -- AD Elaborate_All_Desirable set for this unit, which means that
657 -- there is no Elaborate_All, but the analysis suggests that
658 -- Program_Error may be raised if the Elaborate_All conditions
659 -- cannot be satisfied. The binder will attempt to treat AD as
660 -- EA if it can.
661
662 -- The parameter source-name and lib-name are omitted for the case of a
663 -- generic unit compiled with earlier versions of GNAT which did not
664 -- generate object or ali files for generics. For compatibility in the
665 -- bootstrap path we continue to omit these entries for predefined
666 -- generic units, even though we do now generate object and ali files.
667
668 -- However, in SPARK mode, we always generate source-name and lib-name
669 -- parameters. Bootstrap issues do not apply there, and we need this
670 -- information to properly compute frame conditions of subprograms.
671
672 -- The parameter source-name and lib-name are also omitted for the W
673 -- lines that result from use of a Restriction_Set attribute which gets
674 -- a result of False from a No_Dependence check, in the case where the
675 -- unit is not in the semantic closure. In such a case, the bare W
676 -- line is generated, but no D (dependency) line. This will make the
677 -- binder do the consistency check, but not include the unit in the
678 -- partition closure (unless it is properly With'ed somewhere).
679
680 -- --------------------
681 -- -- T Task Stacks --
682 -- --------------------
683
684 -- Following the W lines (if any, or the U line if not), is an optional
685 -- line that identifies the number of default-sized primary and secondary
686 -- stacks that the binder needs to create for the tasks declared within the
687 -- unit. For each compilation unit, a line is present in the form:
688
689 -- T primary-stack-quantity secondary-stack-quantity
690
691 -- The first parameter of T defines the number of task objects declared
692 -- in the unit that have no Storage_Size specified. The second parameter
693 -- defines the number of task objects declared in the unit that have no
694 -- Secondary_Stack_Size specified. These values are non-zero only if
695 -- the restrictions No_Implicit_Heap_Allocations or
696 -- No_Implicit_Task_Allocations are active.
697
698 -- -----------------------
699 -- -- L Linker_Options --
700 -- -----------------------
701
702 -- Following the T and W lines (if any, or the U line if not), are
703 -- an optional series of lines that indicates the usage of the pragma
704 -- Linker_Options in the associated unit. For each appearance of a pragma
705 -- Linker_Options (or Link_With) in the unit, a line is present with the
706 -- form:
707
708 -- L "string"
709
710 -- where string is the string from the unit line enclosed in quotes.
711 -- Within the quotes the following can occur:
712
713 -- c graphic characters in range 20-7E other than " or {
714 -- "" indicating a single " character
715 -- {hh} indicating a character whose code is hex hh (0-9,A-F)
716 -- {00} [ASCII.NUL] is used as a separator character
717 -- to separate multiple arguments of a single
718 -- Linker_Options pragma.
719
720 -- For further details, see Stringt.Write_String_Table_Entry. Note that
721 -- wide characters in the form {hhhh} cannot be produced, since pragma
722 -- Linker_Option accepts only String, not Wide_String.
723
724 -- The L lines are required to appear in the same order as the
725 -- corresponding Linker_Options (or Link_With) pragmas appear in the
726 -- source file, so that this order is preserved by the binder in
727 -- constructing the set of linker arguments.
728
729 -- Note: Linker_Options lines never appear in the ALI file generated for
730 -- a predefined generic unit, and there is cicuitry in Sem_Prag to enforce
731 -- this restriction, which is needed because of not generating source name
732 -- and lib name parameters on the with lines for such files, as explained
733 -- above in the section on with lines.
734
735 -- --------------
736 -- -- N Notes --
737 -- --------------
738
739 -- The final section of unit-specific lines contains notes which record
740 -- annotations inserted in source code for processing by external tools
741 -- using pragmas. For each occurrence of any of these pragmas, a line is
742 -- generated with the following syntax:
743
744 -- N x<sloc> [<arg_id>:]<arg> ...
745
746 -- x is one of:
747 -- A pragma Annotate
748 -- C pragma Comment
749 -- I pragma Ident
750 -- T pragma Title
751 -- S pragma Subtitle
752
753 -- <sloc> is the source location of the pragma in line:col[:filename]
754 -- format. The file name is omitted if it is the same as the current
755 -- unit (it therefore appears explicitly in the case of pragmas
756 -- occurring in subunits, which do not have U sections of their own).
757
758 -- Successive entries record the pragma_argument_associations.
759
760 -- If a pragma argument identifier is present, the entry is prefixed
761 -- with the pragma argument identifier <arg_id> followed by a colon.
762
763 -- <arg> represents the pragma argument, and has the following
764 -- conventions:
765
766 -- - identifiers are output verbatim
767 -- - static string expressions are output as literals encoded as
768 -- for L lines
769 -- - static integer expressions are output as decimal literals
770 -- - any other expression is replaced by the placeholder "<expr>"
771
772 ---------------------
773 -- Reference Lines --
774 ---------------------
775
776 -- The reference lines contain information about references from any of the
777 -- units in the compilation (including body version and version attributes,
778 -- linker options pragmas and source dependencies).
779
780 -- ------------------------------------
781 -- -- E External Version References --
782 -- ------------------------------------
783
784 -- One of these lines is present for each use of 'Body_Version or 'Version
785 -- in any of the units of the compilation. These are used by the linker to
786 -- determine which version symbols must be output. The format is simply:
787
788 -- E name
789
790 -- where name is the external name, i.e. the unit name with either a S or a
791 -- B for spec or body version referenced (Body_Version always references
792 -- the body, Version references the Spec, except in the case of a reference
793 -- to a subprogram with no separate spec). Upper half and wide character
794 -- codes are encoded using the same method as in Namet (Uhh for upper half,
795 -- Whhhh for wide character, where hh are hex digits).
796
797 -- ---------------------
798 -- -- D Dependencies --
799 -- ---------------------
800
801 -- The dependency lines indicate the source files on which the compiled
802 -- units depend. This is used by the binder for consistency checking.
803 -- These lines are also referenced by the cross-reference information.
804
805 -- D source-name time-stamp checksum (sub)unit-name line:file-name
806
807 -- source-name also includes preprocessing data file and preprocessing
808 -- definition file. These preprocessing files may be given as full
809 -- path names instead of simple file names. If a full path name
810 -- includes a directory with spaces, the path name is quoted (quote
811 -- characters (") added at start and end, and any internal quotes are
812 -- doubled).
813
814 -- The time-stamp field contains the time stamp of the corresponding
815 -- source file. See types.ads for details on time stamp representation.
816
817 -- The checksum is an 8-hex digit representation of the source file
818 -- checksum, with letters given in lower case.
819
820 -- If the unit is not a subunit, the (sub)unit name is the unit name in
821 -- internal format, as described in package Uname. If the unit is a
822 -- subunit, the (sub)unit name is the fully qualified name of the
823 -- subunit in all lower case letters.
824
825 -- The line:file-name entry is present only if a Source_Reference
826 -- pragma appeared in the source file identified by source-name. In
827 -- this case, it gives the information from this pragma. Note that this
828 -- allows cross-reference information to be related back to the
829 -- original file. Note: the reason the line number comes first is that
830 -- a leading digit immediately identifies this as a Source_Reference
831 -- entry, rather than a subunit-name.
832
833 -- A line number of zero for line: in this entry indicates that there
834 -- is more than one source reference pragma. In this case, the line
835 -- numbers in the cross-reference are correct, and refer to the
836 -- original line number, but there is no information that allows a
837 -- reader of the ALI file to determine the exact mapping of physical
838 -- line numbers back to the original source.
839
840 -- Files with a zero checksum and a non-zero time stamp are in general
841 -- files on which the compilation depends but which are not Ada files
842 -- with further dependencies. This includes preprocessor data files
843 -- and preprocessor definition files.
844
845 -- Note: blank lines are ignored when the library information is read,
846 -- and separate sections of the file are separated by blank lines to
847 -- ease readability. Blanks between fields are also ignored.
848
849 -- For entries corresponding to files that were not present (and thus
850 -- resulted in error messages), or for files that are not part of the
851 -- dependency set, both the time stamp and checksum are set to all zero
852 -- characters. These dummy entries are ignored by the binder in
853 -- dependency checking, but must be present for proper interpretation
854 -- of the cross-reference data.
855
856 -- -------------------------
857 -- -- G Invocation Graph --
858 -- -------------------------
859
860 -- An invocation graph line has the following format:
861 --
862 -- G line-kind line-attributes
863 --
864 -- Attribute line-kind is a Character which denotes the nature of the
865 -- line. Table ALI.Invocation_Graph_Line_Codes lists all legal values.
866 --
867 -- Attribute line-attributes depends on the value of line-kind, and is
868 -- contents are described further below.
869 --
870 -- An invocation signature uniquely identifies an invocation construct in
871 -- the ALI file namespace, and has the following format:
872 --
873 -- [ name scope line column (locations | "none") ]
874 --
875 -- Attribute name is a String which denotes the name of the construct
876 --
877 -- Attribute scope is a String which denotes the qualified name of the
878 -- scope where the construct is declared.
879 --
880 -- Attribute line is a Positive which denotes the line number where the
881 -- initial declaration of the construct appears.
882 --
883 -- Attribute column is a Positive which denotes the column number where
884 -- the initial declaration of the construct appears.
885 --
886 -- Attribute locations is a String which denotes the line and column
887 -- locations of all instances where the initial declaration of the
888 -- construct appears.
889 --
890 -- When the line-kind denotes invocation graph attributes, line-attributes
891 -- are set as follows:
892 --
893 -- encoding-kind
894 --
895 -- Attribute encoding-kind is a Character which specifies the encoding
896 -- kind used when collecting invocation constructs and relations. Table
897 -- ALI.Invocation_Graph_Encoding_Codes lists all legal values.
898 --
899 -- When the line-kind denotes an invocation construct, line-attributes are
900 -- set as follows:
901 --
902 -- construct-kind construct-spec-placement construct-body-placement
903 -- construct-signature
904 --
905 -- Attribute construct-kind is a Character which denotes the nature of
906 -- the construct. Table ALI.Invocation_Construct_Codes lists all legal
907 -- values.
908 --
909 -- Attribute construct-spec-placement is a Character which denotes the
910 -- placement of the construct's spec within the unit. All legal values
911 -- are listed in table ALI.Spec_And_Body_Placement_Codes.
912 --
913 -- Attribute construct-body-placement is a Character which denotes the
914 -- placement of the construct's body within the unit. All legal values
915 -- are listed in table ALI.Spec_And_Body_Placement_Codes.
916 --
917 -- Attribute construct-signature is the invocation signature of the
918 -- construct.
919 --
920 -- When the line-kind denotes an invocation relation, line-attributes are
921 -- set as follows:
922 --
923 -- relation-kind (extra-name | "none") invoker-signature
924 -- target-signature
925 --
926 -- Attribute relation-kind is a Character which denotes the nature of
927 -- the relation. All legal values are listed in ALI.Invocation_Codes.
928 --
929 -- Attribute extra-name is a String which denotes the name of an extra
930 -- entity used for error diagnostics. The value of extra-name depends
931 -- on the relation-kind as follows:
932 --
933 -- Accept_Alternative - related entry
934 -- Access_Taken - related subprogram
935 -- Call - not present
936 -- Controlled_Adjustment - related controlled type
937 -- Controlled_Finalization - related controlled type
938 -- Controlled_Initialization - related controlled type
939 -- Default_Initial_Condition_Verification - related private type
940 -- Initial_Condition_Verification - not present
941 -- Instantiation - not present
942 -- Internal_Controlled_Adjustment - related controlled type
943 -- Internal_Controlled_Finalization - related controlled type
944 -- Internal_Controlled_Initialization - related controlled type
945 -- Invariant_Verification - related private type
946 -- Postcondition_Verification - related routine
947 -- Protected_Entry_Call - not present
948 -- Protected_Subprogram_Call - not present
949 -- Task_Activation - not present
950 -- Task_Entry_Call - not present
951 -- Type_Initialization - related type
952 --
953 -- Attribute invoker-signature is the invocation signature of the
954 -- invoker.
955 --
956 -- Attribute target-signature is the invocation signature of the target
957
958 --------------------------
959 -- Cross-Reference Data --
960 --------------------------
961
962 -- The cross-reference data follows the dependency lines. See the spec of
963 -- Lib.Xref in file lib-xref.ads for details on the format of this data.
964
965 ---------------------------------
966 -- Source Coverage Obligations --
967 ---------------------------------
968
969 -- The Source Coverage Obligation (SCO) information follows the cross-
970 -- reference data. See the spec of Par_SCO in file par_sco.ads for full
971 -- details of the format.
972
973 ---------------------------------------
974 -- SPARK Cross-Reference Information --
975 ---------------------------------------
976
977 -- The SPARK cross-reference information follows the SCO information. See
978 -- the spec of SPARK_Xrefs in file spark_xrefs.ads for full details of the
979 -- format.
980
981 -------------------------------
982 -- ALI File Generation for C --
983 -------------------------------
984
985 -- The C compiler can also generate ALI files for use by the IDE's in
986 -- providing navigation services in C. These ALI files are a subset of
987 -- the specification above, lacking all Ada-specific output. Primarily
988 -- the IDE uses the cross-reference sections of such files.
989
990 ----------------------
991 -- Global Variables --
992 ----------------------
993
994 -- The table defined here stores one entry for each Interrupt_State pragma
995 -- encountered either in the main source or in an ancillary with'ed source.
996 -- Since interrupt state values have to be consistent across all units in a
997 -- partition, we detect inconsistencies at compile time when we can.
998
999 type Interrupt_State_Entry is record
1000 Interrupt_Number : Pos;
1001 -- Interrupt number value
1002
1003 Interrupt_State : Character;
1004 -- Set to r/s/u for Runtime/System/User
1005
1006 Pragma_Loc : Source_Ptr;
1007 -- Location of pragma setting this value in place
1008 end record;
1009
1010 package Interrupt_States is new Table.Table (
1011 Table_Component_Type => Interrupt_State_Entry,
1012 Table_Index_Type => Nat,
1013 Table_Low_Bound => 1,
1014 Table_Initial => 30,
1015 Table_Increment => 200,
1016 Table_Name => "Name_Interrupt_States");
1017
1018 -- The table structure defined here stores one entry for each
1019 -- Priority_Specific_Dispatching pragma encountered either in the main
1020 -- source or in an ancillary with'ed source. Since have to be consistent
1021 -- across all units in a partition, we may as well detect inconsistencies
1022 -- at compile time when we can.
1023
1024 type Specific_Dispatching_Entry is record
1025 Dispatching_Policy : Character;
1026 -- First character (upper case) of the corresponding policy name
1027
1028 First_Priority : Nat;
1029 -- Lower bound of the priority range to which the specified dispatching
1030 -- policy applies.
1031
1032 Last_Priority : Nat;
1033 -- Upper bound of the priority range to which the specified dispatching
1034 -- policy applies.
1035
1036 Pragma_Loc : Source_Ptr;
1037 -- Location of pragma setting this value in place
1038 end record;
1039
1040 package Specific_Dispatching is new Table.Table (
1041 Table_Component_Type => Specific_Dispatching_Entry,
1042 Table_Index_Type => Nat,
1043 Table_Low_Bound => 1,
1044 Table_Initial => 10,
1045 Table_Increment => 100,
1046 Table_Name => "Name_Priority_Specific_Dispatching");
1047
1048 -----------------
1049 -- Subprograms --
1050 -----------------
1051
1052 procedure Ensure_System_Dependency;
1053 -- This procedure ensures that a dependency is created on system.ads. Even
1054 -- if there is no semantic dependency, Targparm has read the file to
1055 -- acquire target parameters, so we need a source dependency.
1056
1057 procedure Write_ALI (Object : Boolean);
1058 -- This procedure writes the library information for the current main unit
1059 -- The Object parameter is true if an object file is created, and false
1060 -- otherwise. Note that the pseudo-object file generated in GNATprove mode
1061 -- does count as an object file from this point of view.
1062 -- May output duplicate D lines caused by generic instantiations. This is
1063 -- by design as GNATcoverage relies on them for its coverage of generic
1064 -- instantiations, although this may be revisited in the future.
1065
1066 procedure Add_Preprocessing_Dependency (S : Source_File_Index);
1067 -- Indicate that there is a dependency to be added on a preprocessing data
1068 -- file, on a preprocessing definition file or on a file included through
1069 -- External_Initialization.
1070
1071 end Lib.Writ;