delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/02/21/18:56:33

From: ian AT cygnus DOT com
Subject: Re: MUCH faster cygwin.dll
21 Feb 1998 18:56:33 -0800 :
Message-ID: <199802220239.VAA04476.cygnus.gnu-win32@tweedledumb.cygnus.com>
References: <199802201638 DOT QAA93664 AT out5 DOT ibm DOT net>
To: vischne AT ibm DOT net
Cc: gnu-win32 AT cygnus DOT com

In gnu-win32 vischne AT ibm DOT 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 AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019