diff mbox

[RFC,3/5] MIPS: Record AT_FLAGS auxiliary vector's entry

Message ID alpine.DEB.2.00.1511200640430.6915@tp.orcam.me.uk
State New
Headers show

Commit Message

Maciej W. Rozycki Nov. 20, 2015, 7:30 a.m. UTC
Record AT_FLAGS auxiliary vector's entry on the MIPS platform, adjusting 
generic code so as to enable this code for platforms which make a use of 
it.  Pass the value recorded on to run-time loader newly invoked from 
static executables.

It is debatable as to whether `_dl_flags' needs to be initialized in 
`_rtld_global_ro', however follow the precedent of `_dl_inhibit_cache'.

Adjust formatting in a minor way in neighboring lines of dl-static.c, to 
follow the GNU Coding Standard.

	* sysdeps/generic/ldsodefs.h (rtld_global_ro) [NEED_DL_FLAGS]: 
	Add `_dl_flags' struct member.
	* sysdeps/unix/sysv/linux/mips/dl-sysdep.h: New file.
	* elf/dl-support.c (_dl_flags) [NEED_DL_FLAGS]: New variable.
	(_dl_aux_init) [NEED_DL_FLAGS] <AT_FLAGS>: Set `GLRO (dl_flags)'.
	* elf/dl-sysdep.c (_dl_sysdep_start) [NEED_DL_FLAGS] <AT_FLAGS>: 
	Set `GLRO (dl_flags)'.
	* elf/rtld.c (_rtld_global_ro) [NEED_DL_FLAGS]: Initialize 
	`_dl_flags' member.
	* sysdeps/unix/sysv/linux/mips/dl-static.c (_dl_var_init): Add 
	DL_FLAGS anonymous enum value.  Set `GLRO (dl_flags)'.
	(variables): Add a pointer to `GLRO (dl_flags)'.
---
glibc-mips-at-flags.diff
diff mbox

Patch

Index: glibc/elf/dl-support.c
===================================================================
--- glibc.orig/elf/dl-support.c	2015-11-10 14:06:46.548882325 +0000
+++ glibc/elf/dl-support.c	2015-11-10 14:07:01.451769679 +0000
@@ -138,6 +138,11 @@  void (*_dl_init_static_tls) (struct link
 
 size_t _dl_pagesize = EXEC_PAGESIZE;
 
+#ifdef NEED_DL_FLAGS
+/* The AT_FLAGS value passed by the kernel.  */
+uintptr_t _dl_flags;
+#endif
+
 int _dl_inhibit_cache;
 
 unsigned int _dl_osversion;
@@ -236,6 +241,11 @@  _dl_aux_init (ElfW(auxv_t) *av)
 	if (av->a_un.a_val != 0)
 	  GLRO(dl_pagesize) = av->a_un.a_val;
 	break;
+#ifdef NEED_DL_FLAGS
+      case AT_FLAGS:
+	GLRO (dl_flags) = av->a_un.a_val;
+	break;
+#endif
       case AT_CLKTCK:
 	GLRO(dl_clktck) = av->a_un.a_val;
 	break;
Index: glibc/elf/dl-sysdep.c
===================================================================
--- glibc.orig/elf/dl-sysdep.c	2015-11-10 13:40:06.158497219 +0000
+++ glibc/elf/dl-sysdep.c	2015-11-10 14:07:01.566120503 +0000
@@ -126,6 +126,11 @@  _dl_sysdep_start (void **start_argptr,
       case AT_PAGESZ:
 	GLRO(dl_pagesize) = av->a_un.a_val;
 	break;
+#ifdef NEED_DL_FLAGS
+      case AT_FLAGS:
+	GLRO (dl_flags) = av->a_un.a_val;
+	break;
+#endif
       case AT_ENTRY:
 	user_entry = av->a_un.a_val;
 	break;
Index: glibc/elf/rtld.c
===================================================================
--- glibc.orig/elf/rtld.c	2015-11-10 14:06:46.617728628 +0000
+++ glibc/elf/rtld.c	2015-11-10 14:07:01.623249929 +0000
@@ -165,6 +165,9 @@  struct rtld_global_ro _rtld_global_ro at
     ._dl_lazy = 1,
     ._dl_fpu_control = _FPU_DEFAULT,
     ._dl_pagesize = EXEC_PAGESIZE,
+#ifdef NEED_DL_FLAGS
+    ._dl_flags = 0,
+#endif
     ._dl_inhibit_cache = 0,
 
     /* Function pointers.  */
Index: glibc/sysdeps/generic/ldsodefs.h
===================================================================
--- glibc.orig/sysdeps/generic/ldsodefs.h	2015-11-10 13:56:33.755429398 +0000
+++ glibc/sysdeps/generic/ldsodefs.h	2015-11-10 14:07:01.732333197 +0000
@@ -472,6 +472,11 @@  struct rtld_global_ro
   /* Cached value of `getpagesize ()'.  */
   EXTERN size_t _dl_pagesize;
 
+#ifdef NEED_DL_FLAGS
+  /* The AT_FLAGS value passed by the kernel.  */
+  EXTERN uintptr_t _dl_flags;
+#endif
+
   /* Do we read from ld.so.cache?  */
   EXTERN int _dl_inhibit_cache;
 
Index: glibc/sysdeps/unix/sysv/linux/mips/dl-static.c
===================================================================
--- glibc.orig/sysdeps/unix/sysv/linux/mips/dl-static.c	2015-11-10 13:40:06.241480977 +0000
+++ glibc/sysdeps/unix/sysv/linux/mips/dl-static.c	2015-11-10 14:07:01.832920115 +0000
@@ -26,17 +26,20 @@  _dl_var_init (void *array[])
   /* It has to match "variables" below. */
   enum
     {
-      DL_PAGESIZE = 0
+      DL_PAGESIZE = 0,
+      DL_FLAGS
     };
 
-  GLRO(dl_pagesize) = *((size_t *) array[DL_PAGESIZE]);
+  GLRO (dl_pagesize) = *((size_t *) array[DL_PAGESIZE]);
+  GLRO (dl_flags) = *((uintptr_t *) array[DL_FLAGS]);
 }
 
 #else
 
 static void *variables[] =
 {
-  &GLRO(dl_pagesize)
+  &GLRO (dl_pagesize),
+  &GLRO (dl_flags)
 };
 
 static void
Index: glibc/sysdeps/unix/sysv/linux/mips/dl-sysdep.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ glibc/sysdeps/unix/sysv/linux/mips/dl-sysdep.h	2015-11-10 14:07:01.873416812 +0000
@@ -0,0 +1,23 @@ 
+/* System-specific settings for dynamic linker code.  MIPS/Linux version.
+   Copyright (C) 2015 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
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include_next <dl-sysdep.h>
+
+/* Record the AT_FLAGS value passed by the kernel in the auxiliary vector
+   to the application.  */
+#define NEED_DL_FLAGS 1