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]

[RFC] Allow read-only dynamic section



The MIPS ABI mandates a read only dynamic section - but this doesn't
work with the current glibc sources (see also the thread from november
1999 with subject "Has the dynamic section to be read-write?").

Ulrich suggested the following implementation to get this working:

- we define for MIPS (and so far only for MIPS) DL_RO_L_INFO and use
  this flag to decide if we change the dynamic section or not.
- dynamic-link.h relocates some entires (DT_PLTGOT, DT_STRTAB,
  DT_RELA, DT_REL, DT_JMPREL, DT_VERSYM and DT_INIT_ARRAY.  Each place
  that access this the value of these entries in l_info, uses a
  special macro D_PTR.  If the dynamic section is read-only we need to
  add l_addr, otherwise, we can use the entry:

#ifdef DL_RO_L_INFO
# define D_PTR(map,i) (map->i->d_un.d_ptr + map->l_addr)
#else
# define D_PTR(map,i) map->i->d_un.d_ptr
#endif

I'm appending a patch which passed make check on i686 - with *and*
without the definition of DL_RO_L_INFO (I needed to add some D_PTR for
some ix86 specific files to run with DL_RO_L_INFO set which I'm not
appending).

I've got the following open questions:

- Where should we define DL_RO_L_INFO?  Andreas Schwab suggested
  dl-machine.h but this means that we need to include dl-machine.h in
  a number of files where it's not included yet.  My favourite is a
  new file named e.g. "dl_sys.h" which just defines DL_RO_L_INFO (for
  MIPS, the generic version doesn't define anything).

- Where should D_PTR be defined?  Andreas Schwab suggested
  dynamic-link.h - but this has IMHO the same problem as above.  My
  proposal was to add to elf/ldsodefs.h (this way no changes to other
  headers are needed):
#include "dl_sys.h"
#ifdef DL_RO_L_INFO
# define D_PTR(map, i) (map->i->d_un.d_ptr + map->l_addr)
#else
# define D_PTR(map,i) map->i->d_un.d_ptr
#endif

- Are the choosen names good enough?  Do you have besser suggestions?
  I'm considering to use DL_RO_DYN_SECTION instead of DL_RO_L_INFO
  since the dynamic section is read only instead of L_INFO.

- Should I send patches for all dl-machine.h files to use D_PTR?  This
  is only needed for the MIPS version currently.  We could add it for
  consistency to other files but since other architectures will not
  define DL_RO_L_INFO, there's no need for a change.


Please note that the patch for elf/ldsodefs.h should not be added,
it's just to show a possible location.  I'll rework the patch with
your comments and send a final patch later.

Andreas

2000-03-22  Andreas Jaeger  <aj@suse.de>

	* elf/dl-version.c (match_symbol): Use D_PTR to access relocated
	entries in l_info.
	(_dl_check_map_versions): Likewise.
	* elf/dl-reloc.c (_dl_relocate_object): Likewise.
	* elf/dl-load.c (_dl_init_paths): Likewise.
	(_dl_map_object): Likewise.
	* elf/dynamic-link.h (_ELF_DYNAMIC_DO_RELOC): Likewise.
	(elf_get_dynamic_info): Likewise.
	* elf/do-lookup.h (FCT): Likewise.
	* elf/do-rel.h (elf_dynamic_do_rel): Likewise.
	* elf/dl-deps.c (_dl_map_object_deps): Likewise.
	* elf/dl-addr.c (_dl_addr): Likewise.
	* elf/dl-runtime.c (profile_fixup): Likewise.
	(fixup): Likewise.
	* elf/dl-init.c (_dl_init_next): Likewise.

	* sysdeps/generic/dl-machine.h (elf_machine_runtime_setup): Likewise.

	* elf/dynamic-link.h (elf_get_dynamic_info): Only change l_info
	for writable dynamic section.

Index: elf/ldsodefs.h
===================================================================
RCS file: /cvs/glibc/libc/elf/ldsodefs.h,v
retrieving revision 1.25
diff -u -p -r1.25 ldsodefs.h
--- elf/ldsodefs.h	2000/03/15 05:29:24	1.25
+++ elf/ldsodefs.h	2000/03/23 09:03:22
@@ -36,6 +36,21 @@ __BEGIN_DECLS
    `ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'.  */
 #define ELFW(type)	_ElfW (ELF, __ELF_NATIVE_CLASS, type)
 
+/* all references to the value of l_info[DT_PLTGOT],
+  l_info[DT_STRTAB], l_info[DT_SYMTAB], l_info[DT_RELA],
+  l_info[DT_REL], l_info[DT_JMPREL], l_info[VERSYMIDX (DT_VERSYM)],
+  and l_info[DT_INIT_ARRAY] have to accessed via the D_PTR macro.  The
+  macro is needed since for most architectures the entry is already
+  relocated - but for some not and we need to relocate at access time.  */
+#if 1
+#define DL_RO_L_INFO 1
+#endif
+#ifdef DL_RO_L_INFO
+# define D_PTR(map,i) (map->i->d_un.d_ptr + map->l_addr)
+#else
+# define D_PTR(map,i) map->i->d_un.d_ptr
+#endif
+
 /* For the version handling we need an array with only names and their
    hash values.  */
 struct r_found_version
Index: elf/dl-addr.c
===================================================================
RCS file: /cvs/glibc/libc/elf/dl-addr.c,v
retrieving revision 1.7
diff -u -p -r1.7 dl-addr.c
--- elf/dl-addr.c	1999/02/20 14:41:27	1.7
+++ elf/dl-addr.c	2000/03/23 09:03:18
@@ -1,5 +1,5 @@
 /* Locate the shared object symbol nearest a given address.
-   Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 1999, 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
@@ -62,8 +62,8 @@ _dl_addr (const void *address, Dl_info *
   info->dli_fname = match->l_name;
   info->dli_fbase = (void *) match->l_addr;
 
-  symtab = (const void *) match->l_info[DT_SYMTAB]->d_un.d_ptr;
-  strtab = (const void *) match->l_info[DT_STRTAB]->d_un.d_ptr;
+  symtab = (const void *) D_PTR (match, l_info[DT_SYMTAB]);
+  strtab = (const void *) D_PTR (match, l_info[DT_STRTAB]);
 
   /* We assume that the string table follows the symbol table, because
      there is no way in ELF to know the size of the dynamic symbol table!!  */
Index: elf/dl-deps.c
===================================================================
RCS file: /cvs/glibc/libc/elf/dl-deps.c,v
retrieving revision 1.35
diff -u -p -r1.35 dl-deps.c
--- dl-deps.c	2000/03/15 05:27:45	1.35
+++ dl-deps.c	2000/03/23 09:03:18
@@ -195,7 +195,7 @@ _dl_map_object_deps (struct link_map *ma
 
       if (l->l_info[DT_NEEDED] || l->l_info[AUXTAG] || l->l_info[FILTERTAG])
 	{
-	  const char *strtab = (const void *) l->l_info[DT_STRTAB]->d_un.d_ptr;
+	  const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
 	  struct openaux_args args;
 	  struct list *orig;
 	  const ElfW(Dyn) *d;
Index: elf/dl-init.c
===================================================================
RCS file: /cvs/glibc/libc/elf/dl-init.c,v
retrieving revision 1.16
diff -u -p -r1.16 dl-init.c
--- elf/dl-init.c	1999/07/24 19:35:51	1.16
+++ elf/dl-init.c	2000/03/23 09:03:18
@@ -1,5 +1,5 @@
 /* Return the next shared object initializer function not yet run.
-   Copyright (C) 1995, 1996, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1998, 1999, 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
@@ -88,7 +88,7 @@ _dl_init_next (struct r_scope_elem *sear
 			   l->l_name[0] ? l->l_name : _dl_argv[0],
 			   "\n\n", NULL);
 
-      array = (ElfW(Addr) *) l->l_info[DT_INIT_ARRAY]->d_un.d_ptr;
+      array = (ElfW(Addr) *) D_PTR (l, l_info[DT_INIT_ARRAY]);
       return l->l_addr + array[l->l_runcount - 2];
       /* NOTREACHED */
     }
Index: elf/dl-load.c
===================================================================
RCS file: /cvs/glibc/libc/elf/dl-load.c,v
retrieving revision 1.114
diff -u -p -r1.114 dl-load.c
--- elf/dl-load.c	1999/12/31 18:43:44	1.114
+++ elf/dl-load.c	2000/03/23 09:03:20
@@ -1,5 +1,5 @@
 /* Map in a shared object's segments from the file.
-   Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1995,96,97,98,99,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
@@ -591,7 +591,7 @@ _dl_init_paths (const char *llp)
 	  /* Allocate room for the search path and fill in information
 	     from RUNPATH.  */
 	  l->l_runpath_dirs =
-	    decompose_rpath ((const void *) (l->l_info[DT_STRTAB]->d_un.d_ptr
+	    decompose_rpath ((const void *) (D_PTR (l, l_info[DT_STRTAB])
 					     + l->l_info[DT_RUNPATH]->d_un.d_val),
 			     l, "RUNPATH");
 
@@ -606,7 +606,7 @@ _dl_init_paths (const char *llp)
 	    /* Allocate room for the search path and fill in information
 	       from RPATH.  */
 	    l->l_rpath_dirs =
-	      decompose_rpath ((const void *) (l->l_info[DT_STRTAB]->d_un.d_ptr
+	      decompose_rpath ((const void *) (D_PTR (l, l_info[DT_STRTAB])
 					       + l->l_info[DT_RPATH]->d_un.d_val),
 			       l, "RPATH");
 	  else
@@ -1300,7 +1300,7 @@ _dl_map_object (struct link_map *loader,
 	  if (l->l_info[DT_SONAME] == NULL)
 	    continue;
 
-	  soname = (const void *) (l->l_info[DT_STRTAB]->d_un.d_ptr
+	  soname = (const void *) (D_PTR (l, l_info[DT_STRTAB])
 				   + l->l_info[DT_SONAME]->d_un.d_val);
 	  if (strcmp (name, soname) != 0)
 	    continue;
@@ -1343,7 +1343,7 @@ _dl_map_object (struct link_map *loader,
 		/* Make sure the cache information is available.  */
 		if (l->l_rpath_dirs == NULL)
 		  {
-		    size_t ptrval = (l->l_info[DT_STRTAB]->d_un.d_ptr
+		    size_t ptrval = (D_PTR (l, l_info[DT_STRTAB])
 				     + l->l_info[DT_RPATH]->d_un.d_val);
 		    l->l_rpath_dirs =
 		      decompose_rpath ((const char *) ptrval, l, "RPATH");
@@ -1373,7 +1373,7 @@ _dl_map_object (struct link_map *loader,
 	  /* Make sure the cache information is available.  */
 	   if (loader->l_runpath_dirs == NULL)
 	      {
-		size_t ptrval = (loader->l_info[DT_STRTAB]->d_un.d_ptr
+		size_t ptrval = (D_PTR (loader, l_info[DT_STRTAB])
 				 + loader->l_info[DT_RUNPATH]->d_un.d_val);
 		loader->l_runpath_dirs =
 		  decompose_rpath ((const char *) ptrval, loader, "RUNPATH");
Index: elf/dl-reloc.c
===================================================================
RCS file: /cvs/glibc/libc/elf/dl-reloc.c,v
retrieving revision 1.36
diff -u -p -r1.36 dl-reloc.c
--- elf/dl-reloc.c	1999/12/18 23:39:31	1.36
+++ elf/dl-reloc.c	2000/03/23 09:03:20
@@ -1,5 +1,5 @@
 /* Relocate a shared object and resolve its references to other loaded objects.
-   Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1995,96,97,98,99,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
@@ -67,7 +67,7 @@ _dl_relocate_object (struct link_map *l,
     /* Do the actual relocation of the object's GOT and other data.  */
 
     /* String table object symbols.  */
-    const char *strtab = (const void *) l->l_info[DT_STRTAB]->d_un.d_ptr;
+    const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
 
     /* This macro is used as a callback from the ELF_DYNAMIC_RELOCATE code.  */
 #define RESOLVE(ref, version, flags) \
Index: elf/dl-runtime.c
===================================================================
RCS file: /cvs/glibc/libc/elf/dl-runtime.c,v
retrieving revision 1.38
diff -u -p -r1.38 dl-runtime.c
--- elf/dl-runtime.c	2000/03/22 00:16:47	1.38
+++ elf/dl-runtime.c	2000/03/23 09:03:21
@@ -50,11 +50,11 @@ fixup (
        struct link_map *l, ElfW(Word) reloc_offset)
 {
   const ElfW(Sym) *const symtab
-    = (const void *) l->l_info[DT_SYMTAB]->d_un.d_ptr;
-  const char *strtab = (const void *) l->l_info[DT_STRTAB]->d_un.d_ptr;
+    = (const void *) D_PTR (l, l_info[DT_SYMTAB]);
+  const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
 
   const PLTREL *const reloc
-    = (const void *) (l->l_info[DT_JMPREL]->d_un.d_ptr + reloc_offset);
+    = (const void *) (D_PTR (l, l_info[DT_JMPREL]) + reloc_offset);
   const ElfW(Sym) *sym = &symtab[ELFW(R_SYM) (reloc->r_info)];
   void *const rel_addr = (void *)(l->l_addr + reloc->r_offset);
   ElfW(Addr) value;
@@ -77,7 +77,7 @@ fixup (
 	default:
 	  {
 	    const ElfW(Half) *vernum =
-	      (const void *) l->l_info[VERSYMIDX (DT_VERSYM)]->d_un.d_ptr;
+	      (const void *) D_PTR (l, l_info[VERSYMIDX (DT_VERSYM)]);
 	    ElfW(Half) ndx = vernum[ELFW(R_SYM) (reloc->r_info)];
 	    const struct r_found_version *version = &l->l_versions[ndx];
 
@@ -141,11 +141,11 @@ profile_fixup (
     {
       /* This is the first time we have to relocate this object.  */
       const ElfW(Sym) *const symtab
-	= (const void *) l->l_info[DT_SYMTAB]->d_un.d_ptr;
-      const char *strtab = (const void *) l->l_info[DT_STRTAB]->d_un.d_ptr;
+	= (const void *) D_PTR (l, l_info[DT_SYMTAB]);
+      const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
 
       const PLTREL *const reloc
-	= (const void *) (l->l_info[DT_JMPREL]->d_un.d_ptr + reloc_offset);
+	= (const void *) (D_PTR (l, l_info[DT_JMPREL]) + reloc_offset);
       const ElfW(Sym) *sym = &symtab[ELFW(R_SYM) (reloc->r_info)];
 
       /* Sanity check that we're really looking at a PLT relocation.  */
@@ -160,7 +160,7 @@ profile_fixup (
 	    default:
 	      {
 		const ElfW(Half) *vernum =
-		  (const void *) l->l_info[VERSYMIDX (DT_VERSYM)]->d_un.d_ptr;
+		  (const void *) D_PTR (l,l_info[VERSYMIDX (DT_VERSYM)]);
 		ElfW(Half) ndx = vernum[ELFW(R_SYM) (reloc->r_info)];
 		const struct r_found_version *version = &l->l_versions[ndx];
 
Index: elf/dl-version.c
===================================================================
RCS file: /cvs/glibc/libc/elf/dl-version.c,v
retrieving revision 1.17
diff -u -p -r1.17 dl-version.c
--- elf/dl-version.c	1999/02/22 18:04:38	1.17
+++ elf/dl-version.c	2000/03/23 09:03:21
@@ -1,5 +1,5 @@
 /* Handle symbol and library versioning.
-   Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -77,7 +77,7 @@ internal_function
 match_symbol (const char *name, ElfW(Word) hash, const char *string,
 	      struct link_map *map, int verbose, int weak)
 {
-  const char *strtab = (const void *) map->l_info[DT_STRTAB]->d_un.d_ptr;
+  const char *strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
   ElfW(Addr) def_offset;
   ElfW(Verdef) *def;
 
@@ -175,7 +175,7 @@ _dl_check_map_versions (struct link_map 
   /* If we don't have a string table, we must be ok.  */
   if (map->l_info[DT_STRTAB] == NULL)
     return 0;
-  strtab = (const void *) map->l_info[DT_STRTAB]->d_un.d_ptr;
+  strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
 
   dyn = map->l_info[VERSYMIDX (DT_VERNEED)];
   def = map->l_info[VERSYMIDX (DT_VERDEF)];
@@ -285,7 +285,7 @@ _dl_check_map_versions (struct link_map 
 
 	  /* Compute the pointer to the version symbols.  */
 	  map->l_versyms =
-	    (void *) map->l_info[VERSYMIDX (DT_VERSYM)]->d_un.d_ptr;
+	    (void *) D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);
 
 	  if (dyn != NULL)
 	    {
Index: elf/do-lookup.h
===================================================================
RCS file: /cvs/glibc/libc/elf/do-lookup.h,v
retrieving revision 1.7
diff -u -p -r1.7 do-lookup.h
--- elf/do-lookup.h	1999/07/29 22:59:14	1.7
+++ elf/do-lookup.h	2000/03/23 09:03:21
@@ -1,5 +1,5 @@
 /* Look up a symbol in the loaded objects.
-   Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 1998, 1999, 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
@@ -67,8 +67,8 @@ FCT (const char *undef_name, struct link
 			   map->l_name[0] ? map->l_name : _dl_argv[0],
 			   "\n", NULL);
 
-      symtab = (const void *) map->l_info[DT_SYMTAB]->d_un.d_ptr;
-      strtab = (const void *) map->l_info[DT_STRTAB]->d_un.d_ptr;
+      symtab = (const void *) D_PTR (map, l_info[DT_SYMTAB]);
+      strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
       verstab = map->l_versyms;
 
       /* Search the appropriate hash bucket in this object's symbol table
Index: elf/do-rel.h
===================================================================
RCS file: /cvs/glibc/libc/elf/do-rel.h,v
retrieving revision 1.16
diff -u -p -r1.16 do-rel.h
--- elf/do-rel.h	1999/07/21 16:57:50	1.16
+++ elf/do-rel.h	2000/03/23 09:03:21
@@ -1,5 +1,5 @@
 /* Do relocations for ELF dynamic linking.
-   Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1995,96,97,98,99,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
@@ -53,12 +53,12 @@ elf_dynamic_do_rel (struct link_map *map
   else
     {
       const ElfW(Sym) *const symtab =
-	(const void *) map->l_info[DT_SYMTAB]->d_un.d_ptr;
+	(const void *) D_PTR (map, l_info[DT_SYMTAB]);
 
       if (map->l_info[VERSYMIDX (DT_VERSYM)])
 	{
 	  const ElfW(Half) *const version =
-	    (const void *) map->l_info[VERSYMIDX (DT_VERSYM)]->d_un.d_ptr;
+	    (const void *) D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);
 
 	  for (; r < end; ++r)
 	    {
Index: elf/dynamic-link.h
===================================================================
RCS file: /cvs/glibc/libc/elf/dynamic-link.h,v
retrieving revision 1.30
diff -u -p -r1.30 dynamic-link.h
--- elf/dynamic-link.h	1999/07/24 22:15:01	1.30
+++ elf/dynamic-link.h	2000/03/23 09:03:22
@@ -1,5 +1,5 @@
 /* Inline functions for dynamic linking.
-   Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 1998, 1999, 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
@@ -62,42 +62,45 @@ elf_get_dynamic_info (struct link_map *l
 	assert (! "bad dynamic tag");
       ++dyn;
     }
-
+#ifndef DL_RO_L_INFO
   if (info[DT_PLTGOT] != NULL)
     info[DT_PLTGOT]->d_un.d_ptr += l_addr;
   if (info[DT_STRTAB] != NULL)
     info[DT_STRTAB]->d_un.d_ptr += l_addr;
   if (info[DT_SYMTAB] != NULL)
     info[DT_SYMTAB]->d_un.d_ptr += l_addr;
-#if ! ELF_MACHINE_NO_RELA
+# if ! ELF_MACHINE_NO_RELA
   if (info[DT_RELA] != NULL)
     {
       assert (info[DT_RELAENT]->d_un.d_val == sizeof (ElfW(Rela)));
       info[DT_RELA]->d_un.d_ptr += l_addr;
     }
-#endif
-#if ! ELF_MACHINE_NO_REL
+# endif
+# if ! ELF_MACHINE_NO_REL
   if (info[DT_REL] != NULL)
     {
       assert (info[DT_RELENT]->d_un.d_val == sizeof (ElfW(Rel)));
       info[DT_REL]->d_un.d_ptr += l_addr;
     }
+# endif
 #endif
   if (info[DT_PLTREL] != NULL)
     {
-#if ELF_MACHINE_NO_RELA
+# if ELF_MACHINE_NO_RELA
       assert (info[DT_PLTREL]->d_un.d_val == DT_REL);
-#elif ELF_MACHINE_NO_REL
+# elif ELF_MACHINE_NO_REL
       assert (info[DT_PLTREL]->d_un.d_val == DT_RELA);
-#else
+# else
       assert (info[DT_PLTREL]->d_un.d_val == DT_REL
 	      || info[DT_PLTREL]->d_un.d_val == DT_RELA);
-#endif
+# endif
     }
+#ifndef DL_RO_L_INFO
   if (info[DT_JMPREL] != NULL)
     info[DT_JMPREL]->d_un.d_ptr += l_addr;
   if (info[VERSYMIDX (DT_VERSYM)] != NULL)
     info[VERSYMIDX (DT_VERSYM)]->d_un.d_ptr += l_addr;
+#endif
   if (info[DT_FLAGS] != NULL)
     {
       /* Flags are used.  Translate to the old form where available.
@@ -111,10 +114,22 @@ elf_get_dynamic_info (struct link_map *l
       if (flags & DF_BIND_NOW)
 	info[DT_BIND_NOW] = info[DT_FLAGS];
     }
+#ifndef DL_RO_L_INFO
   /* Determine how many constructors there are.  */
   if (info[DT_INIT_ARRAY] != NULL)
     info[DT_INIT_ARRAY]->d_un.d_ptr += l_addr;
+#endif
+#ifdef DL_RO_L_INFO
   l->l_initcount = 1 + (info[DT_INIT_ARRAY]
+			? (info[DT_INIT_ARRAYSZ]->d_un.d_val + l_addr
+			   / sizeof (ElfW(Addr)))
+			: 0);
+  l->l_preinitcount = (info[DT_PREINIT_ARRAY]
+		       ? (info[DT_PREINIT_ARRAYSZ]->d_un.d_val + l_addr
+			  / sizeof (ElfW(Addr)))
+		       : 0);
+#else
+  l->l_initcount = 1 + (info[DT_INIT_ARRAY]
 			? (info[DT_INIT_ARRAYSZ]->d_un.d_val
 			   / sizeof (ElfW(Addr)))
 			: 0);
@@ -122,6 +137,7 @@ elf_get_dynamic_info (struct link_map *l
 		       ? (info[DT_PREINIT_ARRAYSZ]->d_un.d_val
 			  / sizeof (ElfW(Addr)))
 		       : 0);
+#endif
   if (info[DT_RUNPATH] != NULL)
     /* If both RUNPATH and RPATH are given, the latter is ignored.  */
     info[DT_RPATH] = NULL;
@@ -151,7 +167,7 @@ elf_get_dynamic_info (struct link_map *l
 									      \
     if ((map)->l_info[DT_##RELOC])					      \
       {									      \
-	ranges[0].start = (map)->l_info[DT_##RELOC]->d_un.d_ptr;	      \
+	ranges[0].start = D_PTR ((map), l_info[DT_##RELOC]);		      \
 	ranges[0].size = (map)->l_info[DT_##RELOC##SZ]->d_un.d_val;	      \
       }									      \
 									      \
@@ -159,7 +175,7 @@ elf_get_dynamic_info (struct link_map *l
 	&& (map)->l_info[DT_PLTREL]					      \
 	&& (!test_rel || (map)->l_info[DT_PLTREL]->d_un.d_val == DT_##RELOC)) \
       {									      \
-	ranges[1].start = (map)->l_info[DT_JMPREL]->d_un.d_ptr;		      \
+	ranges[1].start = D_PTR ((map), l_info[DT_JMPREL]);		      \
 	ranges[1].size = (map)->l_info[DT_PLTRELSZ]->d_un.d_val;	      \
 	ranges[2].start = ranges[1].start + ranges[1].size;		      \
 	ranges[2].size = ranges[0].start + ranges[0].size - ranges[2].start;  \
@@ -183,13 +199,13 @@ elf_get_dynamic_info (struct link_map *l
 									      \
     if ((map)->l_info[DT_##RELOC])					      \
       {									      \
-        ranges[0].start = (map)->l_info[DT_##RELOC]->d_un.d_ptr;	      \
+        ranges[0].start = D_PTR ((map), l_info[DT_##RELOC]);		      \
         ranges[0].size = (map)->l_info[DT_##RELOC##SZ]->d_un.d_val;	      \
       }									      \
     if ((map)->l_info[DT_PLTREL]					      \
 	&& (!test_rel || (map)->l_info[DT_PLTREL]->d_un.d_val == DT_##RELOC)) \
       {									      \
-	ElfW(Addr) start = (map)->l_info[DT_JMPREL]->d_un.d_ptr;	      \
+	ElfW(Addr) start = D_PTR ((map), l_info[DT_JMPREL]);		      \
 									      \
 	if ((do_lazy)							      \
 	    /* This test does not only detect whether the relocation	      \
Index: elf/rtld.c
===================================================================
RCS file: /cvs/glibc/libc/elf/rtld.c,v
retrieving revision 1.158
diff -u -p -r1.158 rtld.c
--- elf/rtld.c	2000/03/15 05:30:14	1.158
+++ elf/rtld.c	2000/03/23 09:03:24
@@ -317,7 +317,7 @@ find_needed (const char *name)
 static int
 match_version (const char *string, struct link_map *map)
 {
-  const char *strtab = (const void *) map->l_info[DT_STRTAB]->d_un.d_ptr;
+  const char *strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
   ElfW(Verdef) *def;
 
 #define VERDEFTAG (DT_NUM + DT_PROCNUM + DT_VERSIONTAGIDX (DT_VERDEF))
@@ -926,7 +926,7 @@ of this helper program; chances are you 
 		  if (dyn == NULL)
 		    continue;
 
-		  strtab = (const void *) map->l_info[DT_STRTAB]->d_un.d_ptr;
+		  strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
 		  ent = (ElfW(Verneed) *) (map->l_addr + dyn->d_un.d_ptr);
 
 		  if (first)
Index: sysdeps/generic/dl-machine.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/generic/dl-machine.h,v
retrieving revision 1.2
diff -u -p -r1.2 dl-machine.h
--- sysdeps/generic/dl-machine.h	1999/07/21 16:57:50	1.2
+++ sysdeps/generic/dl-machine.h	2000/03/23 09:03:36
@@ -1,5 +1,5 @@
 /* Machine-dependent ELF dynamic relocation inline functions.  Stub version.
-   Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 1999, 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
@@ -117,7 +117,7 @@ elf_machine_runtime_setup (struct link_m
          in.  Their initial contents will arrange when called to push an
          offset into the .rel.plt section, push _GLOBAL_OFFSET_TABLE_[1],
          and then jump to _GLOBAL_OFFSET_TABLE[2].  */
-      Elf32_Addr *got = (Elf32_Addr *) l->l_info[DT_PLTGOT]->d_un.d_ptr;
+      Elf32_Addr *got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]);
       got[1] = (Elf32_Addr) l;	/* Identify this shared object.  */
 
       /* This function will get called to fix up the GOT entry indicated by

-- 
 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]