This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: MUCH faster cygwin.dll


In gnu-win32 vischne@ibm.net writes:

>Gee guys, noone talks about the `-fPIC' option of gcc.  Using position-
>independent code means never having to relocate.  Or does it?

Well, yes, it does.

The gcc -fPIC option is intended for use with an SVR4 style dynamic
loader, as is used on ELF and SunOS systems.  The SVR4 dynamic loader
serves much the same function as the Windows loader which handles the
.reloc section.  There actually is relocation involved.

The changes made by using -fPIC are related to the advantages ELF
shared libraries have over Windows DLLs: you can override any function
in an ELF shared library with a function in the main executable (e.g.,
you can arrange for a shared library to call your version of malloc,
even if the library provides its own version of malloc), and you can
use global variables in a shared library without any of this
declspec(dllimport)/declspec(dllexport) nonsense.

Mind you, those advantages of ELF shared libraries work even if you
don't use -fPIC.  However, if you do use -fPIC, the dynamic loader
will be able to process your shared library more efficiently.

In any case, -fPIC will not help in any way on Windows.

Ian
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]