This is the mail archive of the mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.

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

PIC & shared libs - let's solve this now;-)

On this list there were several times the problems with PIC and shared
libraries mentioned.  The situation is still unresolved.  I'd like to
get this resolved now and therefore bring up the discussion again.

The problem is (citing Philip):
> The libc configure script detects that -fPIC is default and adds `-DPIC' to 
> the CPPFLAGS.  Unfortunately, it seems that in many cases the code is actually 
> using "#ifdef PIC" as a test for "is this a shared object", not for PIC per 
> se, and this causes things to go somewhat wrong.

So far this causes problems on MIPS, AFAIK ia64 and an ARM port Philip
was working on.

Here's an answer from myself to an old email from Ulrich.  I do think
we need SHARED, I don't think that Ulrich's idea works without major
problems.   IMO adding SHARED is a simple, isolated change.
>>>>> Ulrich Drepper wrote on 17 Nov 1998:

Ulrich> (H.J. Lu) writes:
>> It seems to work for me. I removed the change to sysdeps/i386/bits/string.h.
>> It is correct since it is the installed header file and __PIC__ is defined
>> when -fPIC is used. I will send a patch for linuxthreads later.

Ulrich> Thanks for your efforts.  I have a few problems, though.

Ulrich> I understand the reason why these changes are necessary.  The questions are:

Ulrich> - why introducing yet another symbol SHARED?

Ulrich> - some files do have a different form .o and .os even for platforms where
Ulrich>   PIC is the default.  These files are all those which include versioning
Ulrich>   code.

There are some files which have different .o and .os forms which
aren't dependend on versioning code.  For example elf/dl-close.c has:
#ifdef PIC
          /* We will unlink the first object only if this is a statically
             linked program.  */
          assert (imap->l_prev != NULL);
          imap->l_prev->l_next = imap->l_next;
          if (imap->l_prev != NULL)
            imap->l_prev->l_next = imap->l_next;
            _dl_loaded = imap->l_next;

Other C files which are effected are elf/dl-open.c,
include/libc-symbols.h (this one might be ok), libio/freopen.c,
linuxthreads/cancel.c, linuxthreads/pthread.c, nss/nsswitch.c,
sysdeps/generic/libc-start.c, sysdeps/unix/sysv/linux/init-first.c,

How should we handle those files?  I guess Ralf introduced SHARED also
for this problem.

Ulrich> Therefore I think the correct change is this:

Ulrich> - remove defining PIC from the CFLAGS-.o  This cannot make any sense.

Ulrich> - somehow mark those object files which contain versioning stuff and
Ulrich>   therefore are only used in the shared object.

Ulrich> This way we can build a libc.a and libc_pic.a.  Both files mainly
Ulrich> contain the .o files but libc_pic.a has those .o files replaced by .os
Ulrich> files if they contain versioning information.

Ulrich> I think this is only an optimization and therefore will not be added
Ulrich> before 2.1.  Anybody volunteer to make such a patch for later?

 Andreas Jaeger
  SuSE Labs

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