This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Powerpc64 glibc and gcc-3.3


I ran into a problem trying to build powerpc64 with the latest gcc-3.3 cvs 
head. In this case ld64.so segfaults because it is trying to use static 
storage in _dl_start. Static storage references are via the TOC and the 
TOC has to be relocated.

The problem starts following statement in elf/rtld.c:

/* Before ld.so is relocated we must not access variables which need
   relocations.  This means variables which are exported.  Variables
   declared as static are fine.  If we can mark a variable hidden this
   is fine, too.  The latter is impotant here.  We can avoid setting
   up a temporary link map for ld.so if we can mark _rtld_global as
   hidden.  */
#if defined PI_STATIC_AND_HIDDEN && defined HAVE_HIDDEN \
    && defined HAVE_VISIBILITY_ATTRIBUTE
# define DONT_USE_BOOTSTRAP_MAP 1
#endif

and

#ifdef DONT_USE_BOOTSTRAP_MAP
# define bootstrap_map GL(dl_rtld_map)
#else
  struct dl_start_final_info info;
# define bootstrap_map info.l
#endif

For PPC64 referencing the static "dl_rtld_map" involves a TOC load but the TOC is not relocatedyet. So first reference 
to dl_rtld_map results in a segfault!

The assumption (stated in the comment above) that if symbol is not visible 
(.hidden) it does not require relocation is not true for PPC64. And it is 
not likely to be true any time soon.

Previously PPC64 was protected by not supporting __attribute__ visibility 
(HAVE_VISIBILITY_ATTRIBUTE) but that has changed with the latest gcc-3.3 cvs head. 

The simplest solutions is some thing like:

diff -urN libc23-cvstip/elf/rtld.c libc23/elf/rtld.c
--- libc23-cvstip/elf/rtld.c    2003-01-07 12:50:35.000000000 -0600
+++ libc23/elf/rtld.c   2003-03-11 16:42:51.000000000 -0600
@@ -141,7 +141,7 @@
    up a temporary link map for ld.so if we can mark _rtld_global as
    hidden.  */
 #if defined PI_STATIC_AND_HIDDEN && defined HAVE_HIDDEN \
-    && defined HAVE_VISIBILITY_ATTRIBUTE
+    && defined HAVE_VISIBILITY_ATTRIBUTE && !defined __powerpc64__
 # define DONT_USE_BOOTSTRAP_MAP        1
 #endif
 
Any other good ideas?


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