Red Hat ENTERPRISE LINUX 3 - USING ID Using Instructions page 66

Using ld, the gnu linker
Hide thumbs Also See for ENTERPRISE LINUX 3 - USING ID:
Table of Contents

Advertisement

62
-exclude-libs
If, however,
default auto-export behavior will be disabled if either of the following are true:
A DEF file is used.
Any symbol in any object file was marked with the __declspec(dllexport) attribute.
using a DEF file
Another way of exporting symbols is using a DEF file. A DEF file is an ASCII file con-
taining definitions of symbols which should be exported when a dll is created. Usually it
is named

line. The file's name must end in
gcc -o

Using a DEF file turns off the normal auto-export
-export-all-symbols
Here is an example of a DEF file for a shared library called
LIBRARY "xyz.dll" BASE=0x10000000
EXPORTS
foo
bar
_bar = bar
This example defines a base address and three symbols. The third symbol is an alias for the
second. For the complete format specification see ld/deffilep.y in the binutils sources.
While linking a shared dll,
command line option.
Using decorations
Another way of marking symbols for export is to modify the source code itself, so that when
building the DLL each symbol to be exported is declared as:
__declspec(dllexport) int a_variable
__declspec(dllexport) void a_function(int with_args)
All such symbols will be exported from the DLL. If, however, any of the object files in
the DLL contain symbols decorated in this way, then the normal auto-export behavior is
disabled, unless the
Note that object files that wish to access these symbols must not decorate them with dllex-
port. Instead, they should use dllimport, instead:
__declspec(dllimport) int a_variable
__declspec(dllimport) void a_function(int with_args)
This complicates the structure of library header files, because when included by the library
itself the header must declare the variables and functions as dllexport, but when included by
client code the header must declare them as dllimport. There are a number of idioms that are
typically used to do this; often client code can omit the __declspec() declaration completely.
See
-enable-auto-import
automatic data imports
The standard Windows dll format supports data imports from dlls only by adding special
decorations (dllimport/dllexport), which let the compiler produce specific assembler instructions
to deal with this issue. This increases the effort necessary to port existing Un*x code to these
platforms, especially for large c++ libraries and applications. The auto-import feature, which
-export-all-symbols
and is added as any other object file to the linker's command
dll name .def
output
objectfiles
! 
option is also used.
is able to create a DEF file with the
ld
-export-all-symbols
and
Chapter 5. Machine Dependent Features
is not given explicitly on the command line, then the
or
.
.def
.DEF
dll name .def
" 
option is also used.
automatic data imports
behavior,
unless the
:
xyz.dll
-output-def
for more imformation.
file


Advertisement

Table of Contents
loading

This manual is also suitable for:

Enterprise linux 3

Table of Contents