Option fPIC not supported ?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Option fPIC not supported ?

John Hookeer

Hello,

It seems that the PIC (Position Independent Code) option of gcc is not supported on Windows. I understand that Windows does not need this functionality since it uses relocation table in dll, but I was wondering why is this option not available? Is it only because it is useless? Or is there any real problem that makes it unavailable?
It tried with gcc from cygwin and mingw, with option fPIC, fpic, fPIE and fpie:
C:\>gcc.exe main.c -o main -fpic
main.c:1: warning: -fpic ignored for target (all code is position independent)

Thanks.


     


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
--
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: Option fPIC not supported ?

ColdShine
2009/3/20 John Hookeer <[hidden email]>:
> It seems that the PIC (Position Independent Code) option of gcc is not supported on Windows. I understand that Windows does not need this functionality since it uses relocation table in dll, but I was wondering why is this option not available? Is it only because it is useless? Or is there any real problem that makes it unavailable?
> It tried with gcc from cygwin and mingw, with option fPIC, fpic, fPIE and fpie:
> C:\>gcc.exe main.c -o main -fpic
> main.c:1: warning: -fpic ignored for target (all code is position independent)

The last five words of the error message are quite self-explanatory...
You cannot generate non-pic code, so why bother providing an option
*not* to do so?

--
CS

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
--
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: Option fPIC not supported ?

John Hookeer

Thank you for your answer. In fact, generated code is not really PIC since it contains hardcoded addresses:
For example, if you compile the following function call:
printf("Hello !\n");
the generated assembly is:
movl   $0x403000,(%esp)
call   401898 <_printf>

So the address of “Hello” string is hardcoded

On Linux, the "fPIC" option generates specific code: it calls a function to get eip and uses this value to compute address of the string, so it never uses a hardcoded address.

I know Linux and Windows work differently and that Windows does not really need this kind of things (since it uses relocation table), but my question is: is there however an option to generate such code on Windows with mingw ?

Thanks again.




----- Original Message ----
From: ColdShine <[hidden email]>
To: MinGW Users List <[hidden email]>
Sent: Saturday, March 21, 2009 11:46:13 AM
Subject: Re: [Mingw-users] Option fPIC not supported ?

2009/3/20 John Hookeer <[hidden email]>:
> It seems that the PIC (Position Independent Code) option of gcc is not supported on Windows. I understand that Windows does not need this functionality since it uses relocation table in dll, but I was wondering why is this option not available? Is it only because it is useless? Or is there any real problem that makes it unavailable?
> It tried with gcc from cygwin and mingw, with option fPIC, fpic, fPIE and fpie:
> C:\>gcc.exe main.c -o main -fpic
> main.c:1: warning: -fpic ignored for target (all code is position independent)

The last five words of the error message are quite self-explanatory...
You cannot generate non-pic code, so why bother providing an option
*not* to do so?

--
CS

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
--
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users



     


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
--
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: Option fPIC not supported ?

Ross Ridge
In reply to this post by John Hookeer
John Hookeer writes:
>I know Linux and Windows work differently and that Windows does not
>really need this kind of things (since it uses relocation table)...

Effectively that relocation table makes the code position independent.

>... but my question is: is there however an option to generate such code
>on Windows with mingw ?

No, there is no compiler, assembler, linker or runtime support for
"Linux-style" PIC code in the MinGW tools.

You can either pick a good base address for your DLL so it never needs
to be relocated, or just ignore the issue.  The cost of relocating a
DLL in terms ot time and memory is insignificant these days.

                                        Ross Ridge


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
--
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users