+2004-01-14 Ulrich Drepper <drepper@redhat.com>
+
+ * configure.in: Define HAVE_Z_RELRO if the linker supports -z relro.
+ * config.h.in: Add entry for HAVE_Z_RELRO.
+ * include/libc-symbols.h: Define attribute_relro.
+ * elf/dl-load.c: Add attribute_relro to env_path_list, capstr, ncapstr,
+ max_capstrlen, and max_dirnamelen definitions.
+ * elf/rtld.c: Add attribute_relro to _dl_argc, _dl_argv, _dl_skip_args,
+ load_time, start_time, library_path, preloadlist, version_info,
+ any_debug.
+ Remove rtld_total_time. Make it a local variable. Pass pointer to
+ it to print_statistics. Change print_statistics accordingly.
+ * sysdeps/generic/dl-sysdep.c: Add attribute_relro to _dl_auxv. Use
+ attribute_relro instead of explicitly assigning variable to the
+ .data.rel.ro section for __libc_enable_secure and __libc_stack_end.
+ * sysdeps/generic/ldsodefs.h: Declare __libc_stack_end, _dl_argc,
+ _dl_argv, _dl_argv_internal with attribute_relro.
+
2004-01-13 Segher Boessenkool <boessen@de.ibm.com>
* Makerules (gen-as-const): Don't silently continue on failure.
/* Defined if forced unwind support is available. */
#undef HAVE_FORCED_UNWIND
+/* Defined if the linker supports the -z relro option. */
+#undef HAVE_Z_RELRO
+
/*
\f */
echo "$as_me:$LINENO: result: $libc_cv_z_relro" >&5
echo "${ECHO_T}$libc_cv_z_relro" >&6
+ if test $libc_cv_z_relro = yes; then
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_Z_RELRO 1
+_ACEOF
+
+ fi
echo "$as_me:$LINENO: checking for -Bgroup option" >&5
echo $ECHO_N "checking for -Bgroup option... $ECHO_C" >&6
};
/* This is the decomposed LD_LIBRARY_PATH search path. */
-static struct r_search_path_struct env_path_list;
+static struct r_search_path_struct env_path_list attribute_relro;
/* List of the hardware capabilities we might end up using. */
-static const struct r_strlenpair *capstr;
-static size_t ncapstr;
-static size_t max_capstrlen;
+static const struct r_strlenpair *capstr attribute_relro;
+static size_t ncapstr attribute_relro;
+static size_t max_capstrlen attribute_relro;
/* Get the generated information about the trusted directories. */
}
/* Standard search directories. */
-static struct r_search_path_struct rtld_search_dirs;
+static struct r_search_path_struct rtld_search_dirs attribute_relro;
-static size_t max_dirnamelen;
+static size_t max_dirnamelen attribute_relro;
static struct r_search_path_elem **
fillin_rpath (char *rpath, struct r_search_path_elem **result, const char *sep,
const char *errsting);
/* Print the various times we collected. */
-static void print_statistics (void);
+static void print_statistics (hp_timing_t *total_timep);
/* This is a list of all the modes the dynamic loader can be in. */
enum mode { normal, list, verify, trace };
all the entries. */
static void process_envvars (enum mode *modep);
-int _dl_argc attribute_hidden;
-char **_dl_argv = NULL;
+int _dl_argc attribute_relro attribute_hidden;
+char **_dl_argv attribute_relro;
INTDEF(_dl_argv)
/* Nonzero if we were run directly. */
-unsigned int _dl_skip_args attribute_hidden;
+unsigned int _dl_skip_args attribute_relro attribute_hidden;
/* Set nonzero during loading and initialization of executable and
libraries, cleared before the executable's entry point runs. This
static void dl_main (const ElfW(Phdr) *phdr, ElfW(Word) phnum,
ElfW(Addr) *user_entry);
+/* These two variables cannot be moved into .data.rel.ro. */
static struct libname_list _dl_rtld_libname;
static struct libname_list _dl_rtld_libname2;
/* Variable for statistics. */
#ifndef HP_TIMING_NONAVAIL
-static hp_timing_t rtld_total_time;
static hp_timing_t relocate_time;
-static hp_timing_t load_time;
-static hp_timing_t start_time;
+static hp_timing_t load_time attribute_relro;
+static hp_timing_t start_time attribute_relro;
#endif
/* Additional definitions needed by TLS initialization. */
start_addr = _dl_sysdep_start (arg, &dl_main);
#ifndef HP_TIMING_NONAVAIL
+ hp_timing_t rtld_total_time;
if (HP_TIMING_AVAIL)
{
hp_timing_t end_time;
#endif
if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_STATISTICS, 0))
- print_statistics ();
+ print_statistics (&rtld_total_time);
return start_addr;
}
#endif
-static const char *library_path; /* The library search path. */
-static const char *preloadlist; /* The list preloaded objects. */
-static int version_info; /* Nonzero if information about
- versions has to be printed. */
+/* The library search path. */
+static const char *library_path attribute_relro;
+/* The list preloaded objects. */
+static const char *preloadlist attribute_relro;
+/* Nonzero if information about versions has to be printed. */
+static int version_info attribute_relro;
static void
dl_main (const ElfW(Phdr) *phdr,
}
\f
/* Nonzero if any of the debugging options is enabled. */
-static int any_debug;
+static int any_debug attribute_relro;
/* Process the string given as the parameter which explains which debugging
options are enabled. */
/* Print the various times we collected. */
static void
-print_statistics (void)
+print_statistics (hp_timing_t *rtld_total_timep)
{
#ifndef HP_TIMING_NONAVAIL
char buf[200];
/* Total time rtld used. */
if (HP_TIMING_AVAIL)
{
- HP_TIMING_PRINT (buf, sizeof (buf), rtld_total_time);
+ HP_TIMING_PRINT (buf, sizeof (buf), *rtld_total_timep);
INTUSE(_dl_debug_printf) ("\nruntime linker statistics:\n"
" total startup time in dynamic loader: %s\n",
buf);
- }
- /* Print relocation statistics. */
- if (HP_TIMING_AVAIL)
- {
+ /* Print relocation statistics. */
char pbuf[30];
HP_TIMING_PRINT (buf, sizeof (buf), relocate_time);
- cp = _itoa ((1000ULL * relocate_time) / rtld_total_time,
+ cp = _itoa ((1000ULL * relocate_time) / *rtld_total_timep,
pbuf + sizeof (pbuf), 10, 0);
wp = pbuf;
switch (pbuf + sizeof (pbuf) - cp)
{
char pbuf[30];
HP_TIMING_PRINT (buf, sizeof (buf), load_time);
- cp = _itoa ((1000ULL * load_time) / rtld_total_time,
+ cp = _itoa ((1000ULL * load_time) / *rtld_total_timep,
pbuf + sizeof (pbuf), 10, 0);
wp = pbuf;
switch (pbuf + sizeof (pbuf) - cp)
/* Support macros for making weak and strong aliases for symbols,
and for using symbol sets and linker warnings with GNU ld.
- Copyright (C) 1995-1998,2000,2001,2002,2003 Free Software Foundation, Inc.
+ Copyright (C) 1995-1998,2000-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
# define attribute_hidden
#endif
-#if defined HAVE_TLS_MODEL_ATTRIBUTE
+#ifdef HAVE_TLS_MODEL_ATTRIBUTE
# define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec")))
#else
# define attribute_tls_model_ie
#endif
+#ifdef HAVE_Z_RELRO
+# define attribute_relro __attribute__ ((section (".data.rel.ro")))
+#else
+# define attribute_relro
+#endif
+
/* Handling on non-exported internal names. We have to do this only
for shared code. */
#ifdef SHARED
#ifdef NEED_DL_BASE_ADDR
ElfW(Addr) _dl_base_addr;
#endif
-int __libc_enable_secure __attribute__ ((section (".data.rel.ro"))) = 0;
+int __libc_enable_secure attribute_relro = 0;
INTVARDEF(__libc_enable_secure)
int __libc_multiple_libcs = 0; /* Defining this here avoids the inclusion
of init-first. */
/* This variable contains the lowest stack address ever used. */
-void *__libc_stack_end __attribute__ ((section (".data.rel.ro")));
+void *__libc_stack_end attribute_relro;
rtld_hidden_data_def(__libc_stack_end)
-static ElfW(auxv_t) *_dl_auxv;
+static ElfW(auxv_t) *_dl_auxv attribute_relro;
#ifndef DL_FIND_ARG_COMPONENTS
# define DL_FIND_ARG_COMPONENTS(cookie, argc, argv, envp, auxp) \
might use the variable which results in copy relocations on some
platforms. But this does not matter, ld.so can always use the local
copy. */
-extern void *__libc_stack_end;
+extern void *__libc_stack_end attribute_relro;
rtld_hidden_proto (__libc_stack_end)
/* Parameters passed to the dynamic linker. */
-extern int _dl_argc attribute_hidden;
-extern char **_dl_argv;
+extern int _dl_argc attribute_hidden attribute_relro;
+extern char **_dl_argv attribute_relro;
#ifdef IS_IN_rtld
-extern char **_dl_argv_internal attribute_hidden;
+extern char **_dl_argv_internal attribute_hidden attribute_relro;
# define rtld_progname (INTUSE(_dl_argv)[0])
#else
# define rtld_progname _dl_argv[0]