This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: ld and export lists
- From: Nick Clifton <nickc at redhat dot com>
- To: Robert Schweikert <rjschwei at cox dot net>
- Cc: binutils at sources dot redhat dot com
- Date: 13 Jan 2003 17:48:51 +0000
- Subject: Re: ld and export lists
- References: <3E208432.4010905@cox.net>
Hi Robert,
> How does one define an export list for a shared library using
> ld.
By using a DEF file.
Have a look at the information in the ld.texinfo file for more details
about this. (You should get a copy of the latest version from the CVS
repository, since this section has seen a lot of work in the last few
months). In particular in the WIN32 section of the Machine Dependent
Features section it says this:
_exporting DLL symbols_
The cygwin/mingw `ld' has several ways to export symbols for dll's.
_using auto-export functionality_
By default `ld' exports symbols with the auto-export
functionality, which is controlled by the following command
line options:
--export-all-symbols [This is the default]
--exclude-symbols
--exclude-libs
_using a DEF file_
Another way of exporting symbols is using a DEF file. A DEF
file is an ASCII file containing definitions of symbols which
should be exported when a dll is created. Usually it is
named `<dll name>.def' and is added as any other object file
to the linker's command line.
gcc -o <output> <objectfiles> <dll name>.def
Here is an example of a DEF file for a shared library called
`xyz.dll':
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, `ld' is able to create a DEF file
with the `--output-def <file>' command line option.
Cheers
Nick