From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: How do package body initializers get run in GNU Ada?
Date: Sat, 2 Nov 2002 16:00:47 GMT
Date: 2002-11-02T16:00:47+00:00 [thread overview]
Message-ID: <wccof98ufkg.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 3DC31EBB.2050809@math.jpl.nasa.gov
Van Snyder <vsnyder@math.jpl.nasa.gov> writes:
> In GNU Ada, what mechanism is used to cause execution of package
> body initializers, i.e., the code between begin and end in a
> package body?
>
> Is it done using some kind of back-patching/overlaying done
> by an otherwise garden-variety ld, by special features added
> to ld to support Ada, by first-time flags at the entries
> to procedures, or by something else?
I believe most Ada compilers do not use such features of the linker.
Instead, they provide a program called the "builder" or "prelinker".
The compiler generates a procedure for each compilation unit,
containing the elaboration code. The builder constructs a "main" that
calls all those elaboration procedures in a correct order, and then
calls the user-defined main procedure. The builder normally then
invokes the system linker (e.g. 'ld'), with all that code, telling it
the automatically constructed "main" is the program's entry point (*not*
the user-defined main procedure).
Note that the elaboration code for a package body is not just the code
between "begin" and "end". It also includes initialization code for all
kinds of declarations. E.g., if you say "X: Integer := Func(...);", the
elaboration code must call Func and initialize X to the result.
Similarly, package specs also have elaboration code.
- Bob
next prev parent reply other threads:[~2002-11-02 16:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-02 0:39 How do package body initializers get run in GNU Ada? Van Snyder
2002-11-02 1:23 ` Jeffrey Carter
2002-11-02 1:28 ` sk
2002-11-04 15:20 ` Stephen Leake
2002-11-05 1:03 ` sk
2002-11-02 16:00 ` Robert A Duff [this message]
2002-11-03 2:45 ` David Marceau
2002-11-03 11:37 ` Romanov
2002-11-03 20:14 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox