This is the mail archive of the libc-hacker@sources.redhat.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]
Other format: [Raw text]

[PATCH] DL_ARGV_NOT_RELRO (take 2)


Hi!

My patch from yesterday was broken, as ldsodefs.h declares _dl_argv with
attribute_relro earlier than dl-machine.h is actually included.
The following incremental patch makes it work (tested on sparc32).

Can you please also commit the sysdeps/sparc/sparc32/bits/atomic.h patch
I've posted 2 days ago?

2004-02-20  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/generic/ldsodefs.h (_dl_argv, _dl_argv_internal): If
	DL_ARGV_NOT_RELRO defined, don't use attribute_relro.
	* sysdeps/alpha/dl-machine.h (DL_ARGV_NOT_RELRO): Remove.
	* sysdeps/ia64/dl-machine.h (DL_ARGV_NOT_RELRO): Remove.
	* sysdeps/sparc/sparc32/dl-machine.h (DL_ARGV_NOT_RELRO): Remove.
	* sysdeps/sparc/sparc64/dl-machine.h (DL_ARGV_NOT_RELRO): Remove.
	* sysdeps/alpha/dl-sysdep.h: New file.
	* sysdeps/ia64/dl-sysdep.h: New file.
	* sysdeps/sparc/dl-sysdep.h: New file.
nptl/
	* sysdeps/unix/sysv/linux/ia64/dl-sysdep.h (DL_ARGV_NOT_RELRO): Define.
linuxthreads/
	* sysdeps/unix/sysv/linux/ia64/dl-sysdep.h (DL_ARGV_NOT_RELRO): Define.

--- libc/sysdeps/alpha/dl-sysdep.h.jj	2004-02-20 16:46:10.522858416 +0100
+++ libc/sysdeps/alpha/dl-sysdep.h	2004-02-20 16:56:05.989333752 +0100
@@ -0,0 +1,41 @@
+/* System-specific settings for dynamic linker code.  Alpha version.
+   Copyright (C) 2002, 2003, 2004 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _DL_SYSDEP_H
+#define _DL_SYSDEP_H   1
+
+/* This macro must be defined to either 0 or 1.
+
+   If 1, then an errno global variable hidden in ld.so will work right with
+   all the errno-using libc code compiled for ld.so, and there is never a
+   need to share the errno location with libc.  This is appropriate only if
+   all the libc functions that ld.so uses are called without PLT and always
+   get the versions linked into ld.so rather than the libc ones.  */
+
+#ifdef IS_IN_rtld
+# define RTLD_PRIVATE_ERRNO 1
+#else
+# define RTLD_PRIVATE_ERRNO 0
+#endif
+
+/* _dl_argv cannot be attribute_relro, because _dl_start_user
+   might write into it after _dl_start returns.  */
+#define DL_ARGV_NOT_RELRO 1
+
+#endif /* dl-sysdep.h */
--- libc/sysdeps/alpha/dl-machine.h.jj	2004-02-20 16:36:31.000000000 +0100
+++ libc/sysdeps/alpha/dl-machine.h	2004-02-20 16:45:16.483073712 +0100
@@ -293,10 +293,6 @@ elf_machine_runtime_setup (struct link_m
   strong_alias (_dl_runtime_resolve, _dl_runtime_profile);
 #endif
 
-/* _dl_argv cannot be attribute_relro, because _dl_start_user below
-   might write into it after _dl_start returns.  */
-#define DL_ARGV_NOT_RELRO 1
-
 /* Initial entry point code for the dynamic linker.
    The C function `_dl_start' is the real entry point;
    its return value is the user program's entry point.  */
--- libc/sysdeps/sparc/sparc32/dl-machine.h.jj	2004-02-20 16:36:32.000000000 +0100
+++ libc/sysdeps/sparc/sparc32/dl-machine.h	2004-02-20 16:47:24.069677600 +0100
@@ -253,10 +253,6 @@ elf_machine_runtime_setup (struct link_m
 #define DL_STACK_END(cookie) \
   ((void *) (((long) (cookie)) - (22 - 6) * 4))
 
-/* _dl_argv cannot be attribute_relro, because _dl_start_user below
-   might write into it after _dl_start returns.  */
-#define DL_ARGV_NOT_RELRO 1
-
 /* Initial entry point code for the dynamic linker.
    The C function `_dl_start' is the real entry point;
    its return value is the user program's entry point.  */
--- libc/sysdeps/sparc/sparc64/dl-machine.h.jj	2004-02-20 16:36:32.000000000 +0100
+++ libc/sysdeps/sparc/sparc64/dl-machine.h	2004-02-20 16:47:36.546780792 +0100
@@ -671,10 +671,6 @@ elf_machine_runtime_setup (struct link_m
 #define DL_STACK_END(cookie) \
   ((void *) (((long) (cookie)) - (22 - 6) * 8 - STACK_BIAS))
 
-/* _dl_argv cannot be attribute_relro, because _dl_start_user below
-   might write into it after _dl_start returns.  */
-#define DL_ARGV_NOT_RELRO 1
-
 /* Initial entry point code for the dynamic linker.
    The C function `_dl_start' is the real entry point;
    its return value is the user program's entry point.  */
--- libc/sysdeps/sparc/dl-sysdep.h.jj	2004-02-20 16:46:10.000000000 +0100
+++ libc/sysdeps/sparc/dl-sysdep.h	2004-02-20 16:56:24.953450768 +0100
@@ -0,0 +1,41 @@
+/* System-specific settings for dynamic linker code.  SPARC version.
+   Copyright (C) 2002, 2003, 2004 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _DL_SYSDEP_H
+#define _DL_SYSDEP_H   1
+
+/* This macro must be defined to either 0 or 1.
+
+   If 1, then an errno global variable hidden in ld.so will work right with
+   all the errno-using libc code compiled for ld.so, and there is never a
+   need to share the errno location with libc.  This is appropriate only if
+   all the libc functions that ld.so uses are called without PLT and always
+   get the versions linked into ld.so rather than the libc ones.  */
+
+#ifdef IS_IN_rtld
+# define RTLD_PRIVATE_ERRNO 1
+#else
+# define RTLD_PRIVATE_ERRNO 0
+#endif
+
+/* _dl_argv cannot be attribute_relro, because _dl_start_user
+   might write into it after _dl_start returns.  */
+#define DL_ARGV_NOT_RELRO 1
+
+#endif /* dl-sysdep.h */
--- libc/sysdeps/ia64/dl-sysdep.h.jj	2004-02-20 16:46:10.000000000 +0100
+++ libc/sysdeps/ia64/dl-sysdep.h	2004-02-20 16:56:14.867983992 +0100
@@ -0,0 +1,41 @@
+/* System-specific settings for dynamic linker code.  IA-64 version.
+   Copyright (C) 2002, 2003, 2004 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _DL_SYSDEP_H
+#define _DL_SYSDEP_H   1
+
+/* This macro must be defined to either 0 or 1.
+
+   If 1, then an errno global variable hidden in ld.so will work right with
+   all the errno-using libc code compiled for ld.so, and there is never a
+   need to share the errno location with libc.  This is appropriate only if
+   all the libc functions that ld.so uses are called without PLT and always
+   get the versions linked into ld.so rather than the libc ones.  */
+
+#ifdef IS_IN_rtld
+# define RTLD_PRIVATE_ERRNO 1
+#else
+# define RTLD_PRIVATE_ERRNO 0
+#endif
+
+/* _dl_argv cannot be attribute_relro, because _dl_start_user
+   might write into it after _dl_start returns.  */
+#define DL_ARGV_NOT_RELRO 1
+
+#endif /* dl-sysdep.h */
--- libc/sysdeps/ia64/dl-machine.h.jj	2004-02-20 16:36:32.000000000 +0100
+++ libc/sysdeps/ia64/dl-machine.h	2004-02-20 16:51:27.383688248 +0100
@@ -272,10 +272,6 @@ elf_machine_runtime_setup (struct link_m
 #define DL_STACK_END(cookie) \
   ((void *) (((long) (cookie)) - 16))
 
-/* _dl_argv cannot be attribute_relro, because _dl_start_user below
-   might write into it after _dl_start returns.  */
-#define DL_ARGV_NOT_RELRO 1
-
 /* Initial entry point code for the dynamic linker.
    The C function `_dl_start' is the real entry point;
    its return value is the user program's entry point.  */
--- libc/sysdeps/generic/ldsodefs.h.jj	2004-02-09 14:52:34.000000000 +0100
+++ libc/sysdeps/generic/ldsodefs.h	2004-02-20 16:54:25.085673440 +0100
@@ -469,9 +469,17 @@ rtld_hidden_proto (__libc_stack_end)
 
 /* Parameters passed to the dynamic linker.  */
 extern int _dl_argc attribute_hidden attribute_relro;
-extern char **_dl_argv attribute_relro;
+extern char **_dl_argv
+#ifndef DL_ARGV_NOT_RELRO
+     attribute_relro
+#endif
+     ;
 #ifdef IS_IN_rtld
-extern char **_dl_argv_internal attribute_hidden attribute_relro;
+extern char **_dl_argv_internal attribute_hidden
+# ifndef DL_ARGV_NOT_RELRO
+     attribute_relro
+# endif
+     ;
 # define rtld_progname (INTUSE(_dl_argv)[0])
 #else
 # define rtld_progname _dl_argv[0]
--- libc/nptl/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h.jj	2003-12-10 23:44:52.000000000 +0100
+++ libc/nptl/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h	2004-02-20 16:55:10.291801064 +0100
@@ -1,5 +1,5 @@
 /* System-specific settings for dynamic linker code.  IA-64 version.
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004 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
@@ -61,4 +61,8 @@ extern int _dl_sysinfo_break attribute_h
        ".previous");
 #endif
 
+/* _dl_argv cannot be attribute_relro, because _dl_start_user
+   might write into it after _dl_start returns.  */
+#define DL_ARGV_NOT_RELRO 1
+
 #endif	/* dl-sysdep.h */
--- libc/linuxthreads/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h.jj	2003-12-10 23:35:14.000000000 +0100
+++ libc/linuxthreads/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h	2004-02-20 16:55:53.009307016 +0100
@@ -1,5 +1,5 @@
 /* System-specific settings for dynamic linker code.  IA-64 version.
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004 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
@@ -42,4 +42,8 @@ extern int _dl_sysinfo_break attribute_h
        ".previous");
 #endif
 
+/* _dl_argv cannot be attribute_relro, because _dl_start_user
+   might write into it after _dl_start returns.  */
+#define DL_ARGV_NOT_RELRO 1
+
 #endif	/* dl-sysdep.h */

	Jakub


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