This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Non-relocatable DLLs and GCC -shared
- From: Pascal Obry <p dot obry at wanadoo dot fr>
- To: Danny Smith <danny_r_smith_2001 at yahoo dot co dot nz>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 21 Jul 2003 22:21:41 +0200
- Subject: Re: Non-relocatable DLLs and GCC -shared
- References: <20030721104013.63320.qmail@web21401.mail.yahoo.com>
Danny,
Thanks for your answer.
> gcc -mdll -ofoo.dll --Wl,-out-implib,libfoo.a foo.def foo.c
It seems to me that the DLL built this way are somehow relocatable. What I
have done is to build 2 DLLs. Both are using the same ImageBase and yet a
program using both can be started. The program should not be able to start
and reports and error as the second DLL should fails to load properly.
Am I missing something ?
Here is what I have tried:
file: main.c
<<
#include <stdio.h>
extern void fct1 (void);
extern void fct2 (void);
int
main (void)
{
printf ("main\n");
fct1();
fct2();
}
>>
file: code1.c
<<
#include <stdio.h>
void
fct1 (void)
{
printf ("fct1\n");
}
>>
file: code2.c
<<
#include <stdio.h>
void
fct2 (void)
{
printf ("fct2\n");
}
>>
file: code1.def
<<
EXPORTS
fct1
>>
file: code2.def
<<
EXPORTS
fct2
>>
$ gcc -mdll -o dll1-nr.dll -Wl,--out-implib,libdll1.a code1.def code1.c
$ gcc -mdll -o dll2-nr.dll -Wl,--out-implib,libdll2.a code2.def code2.c
$ gcc -o main-nr main.c libdll1.a libdll2.a
$ ./main-nr
To build a non-relocatable DLL, the procedure was to build an .exp file,
doing this will build a non-relocatable DLL:
$ dlltool --def code1.def --dllname dll1-nr.dll --output-lib libdll1.a --output-exp dll1.exp
$ dlltool --def code2.def --dllname dll2-nr.dll --output-lib libdll2.a --output-exp dll2.exp
$ gcc -mdll -o dll1-nr.dll dll1.exp code1.c
$ gcc -mdll -o dll2-nr.dll dll2.exp code2.c
$ gcc -o main-nr main.c libdll1.a libdll2.a
$ ./main-nr
But since dlltool is called "obsolete", what should be used instead ?
Thanks,
Pascal.
--
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://perso.wanadoo.fr/pascal.obry
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595