This is the mail archive of the libc-alpha@sourceware.org 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]

[PATCH] HPPA/IA64 : Don't use broken DL_AUTO_FUNCTION_ADDRESS()


On hppa and ia64, the macro DL_AUTO_FUNCTION_ADDRESS() uses the
variable fptr[2] in it's own scope.

The content of fptr[] is thus undefined right after the macro exits.
Newest gcc (>= 4.7) seem to reuse the stack space of this variable
triggering a segmentation fault in dl-init.c:69.

To prevent this, we use instead the existing macro
DL_STATIC_FUNCTION_ADDRESS() which is identical to
DL_AUTO_FUNCTION_ADDRESS() but declares fptr as static.

---

2013-10-17  Guy Martin  <gmsoft@tuxicoman.be>

	* ports/sysdeps/hppa/dl-lookupcfg.h: Use DL_STATIC_FUNCTION_ADDRESS()
	instead of the broken macro DL_AUTO_FUNCTION_ADDRESS().
	* ports/sysdeps/ia64/dl-lookupcfg.h: Likewise.

---
diff --git a/ports/sysdeps/hppa/dl-lookupcfg.h b/ports/sysdeps/hppa/dl-lookupcfg.h
index f3125e5..2e8f531 100644
--- a/ports/sysdeps/hppa/dl-lookupcfg.h
+++ b/ports/sysdeps/hppa/dl-lookupcfg.h
@@ -38,15 +38,6 @@ void _dl_unmap (struct link_map *map);
 
 #define DL_UNMAP(map) _dl_unmap (map)
 
-#define DL_AUTO_FUNCTION_ADDRESS(map, addr)				\
-({									\
-  unsigned int fptr[2];							\
-  fptr[0] = (unsigned int) (addr);					\
-  fptr[1] = (map)->l_info[DT_PLTGOT]->d_un.d_ptr;			\
-  /* Set bit 30 to indicate to $$dyncall that this is a PLABEL. */	\
-  (ElfW(Addr))((unsigned int)fptr | 2);					\
-})
-
 #define DL_STATIC_FUNCTION_ADDRESS(map, addr)				\
 ({									\
   static unsigned int fptr[2];						\
@@ -61,9 +52,9 @@ void _dl_unmap (struct link_map *map);
    violated the ELF ABI by pointing DT_INIT and DT_FINI at a function
    descriptor.  */
 #define DL_DT_INIT_ADDRESS(map, addr) \
-  ((Elf32_Addr)(addr) & 2 ? (addr) : DL_AUTO_FUNCTION_ADDRESS (map, addr))
+  ((Elf32_Addr)(addr) & 2 ? (addr) : DL_STATIC_FUNCTION_ADDRESS (map, addr))
 #define DL_DT_FINI_ADDRESS(map, addr) \
-  ((Elf32_Addr)(addr) & 2 ? (addr) : DL_AUTO_FUNCTION_ADDRESS (map, addr))
+  ((Elf32_Addr)(addr) & 2 ? (addr) : DL_STATIC_FUNCTION_ADDRESS (map, addr))
 
 /* The type of the return value of fixup/profile_fixup */
 #define DL_FIXUP_VALUE_TYPE struct fdesc
diff --git a/ports/sysdeps/ia64/dl-lookupcfg.h b/ports/sysdeps/ia64/dl-lookupcfg.h
index 4da1263..8738fae 100644
--- a/ports/sysdeps/ia64/dl-lookupcfg.h
+++ b/ports/sysdeps/ia64/dl-lookupcfg.h
@@ -39,14 +39,6 @@ extern void _dl_unmap (struct link_map *map);
 
 #define DL_UNMAP(map) _dl_unmap (map)
 
-#define DL_AUTO_FUNCTION_ADDRESS(map, addr)		\
-({							\
-  unsigned long int fptr[2];				\
-  fptr[0] = (unsigned long int) (addr);			\
-  fptr[1] = (map)->l_info[DT_PLTGOT]->d_un.d_ptr;	\
-  (Elf64_Addr) fptr;					\
-})
-
 #define DL_STATIC_FUNCTION_ADDRESS(map, addr)		\
 ({							\
   static unsigned long int fptr[2];			\
@@ -55,8 +47,8 @@ extern void _dl_unmap (struct link_map *map);
   (Elf64_Addr) fptr;					\
 })
 
-#define DL_DT_INIT_ADDRESS(map, addr) DL_AUTO_FUNCTION_ADDRESS (map, addr)
-#define DL_DT_FINI_ADDRESS(map, addr) DL_AUTO_FUNCTION_ADDRESS (map, addr)
+#define DL_DT_INIT_ADDRESS(map, addr) DL_STATIC_FUNCTION_ADDRESS (map, addr)
+#define DL_DT_FINI_ADDRESS(map, addr) DL_STATIC_FUNCTION_ADDRESS (map, addr)
 /* The type of the return value of fixup/profile_fixup.  */
 #define DL_FIXUP_VALUE_TYPE struct fdesc
 /* Construct a value of type DL_FIXUP_VALUE_TYPE from a code address


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