comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: text tools
Date: Wed, 21 Oct 2009 01:06:14 -0700 (PDT)
Date: 2009-10-21T01:06:14-07:00	[thread overview]
Message-ID: <29df0927-1d3d-409e-8ee4-b25730e6238c@e34g2000vbm.googlegroups.com> (raw)
In-Reply-To: uulsd5te6lct990dulaaamplv6c2tpe24o@4ax.com

Rob Solomon wrote:
> Now I need to understand more about how this works.

In a nutshell:

- The compiler (gcc-4.3) reads the Ada or C source files and produces
one object file per compilation unit.
- The archiver (ar) takes object files and concatenates them together
into a static library (lib*.a)
- The linker (ld) takes object files and produces a shared library
(lib*.so).  The object files for a shared library must have been
compiled with the option -fPIC to produce Position-Independent Code.
- The linker (ld) then takes object files, static libraries and shared
libraries to produce an executable file. It works this way:

1. It copies all the object files into the executable, adjusting
addresses as necessary.
2. If the object files in the executable call subprograms in the
static libraries, it copies the corresponding object files from the
static libraries into the executable, adjusting addresses as
necessary.
3. If the object files in the executable call subprograms in the
shared libraries, it does NOT copy them; instead, it inserts stub
subprograms into the executable.
4. When the program runs, the stubs call into the shared libraries.

gnatmake with a project file automates this. It decides when to call
gcc-4.3 (i.e. which Ada files need recompiling), then it calls
gnatbind and finally gnatlink, passing it all the static and shared
libraries as parameters. gnatlink in turn calls ld.

In your project, you do not produce any library, so you do not call ar
or ld explicitly. This was done on the build machine that produced the
binary packages libtexttools-dev and libtexttools2.0.5. What you do is
link the shared libraries into your executable, i.e. insert the stubs
into your executable. You can try:

ldd basic

to see which shared libraries "basic" will load at run time.

--
Ludovic Brenta.



      reply	other threads:[~2009-10-21  8:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-18 23:55 text tools Rob Solomon
2009-10-19  8:09 ` Stephen Leake
2009-10-19  8:12 ` Ludovic Brenta
2009-10-19 21:27   ` Rob Solomon
2009-10-19 22:06     ` Ludovic Brenta
2009-10-20  0:13       ` Rob Solomon
2009-10-20  2:25   ` Rob Solomon
2009-10-20  9:28     ` Ludovic Brenta
2009-10-20 17:49       ` Ludovic Brenta
2009-10-20 23:14         ` Rob Solomon
2009-10-21  0:39           ` Rob Solomon
2009-10-21  8:06             ` Ludovic Brenta [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox