This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: What does -DPIC linker flag mean
- From: Brian Dessent <brian at dessent dot net>
- To: sameer at nextbitcpu dot com
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 16 Oct 2006 03:53:30 -0700
- Subject: Re: What does -DPIC linker flag mean
- References: <45335092.8070202@nextbitcpu.com>
- Reply-to: gcc-help at gcc dot gnu dot org
Sameer Naik wrote:
> i would like to know what -DPIC linker flag mean. Tried to search in
> the gcc man page, but couldnt find.
> I've seen its usage as -fPIC -DPIC and id like to know whats it for..
It is not a linker flag, it is a preprocessor flag. It defines the PIC
macro, the equivalent of "#define PIC 1", just like any other regular
preprocessor macro or -D option. What that actually means would depend
on the specific code being compiled.
I would hazard a guess that this flag is automatically supplied by
libtool just in case the object may need this knowledge, but that it
isn't actually needed or utilized much. You'd have to search the code
being compiled for any "#if PIC" or "#ifdef PIC"-type constructs. From
a quick search at
<http://www.google.com/codesearch?hl=en&lr=&q=%22%23ifdef+PIC%22> it
would appear that this is used mainly when inline assembler is involved,
so that a version can be included that uses the GOT.
Brian