[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Linking a static library with -fPIC for flex

On Thu, 7 Sep 2006 18:09:16 -0700, Steve Langasek <vorlon@debian.org> said: 

> The other alternative discussed on IRC was to make /usr/lib/libfl.so
> a linker script, à la libc.so.  I think the below should be
> sufficient, giving you PIC code when shared linking is requested by
> the linker and non-PIC code when static linking is requested:

> /* GNU ld script
>    When shared linking is requested, map the request to the PIC
>    static library, which is the closest we come to a shared library
>    here. */
> INPUT( /usr/lib/libfl_pic.a )

> Untested, though; it may actually be better to use GROUP() instead
> of INPUT(), I'm not sure if ld will treat the two commands the same
> for reduction of unused symbols.
`-( ARCHIVES -)'
`--start-group ARCHIVES --end-group'
     The ARCHIVES should be a list of archive files.  They may be
     either explicit file names, or `-l' options.

     The specified archives are searched repeatedly until no new
     undefined references are created.  Normally, an archive is
     searched only once in the order that it is specified on the
     command line.  If a symbol in that archive is needed to resolve an
     undefined symbol referred to by an object in an archive that
     appears later on the command line, the linker would not be able to
     resolve that reference.  By grouping the archives, they all be
     searched repeatedly until all possible references are resolved.

     Using this option has a significant performance cost.  It is best
     to use it only when there are unavoidable circular references
     between two or more archives.

        Since there is only one archive, and there are no circular
 dependencies, I think we would be OK with using INPUT.

Did you hear that two rabbits escaped from the zoo and so far they
have only recaptured 116 of them?
Manoj Srivastava   <srivasta@debian.org>  <http://www.debian.org/%7Esrivasta/>
1024D/BF24424C print 4966 F272 D093 B493 410B  924B 21BA DABB BF24 424C

Reply to: