[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Classes in C++ have ’constructors’ and ’destructors’. These
are functions which are called automatically by the language
whenever data of a class is created or destroyed. Class data
which is static data may also be have a type which requires
’construction’, the contructor must be called before the data
can be referenced, so the contructor must be called before the
program begins.
The common solution to this problem is for the compiler to
call a magic function as the first statement main
.
This magic function, (often called __main
) runs around
calling the constructors for all the things needing it.
With COFF the compile has a bargain with the linker et al.
All constructors are given strange names, for example
__GLOBAL__$I$foo
might be the label of a contructor for
the class foo. The solution on unfortunate systems
(most system V machines) is to perform a partial link on all
the .o files, do an nm
on the result, run awk
or some
such over the result looking for strange __GLOBAL__$
symbols, generate a C program from this, compile it and link
with the partially linked input. This process is usually
called collect
.
Some versions of a.out
use something called the
set_vector
mechanism. The constructor symbols are output
from the compiler with a special stab code saying that they
are constructors, and the linker can deal with them directly.
BFD allows applications (ie the linker) to deal with
constructor information independently of their external
implimentation by providing a set of entry points for the
indiviual object back ends to call which maintains a database
of the contructor information. The application can
interrogate the database to find out what it wants. The
construction data essential for the linker to be able to
perform its job are:
SEC_CONSTRUCTOR
) which the linker notices and do with
what it wants.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
bfd_constructor_entry
Synopsis
void bfd_constructor_entry(bfd *abfd, asymbol **symbol_ptr_ptr, CONST char*type);
Description
This function is called with an a symbol describing the
function to be called, an string which descibes the xtor type,
eg something like "CTOR" or "DTOR" would be fine. And the bfd
which owns the function. Its duty is to create a section
called "CTOR" or "DTOR" or whatever if the bfd doesn’t already
have one, and grow a relocation table for the entry points as
they accumulate.
[Top] | [Contents] | [Index] | [ ? ] |
This document was generated on December 11, 2024 using texi2html 5.0.
The buttons in the navigation panels have the following meaning:
Button | Name | Go to | From 1.2.3 go to |
---|---|---|---|
[ << ] | FastBack | Beginning of this chapter or previous chapter | 1 |
[ < ] | Back | Previous section in reading order | 1.2.2 |
[ Up ] | Up | Up section | 1.2 |
[ > ] | Forward | Next section in reading order | 1.2.4 |
[ >> ] | FastForward | Next chapter | 2 |
[Top] | Top | Cover (top) of document | |
[Contents] | Contents | Table of contents | |
[Index] | Index | Index | |
[ ? ] | About | About (help) |
where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:
This document was generated on December 11, 2024 using texi2html 5.0.