1 .. _Example_of_Binder_Output_File:
3 *****************************
4 Example of Binder Output File
5 *****************************
7 .. index:: Binder output (example)
9 This Appendix displays the source code for the output file
10 generated by *gnatbind* for a simple 'Hello World' program.
11 Comments have been added for clarification purposes.
16 -- The package is called Ada_Main unless this name is actually used
17 -- as a unit name in the partition, in which case some other unique
23 pragma Warnings (Off);
25 -- The main program saves the parameters (argument count,
26 -- argument values, environment pointer) in global variables
27 -- for later access by other units including
31 gnat_argv : System.Address;
32 gnat_envp : System.Address;
34 -- The actual variables are stored in a library routine. This
35 -- is useful for some shared library situations, where there
36 -- are problems if variables are not in the library.
38 pragma Import (C, gnat_argc);
39 pragma Import (C, gnat_argv);
40 pragma Import (C, gnat_envp);
42 -- The exit status is similarly an external location
44 gnat_exit_status : Integer;
45 pragma Import (C, gnat_exit_status);
47 GNAT_Version : constant String :=
48 "GNAT Version: Pro 7.4.0w (20141119-49)" & ASCII.NUL;
49 pragma Export (C, GNAT_Version, "__gnat_version");
51 Ada_Main_Program_Name : constant String := "_ada_hello" & ASCII.NUL;
52 pragma Export (C, Ada_Main_Program_Name, "__gnat_ada_main_program_name");
54 -- This is the generated adainit routine that performs
55 -- initialization at the start of execution. In the case
56 -- where Ada is the main program, this main program makes
57 -- a call to adainit at program startup.
60 pragma Export (C, adainit, "adainit");
62 -- This is the generated adafinal routine that performs
63 -- finalization at the end of execution. In the case where
64 -- Ada is the main program, this main program makes a call
65 -- to adafinal at program termination.
68 pragma Export (C, adafinal, "adafinal");
70 -- This routine is called at the start of execution. It is
71 -- a dummy routine that is used by the debugger to breakpoint
72 -- at the start of execution.
74 -- This is the actual generated main program (it would be
75 -- suppressed if the no main program switch were used). As
76 -- required by standard system conventions, this program has
77 -- the external name main.
81 argv : System.Address;
82 envp : System.Address)
84 pragma Export (C, main, "main");
86 -- The following set of constants give the version
87 -- identification values for every unit in the bound
88 -- partition. This identification is computed from all
89 -- dependent semantic units, and corresponds to the
90 -- string that would be returned by use of the
91 -- Body_Version or Version attributes.
93 -- The following Export pragmas export the version numbers
94 -- with symbolic names ending in B (for body) or S
95 -- (for spec) so that they can be located in a link. The
96 -- information provided here is sufficient to track down
97 -- the exact versions of units used in a given build.
99 type Version_32 is mod 2 ** 32;
100 u00001 : constant Version_32 := 16#8ad6e54a#;
101 pragma Export (C, u00001, "helloB");
102 u00002 : constant Version_32 := 16#fbff4c67#;
103 pragma Export (C, u00002, "system__standard_libraryB");
104 u00003 : constant Version_32 := 16#1ec6fd90#;
105 pragma Export (C, u00003, "system__standard_libraryS");
106 u00004 : constant Version_32 := 16#3ffc8e18#;
107 pragma Export (C, u00004, "adaS");
108 u00005 : constant Version_32 := 16#28f088c2#;
109 pragma Export (C, u00005, "ada__text_ioB");
110 u00006 : constant Version_32 := 16#f372c8ac#;
111 pragma Export (C, u00006, "ada__text_ioS");
112 u00007 : constant Version_32 := 16#2c143749#;
113 pragma Export (C, u00007, "ada__exceptionsB");
114 u00008 : constant Version_32 := 16#f4f0cce8#;
115 pragma Export (C, u00008, "ada__exceptionsS");
116 u00009 : constant Version_32 := 16#a46739c0#;
117 pragma Export (C, u00009, "ada__exceptions__last_chance_handlerB");
118 u00010 : constant Version_32 := 16#3aac8c92#;
119 pragma Export (C, u00010, "ada__exceptions__last_chance_handlerS");
120 u00011 : constant Version_32 := 16#1d274481#;
121 pragma Export (C, u00011, "systemS");
122 u00012 : constant Version_32 := 16#a207fefe#;
123 pragma Export (C, u00012, "system__soft_linksB");
124 u00013 : constant Version_32 := 16#467d9556#;
125 pragma Export (C, u00013, "system__soft_linksS");
126 u00014 : constant Version_32 := 16#b01dad17#;
127 pragma Export (C, u00014, "system__parametersB");
128 u00015 : constant Version_32 := 16#630d49fe#;
129 pragma Export (C, u00015, "system__parametersS");
130 u00016 : constant Version_32 := 16#b19b6653#;
131 pragma Export (C, u00016, "system__secondary_stackB");
132 u00017 : constant Version_32 := 16#b6468be8#;
133 pragma Export (C, u00017, "system__secondary_stackS");
134 u00018 : constant Version_32 := 16#39a03df9#;
135 pragma Export (C, u00018, "system__storage_elementsB");
136 u00019 : constant Version_32 := 16#30e40e85#;
137 pragma Export (C, u00019, "system__storage_elementsS");
138 u00020 : constant Version_32 := 16#41837d1e#;
139 pragma Export (C, u00020, "system__stack_checkingB");
140 u00021 : constant Version_32 := 16#93982f69#;
141 pragma Export (C, u00021, "system__stack_checkingS");
142 u00022 : constant Version_32 := 16#393398c1#;
143 pragma Export (C, u00022, "system__exception_tableB");
144 u00023 : constant Version_32 := 16#b33e2294#;
145 pragma Export (C, u00023, "system__exception_tableS");
146 u00024 : constant Version_32 := 16#ce4af020#;
147 pragma Export (C, u00024, "system__exceptionsB");
148 u00025 : constant Version_32 := 16#75442977#;
149 pragma Export (C, u00025, "system__exceptionsS");
150 u00026 : constant Version_32 := 16#37d758f1#;
151 pragma Export (C, u00026, "system__exceptions__machineS");
152 u00027 : constant Version_32 := 16#b895431d#;
153 pragma Export (C, u00027, "system__exceptions_debugB");
154 u00028 : constant Version_32 := 16#aec55d3f#;
155 pragma Export (C, u00028, "system__exceptions_debugS");
156 u00029 : constant Version_32 := 16#570325c8#;
157 pragma Export (C, u00029, "system__img_intB");
158 u00030 : constant Version_32 := 16#1ffca443#;
159 pragma Export (C, u00030, "system__img_intS");
160 u00031 : constant Version_32 := 16#b98c3e16#;
161 pragma Export (C, u00031, "system__tracebackB");
162 u00032 : constant Version_32 := 16#831a9d5a#;
163 pragma Export (C, u00032, "system__tracebackS");
164 u00033 : constant Version_32 := 16#9ed49525#;
165 pragma Export (C, u00033, "system__traceback_entriesB");
166 u00034 : constant Version_32 := 16#1d7cb2f1#;
167 pragma Export (C, u00034, "system__traceback_entriesS");
168 u00035 : constant Version_32 := 16#8c33a517#;
169 pragma Export (C, u00035, "system__wch_conB");
170 u00036 : constant Version_32 := 16#065a6653#;
171 pragma Export (C, u00036, "system__wch_conS");
172 u00037 : constant Version_32 := 16#9721e840#;
173 pragma Export (C, u00037, "system__wch_stwB");
174 u00038 : constant Version_32 := 16#2b4b4a52#;
175 pragma Export (C, u00038, "system__wch_stwS");
176 u00039 : constant Version_32 := 16#92b797cb#;
177 pragma Export (C, u00039, "system__wch_cnvB");
178 u00040 : constant Version_32 := 16#09eddca0#;
179 pragma Export (C, u00040, "system__wch_cnvS");
180 u00041 : constant Version_32 := 16#6033a23f#;
181 pragma Export (C, u00041, "interfacesS");
182 u00042 : constant Version_32 := 16#ece6fdb6#;
183 pragma Export (C, u00042, "system__wch_jisB");
184 u00043 : constant Version_32 := 16#899dc581#;
185 pragma Export (C, u00043, "system__wch_jisS");
186 u00044 : constant Version_32 := 16#10558b11#;
187 pragma Export (C, u00044, "ada__streamsB");
188 u00045 : constant Version_32 := 16#2e6701ab#;
189 pragma Export (C, u00045, "ada__streamsS");
190 u00046 : constant Version_32 := 16#db5c917c#;
191 pragma Export (C, u00046, "ada__io_exceptionsS");
192 u00047 : constant Version_32 := 16#12c8cd7d#;
193 pragma Export (C, u00047, "ada__tagsB");
194 u00048 : constant Version_32 := 16#ce72c228#;
195 pragma Export (C, u00048, "ada__tagsS");
196 u00049 : constant Version_32 := 16#c3335bfd#;
197 pragma Export (C, u00049, "system__htableB");
198 u00050 : constant Version_32 := 16#99e5f76b#;
199 pragma Export (C, u00050, "system__htableS");
200 u00051 : constant Version_32 := 16#089f5cd0#;
201 pragma Export (C, u00051, "system__string_hashB");
202 u00052 : constant Version_32 := 16#3bbb9c15#;
203 pragma Export (C, u00052, "system__string_hashS");
204 u00053 : constant Version_32 := 16#807fe041#;
205 pragma Export (C, u00053, "system__unsigned_typesS");
206 u00054 : constant Version_32 := 16#d27be59e#;
207 pragma Export (C, u00054, "system__val_lluB");
208 u00055 : constant Version_32 := 16#fa8db733#;
209 pragma Export (C, u00055, "system__val_lluS");
210 u00056 : constant Version_32 := 16#27b600b2#;
211 pragma Export (C, u00056, "system__val_utilB");
212 u00057 : constant Version_32 := 16#b187f27f#;
213 pragma Export (C, u00057, "system__val_utilS");
214 u00058 : constant Version_32 := 16#d1060688#;
215 pragma Export (C, u00058, "system__case_utilB");
216 u00059 : constant Version_32 := 16#392e2d56#;
217 pragma Export (C, u00059, "system__case_utilS");
218 u00060 : constant Version_32 := 16#84a27f0d#;
219 pragma Export (C, u00060, "interfaces__c_streamsB");
220 u00061 : constant Version_32 := 16#8bb5f2c0#;
221 pragma Export (C, u00061, "interfaces__c_streamsS");
222 u00062 : constant Version_32 := 16#6db6928f#;
223 pragma Export (C, u00062, "system__crtlS");
224 u00063 : constant Version_32 := 16#4e6a342b#;
225 pragma Export (C, u00063, "system__file_ioB");
226 u00064 : constant Version_32 := 16#ba56a5e4#;
227 pragma Export (C, u00064, "system__file_ioS");
228 u00065 : constant Version_32 := 16#b7ab275c#;
229 pragma Export (C, u00065, "ada__finalizationB");
230 u00066 : constant Version_32 := 16#19f764ca#;
231 pragma Export (C, u00066, "ada__finalizationS");
232 u00067 : constant Version_32 := 16#95817ed8#;
233 pragma Export (C, u00067, "system__finalization_rootB");
234 u00068 : constant Version_32 := 16#52d53711#;
235 pragma Export (C, u00068, "system__finalization_rootS");
236 u00069 : constant Version_32 := 16#769e25e6#;
237 pragma Export (C, u00069, "interfaces__cB");
238 u00070 : constant Version_32 := 16#4a38bedb#;
239 pragma Export (C, u00070, "interfaces__cS");
240 u00071 : constant Version_32 := 16#07e6ee66#;
241 pragma Export (C, u00071, "system__os_libB");
242 u00072 : constant Version_32 := 16#d7b69782#;
243 pragma Export (C, u00072, "system__os_libS");
244 u00073 : constant Version_32 := 16#1a817b8e#;
245 pragma Export (C, u00073, "system__stringsB");
246 u00074 : constant Version_32 := 16#639855e7#;
247 pragma Export (C, u00074, "system__stringsS");
248 u00075 : constant Version_32 := 16#e0b8de29#;
249 pragma Export (C, u00075, "system__file_control_blockS");
250 u00076 : constant Version_32 := 16#b5b2aca1#;
251 pragma Export (C, u00076, "system__finalization_mastersB");
252 u00077 : constant Version_32 := 16#69316dc1#;
253 pragma Export (C, u00077, "system__finalization_mastersS");
254 u00078 : constant Version_32 := 16#57a37a42#;
255 pragma Export (C, u00078, "system__address_imageB");
256 u00079 : constant Version_32 := 16#bccbd9bb#;
257 pragma Export (C, u00079, "system__address_imageS");
258 u00080 : constant Version_32 := 16#7268f812#;
259 pragma Export (C, u00080, "system__img_boolB");
260 u00081 : constant Version_32 := 16#e8fe356a#;
261 pragma Export (C, u00081, "system__img_boolS");
262 u00082 : constant Version_32 := 16#d7aac20c#;
263 pragma Export (C, u00082, "system__ioB");
264 u00083 : constant Version_32 := 16#8365b3ce#;
265 pragma Export (C, u00083, "system__ioS");
266 u00084 : constant Version_32 := 16#6d4d969a#;
267 pragma Export (C, u00084, "system__storage_poolsB");
268 u00085 : constant Version_32 := 16#e87cc305#;
269 pragma Export (C, u00085, "system__storage_poolsS");
270 u00086 : constant Version_32 := 16#e34550ca#;
271 pragma Export (C, u00086, "system__pool_globalB");
272 u00087 : constant Version_32 := 16#c88d2d16#;
273 pragma Export (C, u00087, "system__pool_globalS");
274 u00088 : constant Version_32 := 16#9d39c675#;
275 pragma Export (C, u00088, "system__memoryB");
276 u00089 : constant Version_32 := 16#445a22b5#;
277 pragma Export (C, u00089, "system__memoryS");
278 u00090 : constant Version_32 := 16#6a859064#;
279 pragma Export (C, u00090, "system__storage_pools__subpoolsB");
280 u00091 : constant Version_32 := 16#e3b008dc#;
281 pragma Export (C, u00091, "system__storage_pools__subpoolsS");
282 u00092 : constant Version_32 := 16#63f11652#;
283 pragma Export (C, u00092, "system__storage_pools__subpools__finalizationB");
284 u00093 : constant Version_32 := 16#fe2f4b3a#;
285 pragma Export (C, u00093, "system__storage_pools__subpools__finalizationS");
287 -- BEGIN ELABORATION ORDER
291 -- system.case_util%s
292 -- system.case_util%b
300 -- system.parameters%s
301 -- system.parameters%b
303 -- interfaces.c_streams%s
304 -- interfaces.c_streams%b
305 -- system.standard_library%s
306 -- system.exceptions_debug%s
307 -- system.exceptions_debug%b
308 -- system.storage_elements%s
309 -- system.storage_elements%b
310 -- system.stack_checking%s
311 -- system.stack_checking%b
312 -- system.string_hash%s
313 -- system.string_hash%b
318 -- system.traceback_entries%s
319 -- system.traceback_entries%b
321 -- system.soft_links%s
322 -- system.unsigned_types%s
335 -- ada.exceptions.last_chance_handler%s
336 -- ada.exceptions.last_chance_handler%b
337 -- system.address_image%s
338 -- system.exception_table%s
339 -- system.exception_table%b
340 -- ada.io_exceptions%s
345 -- system.exceptions%s
346 -- system.exceptions%b
347 -- system.exceptions.machine%s
348 -- system.finalization_root%s
349 -- system.finalization_root%b
350 -- ada.finalization%s
351 -- ada.finalization%b
352 -- system.storage_pools%s
353 -- system.storage_pools%b
354 -- system.finalization_masters%s
355 -- system.storage_pools.subpools%s
356 -- system.storage_pools.subpools.finalization%s
357 -- system.storage_pools.subpools.finalization%b
360 -- system.standard_library%b
361 -- system.pool_global%s
362 -- system.pool_global%b
363 -- system.file_control_block%s
365 -- system.secondary_stack%s
367 -- system.storage_pools.subpools%b
368 -- system.finalization_masters%b
371 -- system.soft_links%b
373 -- system.secondary_stack%b
374 -- system.address_image%b
375 -- system.traceback%s
377 -- system.traceback%b
381 -- END ELABORATION ORDER
388 -- The following source file name pragmas allow the generated file
389 -- names to be unique for different main programs. They are needed
390 -- since the package name will always be Ada_Main.
392 pragma Source_File_Name (ada_main, Spec_File_Name => "b~hello.ads");
393 pragma Source_File_Name (ada_main, Body_File_Name => "b~hello.adb");
395 pragma Suppress (Overflow_Check);
398 -- Generated package body for Ada_Main starts here
400 package body ada_main is
401 pragma Warnings (Off);
403 -- These values are reference counter associated to units which have
404 -- been elaborated. It is also used to avoid elaborating the
407 E72 : Short_Integer; pragma Import (Ada, E72, "system__os_lib_E");
408 E13 : Short_Integer; pragma Import (Ada, E13, "system__soft_links_E");
409 E23 : Short_Integer; pragma Import (Ada, E23, "system__exception_table_E");
410 E46 : Short_Integer; pragma Import (Ada, E46, "ada__io_exceptions_E");
411 E48 : Short_Integer; pragma Import (Ada, E48, "ada__tags_E");
412 E45 : Short_Integer; pragma Import (Ada, E45, "ada__streams_E");
413 E70 : Short_Integer; pragma Import (Ada, E70, "interfaces__c_E");
414 E25 : Short_Integer; pragma Import (Ada, E25, "system__exceptions_E");
415 E68 : Short_Integer; pragma Import (Ada, E68, "system__finalization_root_E");
416 E66 : Short_Integer; pragma Import (Ada, E66, "ada__finalization_E");
417 E85 : Short_Integer; pragma Import (Ada, E85, "system__storage_pools_E");
418 E77 : Short_Integer; pragma Import (Ada, E77, "system__finalization_masters_E");
419 E91 : Short_Integer; pragma Import (Ada, E91, "system__storage_pools__subpools_E");
420 E87 : Short_Integer; pragma Import (Ada, E87, "system__pool_global_E");
421 E75 : Short_Integer; pragma Import (Ada, E75, "system__file_control_block_E");
422 E64 : Short_Integer; pragma Import (Ada, E64, "system__file_io_E");
423 E17 : Short_Integer; pragma Import (Ada, E17, "system__secondary_stack_E");
424 E06 : Short_Integer; pragma Import (Ada, E06, "ada__text_io_E");
426 Local_Priority_Specific_Dispatching : constant String := "";
427 Local_Interrupt_States : constant String := "";
429 Is_Elaborated : Boolean := False;
431 procedure finalize_library is
436 pragma Import (Ada, F1, "ada__text_io__finalize_spec");
444 pragma Import (Ada, F2, "system__file_io__finalize_body");
451 pragma Import (Ada, F3, "system__file_control_block__finalize_spec");
459 pragma Import (Ada, F4, "system__pool_global__finalize_spec");
465 pragma Import (Ada, F5, "system__storage_pools__subpools__finalize_spec");
471 pragma Import (Ada, F6, "system__finalization_masters__finalize_spec");
476 procedure Reraise_Library_Exception_If_Any;
477 pragma Import (Ada, Reraise_Library_Exception_If_Any, "__gnat_reraise_library_exception_if_any");
479 Reraise_Library_Exception_If_Any;
481 end finalize_library;
489 Main_Priority : Integer;
490 pragma Import (C, Main_Priority, "__gl_main_priority");
491 Time_Slice_Value : Integer;
492 pragma Import (C, Time_Slice_Value, "__gl_time_slice_val");
493 WC_Encoding : Character;
494 pragma Import (C, WC_Encoding, "__gl_wc_encoding");
495 Locking_Policy : Character;
496 pragma Import (C, Locking_Policy, "__gl_locking_policy");
497 Queuing_Policy : Character;
498 pragma Import (C, Queuing_Policy, "__gl_queuing_policy");
499 Task_Dispatching_Policy : Character;
500 pragma Import (C, Task_Dispatching_Policy, "__gl_task_dispatching_policy");
501 Priority_Specific_Dispatching : System.Address;
502 pragma Import (C, Priority_Specific_Dispatching, "__gl_priority_specific_dispatching");
503 Num_Specific_Dispatching : Integer;
504 pragma Import (C, Num_Specific_Dispatching, "__gl_num_specific_dispatching");
506 pragma Import (C, Main_CPU, "__gl_main_cpu");
507 Interrupt_States : System.Address;
508 pragma Import (C, Interrupt_States, "__gl_interrupt_states");
509 Num_Interrupt_States : Integer;
510 pragma Import (C, Num_Interrupt_States, "__gl_num_interrupt_states");
511 Unreserve_All_Interrupts : Integer;
512 pragma Import (C, Unreserve_All_Interrupts, "__gl_unreserve_all_interrupts");
513 Detect_Blocking : Integer;
514 pragma Import (C, Detect_Blocking, "__gl_detect_blocking");
515 Default_Stack_Size : Integer;
516 pragma Import (C, Default_Stack_Size, "__gl_default_stack_size");
517 Leap_Seconds_Support : Integer;
518 pragma Import (C, Leap_Seconds_Support, "__gl_leap_seconds_support");
520 procedure Runtime_Initialize;
521 pragma Import (C, Runtime_Initialize, "__gnat_runtime_initialize");
523 Finalize_Library_Objects : No_Param_Proc;
524 pragma Import (C, Finalize_Library_Objects, "__gnat_finalize_library_objects");
526 -- Start of processing for adainit
530 -- Record various information for this partition. The values
531 -- are derived by the binder from information stored in the ali
532 -- files by the compiler.
534 if Is_Elaborated then
537 Is_Elaborated := True;
539 Time_Slice_Value := -1;
541 Locking_Policy := ' ';
542 Queuing_Policy := ' ';
543 Task_Dispatching_Policy := ' ';
544 Priority_Specific_Dispatching :=
545 Local_Priority_Specific_Dispatching'Address;
546 Num_Specific_Dispatching := 0;
548 Interrupt_States := Local_Interrupt_States'Address;
549 Num_Interrupt_States := 0;
550 Unreserve_All_Interrupts := 0;
551 Detect_Blocking := 0;
552 Default_Stack_Size := -1;
553 Leap_Seconds_Support := 0;
557 Finalize_Library_Objects := finalize_library'access;
559 -- Now we have the elaboration calls for all units in the partition.
560 -- The Elab_Spec and Elab_Body attributes generate references to the
561 -- implicit elaboration procedures generated by the compiler for
562 -- each unit that requires elaboration. Increment a counter of
563 -- reference for each unit.
565 System.Soft_Links'Elab_Spec;
566 System.Exception_Table'Elab_Body;
568 Ada.Io_Exceptions'Elab_Spec;
571 Ada.Streams'Elab_Spec;
573 Interfaces.C'Elab_Spec;
574 System.Exceptions'Elab_Spec;
576 System.Finalization_Root'Elab_Spec;
578 Ada.Finalization'Elab_Spec;
580 System.Storage_Pools'Elab_Spec;
582 System.Finalization_Masters'Elab_Spec;
583 System.Storage_Pools.Subpools'Elab_Spec;
584 System.Pool_Global'Elab_Spec;
586 System.File_Control_Block'Elab_Spec;
588 System.File_Io'Elab_Body;
591 System.Finalization_Masters'Elab_Body;
596 System.Soft_Links'Elab_Body;
598 System.Os_Lib'Elab_Body;
600 System.Secondary_Stack'Elab_Body;
602 Ada.Text_Io'Elab_Spec;
603 Ada.Text_Io'Elab_Body;
611 procedure adafinal is
612 procedure s_stalib_adafinal;
613 pragma Import (C, s_stalib_adafinal, "system__standard_library__adafinal");
615 procedure Runtime_Finalize;
616 pragma Import (C, Runtime_Finalize, "__gnat_runtime_finalize");
619 if not Is_Elaborated then
622 Is_Elaborated := False;
627 -- We get to the main program of the partition by using
628 -- pragma Import because if we try to with the unit and
629 -- call it Ada style, then not only do we waste time
630 -- recompiling it, but also, we don't really know the right
631 -- switches (e.g.@: identifier character set) to be used
634 procedure Ada_Main_Program;
635 pragma Import (Ada, Ada_Main_Program, "_ada_hello");
641 -- main is actually a function, as in the ANSI C standard,
642 -- defined to return the exit status. The three parameters
643 -- are the argument count, argument values and environment
648 argv : System.Address;
649 envp : System.Address)
652 -- The initialize routine performs low level system
653 -- initialization using a standard library routine which
654 -- sets up signal handling and performs any other
655 -- required setup. The routine can be found in file
658 procedure initialize;
659 pragma Import (C, initialize, "__gnat_initialize");
661 -- The finalize routine performs low level system
662 -- finalization using a standard library routine. The
663 -- routine is found in file a-final.c and in the standard
664 -- distribution is a dummy routine that does nothing, so
665 -- really this is a hook for special user finalization.
668 pragma Import (C, finalize, "__gnat_finalize");
670 -- The following is to initialize the SEH exceptions
672 SEH : aliased array (1 .. 2) of Integer;
674 Ensure_Reference : aliased System.Address := Ada_Main_Program_Name'Address;
675 pragma Volatile (Ensure_Reference);
677 -- Start of processing for main
680 -- Save global variables
686 -- Call low level system initialization
688 Initialize (SEH'Address);
690 -- Call our generated Ada initialization routine
694 -- Now we call the main program of the partition
698 -- Perform Ada finalization
702 -- Perform low level system finalization
706 -- Return the proper exit status
707 return (gnat_exit_status);
710 -- This section is entirely comments, so it has no effect on the
711 -- compilation of the Ada_Main package. It provides the list of
712 -- object files and linker options, as well as some standard
713 -- libraries needed for the link. The gnatlink utility parses
714 -- this b~hello.adb file to read these comment lines to generate
715 -- the appropriate command line arguments for the call to the
716 -- system linker. The BEGIN/END lines are used for sentinels for
717 -- this parsing operation.
719 -- The exact file names will of course depend on the environment,
720 -- host/target and location of files on the host system.
722 -- BEGIN Object file/option list
725 -- -L/usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/
726 -- /usr/local/gnat/lib/gcc-lib/i686-pc-linux-gnu/2.8.1/adalib/libgnat.a
727 -- END Object file/option list
732 The Ada code in the above example is exactly what is generated by the
733 binder. We have added comments to more clearly indicate the function
734 of each part of the generated `Ada_Main` package.
736 The code is standard Ada in all respects, and can be processed by any
737 tools that handle Ada. In particular, it is possible to use the debugger
738 in Ada mode to debug the generated `Ada_Main` package. For example,
739 suppose that for reasons that you do not understand, your program is crashing
740 during elaboration of the body of `Ada.Text_IO`. To locate this bug,
741 you can place a breakpoint on the call:
745 Ada.Text_Io'Elab_Body;
747 and trace the elaboration routine for this package to find out where
748 the problem might be (more usually of course you would be debugging
749 elaboration code in your own application).