This is the mail archive of the libc-hacker@sourceware.cygnus.com 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]

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



Uli, here's the patch you've asked me for.

There're still some places which use PIC - they should be replaced
either by __PIC__ or by SHARED.  But I wasn't sure what's the right
thing to do since those occurences are all system specific.

We can now also remove the check "whether -fPIC is default" from
configure.  I'll do this later after this patch has been added.

Andreas

2000-03-29  Andreas Jaeger  <aj@suse.de>,	
            Ralf Baechle <ralf@uni-koblenz.de>

	* Makeconfig: Introduce new variable SHARED to mark code used in
	the shared library.
	* elf/dl-close.c: Use it instead of PIC.
	* elf/dl-load.c: Likewise.
	* elf/dl-open.c: Likewise.
	* hurd/geteuids.c: Likewise.
	* include/libc-symbols.h: Likewise.
	* include/shlib-compat.h: Likewise.
	* libio/freopen.c: Likewise.
	* linuxthreads/cancel.c: Likewise.
	* linuxthreads/pthread.c: Likewise.
	* linuxthreads/wrapsyscall.c: Likewise.
	* nss/nsswitch.c: Likewise.
	* stdio-common/vfprintf.c: Likewise.
	* sysdeps/arm/init-first.c: Likewise.
	* sysdeps/i386/init-first.c: Likewise
	* sysdeps/generic/init-first.c: Likewise.
	* sysdeps/generic/libc-start.c: Likewise.
	* sysdeps/mips/init-first.c: Likewise.
	* sysdeps/powerpc/elf/libc-start.c: Likewise.
	* sysdeps/unix/sysv/linux/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/arm/siglist.c: Likewise.
	* sysdeps/unix/sysv/linux/arm/errlist.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/chown.c: Likewise.

	* sysdeps/mips/machine-gmon.h (asm): Use __PIC__ as check.

============================================================
Index: Makeconfig
--- Makeconfig	2000/03/27 19:42:09	1.230
+++ Makeconfig	2000/03/29 10:04:41
@@ -604,7 +604,7 @@
 # Under --enable-shared, we will build a shared library of PIC objects.
 # The PIC object files are named foo.os.
 object-suffixes += .os
-CPPFLAGS-.os = -DPIC
+CPPFLAGS-.os = -DPIC -DSHARED
 CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
 libtype.os := lib%_pic.a
 # This can be changed by a sysdep makefile
============================================================
Index: elf/dl-close.c
--- elf/dl-close.c	2000/03/23 22:46:19	1.37
+++ elf/dl-close.c	2000/03/29 10:04:42
@@ -125,7 +125,7 @@
 		    imap->l_map_end - imap->l_map_start);
 
 	  /* Finally, unlink the data structure and free it.  */
-#ifdef PIC
+#ifdef SHARED
 	  /* We will unlink the first object only if this is a statically
 	     linked program.  */
 	  assert (imap->l_prev != NULL);
============================================================
Index: elf/dl-load.c
--- elf/dl-load.c	2000/03/23 20:11:30	1.115
+++ elf/dl-load.c	2000/03/29 10:04:44
@@ -516,7 +516,7 @@
   const char *strp;
   struct r_search_path_elem *pelem, **aelem;
   size_t round_size;
-#ifdef PIC
+#ifdef SHARED
   struct link_map *l;
 #endif
 
@@ -579,7 +579,7 @@
   max_dirnamelen = SYSTEM_DIRS_MAX_LEN;
   *aelem = NULL;
 
-#ifdef PIC
+#ifdef SHARED
   /* This points to the map of the main object.  */
   l = _dl_loaded;
   if (l != NULL)
@@ -613,7 +613,7 @@
 	    l->l_rpath_dirs = NULL;
 	}
     }
-#endif	/* PIC */
+#endif	/* SHARED */
 
   if (llp != NULL && *llp != '\0')
     {
============================================================
Index: elf/dl-open.c
--- elf/dl-open.c	2000/03/23 20:12:00	1.48
+++ elf/dl-open.c	2000/03/29 10:04:44
@@ -168,7 +168,7 @@
     {
       if (! l->l_relocated)
 	{
-#ifdef PIC
+#ifdef SHARED
 	  if (_dl_profile != NULL)
 	    {
 	      /* If this here is the shared object which we want to profile
============================================================
Index: hurd/geteuids.c
--- hurd/geteuids.c	1998/12/04 13:46:50	1.2
+++ hurd/geteuids.c	2000/03/29 10:04:44
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 94, 96, 97, 98 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 94, 96, 97, 98, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -64,6 +64,6 @@
 
 /* XXX Remove this alias when we bump the libc soname.  */
 
-#if defined PIC && DO_VERSIONING
+#if defined SHARED && DO_VERSIONING
 weak_alias (geteuids, __getuids)
 #endif
============================================================
Index: include/libc-symbols.h
--- include/libc-symbols.h	1999/07/18 00:17:45	1.9
+++ include/libc-symbols.h	2000/03/29 10:04:45
@@ -214,7 +214,7 @@
 
 /* These are all done the same way in ELF.
    There is a new section created for each set.  */
-#  ifdef PIC
+#  ifdef SHARED
 /* When building a shared library, make the set section writable,
    because it will need to be relocated at run time anyway.  */
 #   define _elf_set_element(set, symbol) \
============================================================
Index: include/shlib-compat.h
--- include/shlib-compat.h	2000/03/27 23:57:24	1.7
+++ include/shlib-compat.h	2000/03/29 10:04:45
@@ -26,7 +26,7 @@
 #include <abi-versions.h>	/* header generated by abi-versions.awk */
 #endif
 
-#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING
+#if defined HAVE_ELF && defined SHARED && defined DO_VERSIONING
 
 /* The file abi-versions.h (generated by scripts/abi-versions.awk) defines
    symbols like `ABI_libm_GLIBC_2_0' for each version set in the source
============================================================
Index: libio/freopen.c
--- libio/freopen.c	2000/03/27 05:18:31	1.12
+++ libio/freopen.c	2000/03/29 10:04:45
@@ -26,7 +26,7 @@
 #include "libioP.h"
 #include "stdio.h"
 
-#ifdef PIC
+#ifdef SHARED
 extern void *_IO_stdin_used;
 weak_extern (_IO_stdin_used);
 #endif
============================================================
Index: linuxthreads/cancel.c
--- linuxthreads/cancel.c	2000/01/05 02:09:11	1.7
+++ linuxthreads/cancel.c	2000/03/29 10:04:45
@@ -162,7 +162,7 @@
     c->__routine(c->__arg);
 }
 
-#ifndef PIC
+#ifndef SHARED
 /* We need a hook to force the cancelation wrappers to be linked in when
    static libpthread is used.  */
 extern const int __pthread_provide_wrappers;
============================================================
Index: linuxthreads/pthread.c
--- linuxthreads/pthread.c	2000/03/22 07:21:40	1.38
+++ linuxthreads/pthread.c	2000/03/29 10:04:46
@@ -871,7 +871,7 @@
 #endif
 
 
-#ifndef PIC
+#ifndef SHARED
 /* We need a hook to force the cancelation wrappers to be linked in when
    static libpthread is used.  */
 extern const int __pthread_provide_wrappers;
============================================================
Index: linuxthreads/wrapsyscall.c
--- linuxthreads/wrapsyscall.c	1999/12/19 05:22:02	1.3
+++ linuxthreads/wrapsyscall.c	2000/03/29 10:04:47
@@ -31,7 +31,7 @@
 #include <sys/socket.h>
 
 
-#ifndef PIC
+#ifndef SHARED
 /* We need a hook to force this file to be linked in when static
    libpthread is used.  */
 const int __pthread_provide_wrappers = 0;
============================================================
Index: nss/nsswitch.c
--- nss/nsswitch.c	1999/06/28 15:52:01	1.48
+++ nss/nsswitch.c	2000/03/29 10:04:47
@@ -27,7 +27,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#if !defined DO_STATIC_NSS || defined PIC
+#if !defined DO_STATIC_NSS || defined SHARED
 # include <gnu/lib-names.h>
 #endif
 
@@ -65,7 +65,7 @@
 
 __libc_lock_define_initialized (static, lock)
 
-#if !defined DO_STATIC_NSS || defined PIC
+#if !defined DO_STATIC_NSS || defined SHARED
 /* String with revision number of the shared object files.  */
 static const char *const __nss_shlib_revision = LIBNSS_FILES_SO + 15;
 #endif
@@ -314,7 +314,7 @@
 		}
 	    }
 
-#if !defined DO_STATIC_NSS || defined PIC
+#if !defined DO_STATIC_NSS || defined SHARED
 	  if (ni->library->lib_handle == NULL)
 	    {
 	      /* Load the shared library.  */
============================================================
Index: stdio-common/vfprintf.c
--- stdio-common/vfprintf.c	2000/02/15 05:38:17	1.80
+++ stdio-common/vfprintf.c	2000/03/29 10:04:49
@@ -303,7 +303,7 @@
 
 #define NOT_IN_JUMP_RANGE(Ch) ((Ch) < L_(' ') || (Ch) > L_('z'))
 #define CHAR_CLASS(Ch) (jump_table[(INT_T) (Ch) - L_(' ')])
-#if defined HAVE_SUBTRACT_LOCAL_LABELS && defined PIC
+#if defined HAVE_SUBTRACT_LOCAL_LABELS && defined SHARED
   /* 'int' is enough and it saves some space on 64 bit systems.  */
 # define JUMP_TABLE_TYPE const int
 # define JUMP(ChExpr, table)						      \
@@ -1258,7 +1258,7 @@
   /* Process whole format string.  */
   do
     {
-#if defined HAVE_SUBTRACT_LOCAL_LABELS && defined PIC
+#if defined HAVE_SUBTRACT_LOCAL_LABELS && defined SHARED
 # define REF(Name) &&do_##Name - &&do_form_unknown
 #else
 # define REF(Name) &&do_##Name
@@ -1648,7 +1648,7 @@
     for (; (size_t) nspecs_done < nspecs; ++nspecs_done)
       {
 #undef REF
-#if defined HAVE_SUBTRACT_LOCAL_LABELS && defined PIC
+#if defined HAVE_SUBTRACT_LOCAL_LABELS && defined SHARED
 # define REF(Name) &&do2_##Name - &&do_form_unknown
 #else
 # define REF(Name) &&do2_##Name
============================================================
Index: sysdeps/arm/init-first.c
--- sysdeps/arm/init-first.c	1998/06/29 12:42:51	1.2
+++ sysdeps/arm/init-first.c	2000/03/29 10:04:49
@@ -39,7 +39,7 @@
   __getopt_clean_environment (envp);
 }
 
-#ifdef PIC
+#ifdef SHARED
 /* This function is called to initialize the shared C library.
    It is called just before the user _start code from i386/elf/start.S,
    with the stack set up as that code gets it.  */
@@ -63,7 +63,7 @@
 void
 __libc_init_first (int argc __attribute__ ((unused)), ...)
 {
-#ifndef PIC
+#ifndef SHARED
   init (&argc);
 #endif
 }
============================================================
Index: sysdeps/i386/init-first.c
--- sysdeps/i386/init-first.c	1997/09/21 01:23:53	1.8
+++ sysdeps/i386/init-first.c	2000/03/29 10:04:50
@@ -1,5 +1,5 @@
 /* Initialization code run first thing by the ELF startup code.  For i386/Unix.
-   Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -39,7 +39,7 @@
   __getopt_clean_environment (envp);
 }
 
-#ifdef PIC
+#ifdef SHARED
 /* This function is called to initialize the shared C library.
    It is called just before the user _start code from i386/elf/start.S,
    with the stack set up as that code gets it.  */
@@ -63,7 +63,7 @@
 void
 __libc_init_first (int argc __attribute__ ((unused)), ...)
 {
-#ifndef PIC
+#ifndef SHARED
   init (&argc);
 #endif
 }
============================================================
Index: sysdeps/generic/init-first.c
--- sysdeps/generic/init-first.c	1998/06/29 12:42:56	1.2
+++ sysdeps/generic/init-first.c	2000/03/29 10:04:50
@@ -25,14 +25,14 @@
 extern void __libc_init (int, char **, char **);
 extern void __getopt_clean_environment (char **);
 
-#ifdef PIC
+#ifdef SHARED
 void
 __libc_init_first (void)
 {
 }
 #endif
 
-#ifdef PIC
+#ifdef SHARED
 /* NOTE!  The linker notices the magical name `_init' and sets the DT_INIT
    pointer in the dynamic section based solely on that.  It is convention
    for this function to be in the `.init' section, but the symbol name is
============================================================
Index: sysdeps/generic/libc-start.c
--- sysdeps/generic/libc-start.c	2000/03/23 20:28:06	1.13
+++ sysdeps/generic/libc-start.c	2000/03/29 10:04:50
@@ -39,7 +39,7 @@
 		   char **argv, void (*init) (void), void (*fini) (void),
 		   void (*rtld_fini) (void), void *stack_end)
 {
-#ifndef PIC
+#ifndef SHARED
   /* The next variable is only here to work around a bug in gcc <= 2.7.2.2.
      If the address would be taken inside the expression the optimizer
      would try to be too smart and throws it away.  Grrr.  */
@@ -64,7 +64,7 @@
     atexit (rtld_fini);
 
   /* Call the initializer of the libc.  */
-#ifdef PIC
+#ifdef SHARED
   if (_dl_debug_impcalls)
     _dl_debug_message (1, "\ninitialize libc\n\n", NULL);
 #endif
@@ -75,14 +75,14 @@
     atexit (fini);
 
   /* Call the initializer of the program, if any.  */
-#ifdef PIC
+#ifdef SHARED
   if (_dl_debug_impcalls)
     _dl_debug_message (1, "\ninitialize program: ", argv[0], "\n\n", NULL);
 #endif
   if (init)
     (*init) ();
 
-#ifdef PIC
+#ifdef SHARED
   if (_dl_debug_impcalls)
     _dl_debug_message (1, "\ntransferring control: ", argv[0], "\n\n", NULL);
 #endif
============================================================
Index: sysdeps/mips/init-first.c
--- sysdeps/mips/init-first.c	1997/06/21 02:02:18	1.1
+++ sysdeps/mips/init-first.c	2000/03/29 10:04:50
@@ -34,7 +34,7 @@
   __libc_init (argc, argv, envp);
 }
 
-#ifdef PIC
+#ifdef SHARED
 /* This function is called to initialize the shared C library.
    It is called just before the user _start code from mips/elf/start.S,
    with the stack set up as that code gets it.  */
@@ -58,7 +58,7 @@
 void
 __libc_init_first (int argc __attribute__ ((unused)), ...)
 {
-#ifndef PIC
+#ifndef SHARED
   init (&argc);
 #endif
 }
============================================================
Index: sysdeps/mips/machine-gmon.h
--- sysdeps/mips/machine-gmon.h	1997/06/21 02:02:21	1.1
+++ sysdeps/mips/machine-gmon.h	2000/03/29 10:04:50
@@ -1,5 +1,5 @@
 /* Machine-specific calling sequence for `mcount' profiling function.  MIPS
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -21,7 +21,7 @@
 
 /* Call __mcount with our the return PC for our caller,
    and the return PC our caller will return to.  */
-#ifdef PIC
+#ifdef __PIC__
 #define CPLOAD ".cpload $25;"
 #else
 #define CPLOAD
============================================================
Index: sysdeps/powerpc/elf/libc-start.c
--- sysdeps/powerpc/elf/libc-start.c	2000/03/23 20:31:00	1.3
+++ sysdeps/powerpc/elf/libc-start.c	2000/03/29 10:04:50
@@ -41,7 +41,7 @@
 		   struct startup_info *stinfo,
 		   char **stack_on_entry)
 {
-#ifndef PIC
+#ifndef SHARED
   /* The next variable is only here to work around a bug in gcc <= 2.7.2.2.
      If the address would be taken inside the expression the optimizer
      would try to be too smart and throws it away.  Grrr.  */
@@ -80,7 +80,7 @@
     atexit (rtld_fini);
 
   /* Call the initializer of the libc.  */
-#ifdef PIC
+#ifdef SHARED
   if (_dl_debug_impcalls)
     _dl_debug_message (1, "\ninitialize libc\n\n", NULL);
 #endif
@@ -91,14 +91,14 @@
     atexit (stinfo->fini);
 
   /* Call the initializer of the program, if any.  */
-#ifdef PIC
+#ifdef SHARED
   if (_dl_debug_impcalls)
     _dl_debug_message (1, "\ninitialize program: ", argv[0], "\n\n", NULL);
 #endif
   if (stinfo->init)
     stinfo->init (argc, argv, __environ, auxvec);
 
-#ifdef PIC
+#ifdef SHARED
   if (_dl_debug_impcalls)
     _dl_debug_message (1, "\ntransferring control: ", argv[0], "\n\n", NULL);
 #endif
============================================================
Index: sysdeps/unix/sysv/linux/init-first.c
--- sysdeps/unix/sysv/linux/init-first.c	2000/03/04 01:04:33	1.26
+++ sysdeps/unix/sysv/linux/init-first.c	2000/03/29 10:04:50
@@ -129,7 +129,7 @@
       /* Set the FPU control word to the proper default value if the
 	 kernel would use a different value.  (In a static program we
 	 don't have this information.)  */
-#ifdef PIC
+#ifdef SHARED
       if (__fpu_control != _dl_fpu_control)
 #endif
 	__setfpucw (__fpu_control);
@@ -140,7 +140,7 @@
   __libc_argv = argv;
   __environ = envp;
 
-#ifndef PIC
+#ifndef SHARED
   __libc_init_secure ();
 #endif
 
@@ -149,12 +149,12 @@
   /* This is a hack to make the special getopt in GNU libc working.  */
   __getopt_clean_environment (envp);
 
-#ifdef PIC
+#ifdef SHARED
   __libc_global_ctors ();
 #endif
 }
 
-#ifdef PIC
+#ifdef SHARED
 
 SYSDEP_CALL_INIT(_init, init);
 
============================================================
Index: sysdeps/unix/sysv/linux/arm/siglist.c
--- sysdeps/unix/sysv/linux/arm/siglist.c	1999/06/19 09:47:56	1.2
+++ sysdeps/unix/sysv/linux/arm/siglist.c	2000/03/29 10:04:50
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -21,7 +21,7 @@
 #include <sizes.h>
 #include <libintl.h>
 
-#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING
+#if defined HAVE_ELF && defined SHARED && defined DO_VERSIONING
 # define SYS_SIGLIST	__new_sys_siglist
 # define SYS_SIGABBREV	__new_sys_sigabbrev
 #else
@@ -29,7 +29,7 @@
 # define SYS_SIGABBREV	_sys_sigabbrev
 #endif
 
-#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING
+#if defined HAVE_ELF && defined SHARED && defined DO_VERSIONING
 asm (".data; .globl __old_sys_siglist;  __old_sys_siglist:");
 #endif
 
@@ -40,7 +40,7 @@
 #undef init_sig
 };
 
-#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING
+#if defined HAVE_ELF && defined SHARED && defined DO_VERSIONING
 asm (".type __old_sys_siglist,%object;.size __old_sys_siglist,"
         OLD_SIGLIST_SIZE_STR "*" PTR_SIZE_STR);
 
@@ -54,7 +54,7 @@
 #undef init_sig
 };
 
-#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING
+#if defined HAVE_ELF && defined SHARED && defined DO_VERSIONING
 asm (".type __old_sys_sigabbrev,%object;.size __old_sys_sigabbrev,"
         OLD_SIGLIST_SIZE_STR "*" PTR_SIZE_STR);
 
============================================================
Index: sysdeps/unix/sysv/linux/arm/errlist.c
--- sysdeps/unix/sysv/linux/arm/errlist.c	1998/08/20 17:37:26	1.1
+++ sysdeps/unix/sysv/linux/arm/errlist.c	2000/03/29 10:04:50
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -19,7 +19,7 @@
 #include <sizes.h>
 #include <errlist.h>
 
-#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING
+#if defined HAVE_ELF && defined SHARED && defined DO_VERSIONING
 
 # define SYS_ERRLIST __new_sys_errlist
 # define SYS_NERR __new_sys_nerr
@@ -29,7 +29,7 @@
 
 #include <sysdeps/gnu/errlist.c>
 
-#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING
+#if defined HAVE_ELF && defined SHARED && defined DO_VERSIONING
 asm (".type __old_sys_errlist,%object;.size __old_sys_errlist,"
      OLD_ERRLIST_SIZE_STR "*" PTR_SIZE_STR);
 
============================================================
Index: sysdeps/unix/sysv/linux/i386/chown.c
--- sysdeps/unix/sysv/linux/i386/chown.c	2000/02/11 19:42:14	1.9
+++ sysdeps/unix/sysv/linux/i386/chown.c	2000/03/29 10:04:50
@@ -132,7 +132,7 @@
 {
   return INLINE_SYSCALL (chown, 3, file, owner, group);
 }
-#elif defined HAVE_ELF && defined PIC && defined DO_VERSIONING
+#elif defined HAVE_ELF && defined SHARED && defined DO_VERSIONING
 /* Compiling for compatibiity.  */
 int
 __chown_is_lchown (const char *file, uid_t owner, gid_t group)
@@ -141,7 +141,7 @@
 }
 #endif
 
-#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING
+#if defined HAVE_ELF && defined SHARED && defined DO_VERSIONING
 strong_alias (__chown_is_lchown, _chown_is_lchown)
 symbol_version (__chown_is_lchown, __chown, GLIBC_2.0);
 symbol_version (_chown_is_lchown, chown, GLIBC_2.0);

-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.rhein-neckar.de

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