* sysdeps/generic/utmp_file.c (UNLOCK_FILE): Clear alarm before
authorRoland McGrath <roland@gnu.org>
Sun, 25 Aug 2002 20:14:50 +0000 (20:14 +0000)
committerRoland McGrath <roland@gnu.org>
Sun, 25 Aug 2002 20:14:50 +0000 (20:14 +0000)
resetting handler, to avoid the possibility of a spurious SIGALRM
delivered to the user's handler.
Reported by Amit D. Chaudhary <amitc@brocade.com>,

* misc/Makefile (CFLAGS-init-misc.c): Varaible removed.  It served to
set -fkeep-inline-functions, which is not needed for the current file.

* sysdeps/generic/ldsodefs.h: Add attribute_hidden to *_internal decls.
(_dl_setup_hash): Add attribute_hidden.
(_dl_sysdep_start, _dl_sysdep_start_cleanup): Likewise.
(_dl_sysdep_read_whole_file, _dl_dprintf): Likewise.
(_dl_new_object, _dl_map_object_deps): Likewise.
(_dl_map_object_deps_internal): Remove decl.
* elf/rtld.c (__mempcpy, _exit): Redeclare locally as hidden.

* sysdeps/i386/dl-machine.h [PI_STATIC_AND_HIDDEN
&& HAVE_VISIBILITY_ATTRIBUTE && HAVE_HIDDEN
&& !HAVE_BROKEN_VISIBILITY_ATTRIBUTE]
(elf_machine_dynamic, elf_machine_load_address): Rewritten without asm,
instead relying on the compiler to produce only GOTOFF variable refs.

ChangeLog
elf/rtld.c
sysdeps/generic/ldsodefs.h
sysdeps/generic/utmp_file.c
sysdeps/i386/dl-machine.h

index a0cf55b..3846b86 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2002-08-25  Roland McGrath  <roland@redhat.com>
+
+       * sysdeps/generic/utmp_file.c (UNLOCK_FILE): Clear alarm before
+       resetting handler, to avoid the possibility of a spurious SIGALRM
+       delivered to the user's handler.
+       Reported by Amit D. Chaudhary <amitc@brocade.com>,
+
+       * misc/Makefile (CFLAGS-init-misc.c): Varaible removed.  It served to
+       set -fkeep-inline-functions, which is not needed for the current file.
+
+       * sysdeps/generic/ldsodefs.h: Add attribute_hidden to *_internal decls.
+       (_dl_setup_hash): Add attribute_hidden.
+       (_dl_sysdep_start, _dl_sysdep_start_cleanup): Likewise.
+       (_dl_sysdep_read_whole_file, _dl_dprintf): Likewise.
+       (_dl_new_object, _dl_map_object_deps): Likewise.
+       (_dl_map_object_deps_internal): Remove decl.
+       * elf/rtld.c (__mempcpy, _exit): Redeclare locally as hidden.
+
+       * sysdeps/i386/dl-machine.h [PI_STATIC_AND_HIDDEN
+       && HAVE_VISIBILITY_ATTRIBUTE && HAVE_HIDDEN
+       && !HAVE_BROKEN_VISIBILITY_ATTRIBUTE]
+       (elf_machine_dynamic, elf_machine_load_address): Rewritten without asm,
+       instead relying on the compiler to produce only GOTOFF variable refs.
+
 2002-08-25  Ulrich Drepper  <drepper@redhat.com>
 
        * elf/dl-load.c: Fix typo in comment.  Add a few more __builtin_expect.
index 0c8bba3..7c7c926 100644 (file)
 
 #include <assert.h>
 
+/* Avoid PLT use for our local calls at startup.  */
+extern __typeof (__mempcpy) __mempcpy attribute_hidden;
+
+/* GCC has mental blocks about _exit.  */
+extern __typeof (_exit) exit_internal asm ("_exit") attribute_hidden;
+#define _exit exit_internal
+
 /* Helper function to handle errors while resolving symbols.  */
 static void print_unresolved (int errcode, const char *objname,
                              const char *errsting);
index 361cb0b..06e68c2 100644 (file)
@@ -419,7 +419,8 @@ extern int _dl_sysdep_open_zero_fill (void); /* dl-sysdep.c */
 extern void _dl_debug_printf (const char *fmt, ...)
      __attribute__ ((__format__ (__printf__, 1, 2)));
 extern void _dl_debug_printf_internal (const char *fmt, ...)
-     __attribute__ ((__format__ (__printf__, 1, 2)));
+     __attribute__ ((__format__ (__printf__, 1, 2)))
+     attribute_hidden;
 
 /* Write message on the debug file descriptor.  The parameters are
    interpreted as for a `printf' call.  All the lines buf the first
@@ -431,7 +432,8 @@ extern void _dl_debug_printf_c (const char *fmt, ...)
 /* Write a message on the specified descriptor FD.  The parameters are
    interpreted as for a `printf' call.  */
 extern void _dl_dprintf (int fd, const char *fmt, ...)
-     __attribute__ ((__format__ (__printf__, 2, 3)));
+     __attribute__ ((__format__ (__printf__, 2, 3)))
+     attribute_hidden;
 
 /* Write a message on the specified descriptor standard output.  The
    parameters are interpreted as for a `printf' call.  */
@@ -466,8 +468,7 @@ extern void _dl_signal_error (int errcode, const char *object,
 extern void _dl_signal_error_internal (int errcode, const char *object,
                                       const char *occurred,
                                       const char *errstring)
-     internal_function
-     __attribute__ ((__noreturn__));
+     internal_function __attribute__ ((__noreturn__)) attribute_hidden;
 
 /* Like _dl_signal_error, but may return when called in the context of
    _dl_receive_error.  */
@@ -498,7 +499,7 @@ extern struct link_map *_dl_map_object_internal (struct link_map *loader,
                                                 int preloaded,
                                                 int type, int trace_mode,
                                                 int mode)
-     internal_function;
+     internal_function attribute_hidden;
 
 /* Call _dl_map_object on the dependencies of MAP, and set up
    MAP->l_searchlist.  PRELOADS points to a vector of NPRELOADS previously
@@ -513,10 +514,11 @@ extern void _dl_map_object_deps_internal (struct link_map *map,
                                          struct link_map **preloads,
                                          unsigned int npreloads,
                                          int trace_mode, int open_mode)
-     internal_function;
+     internal_function attribute_hidden;
 
 /* Cache the locations of MAP's hash table.  */
-extern void _dl_setup_hash (struct link_map *map) internal_function;
+extern void _dl_setup_hash (struct link_map *map)
+     internal_function attribute_hidden;
 
 
 /* Search loaded objects' symbol tables for a definition of the symbol
@@ -537,9 +539,9 @@ extern lookup_t _dl_lookup_symbol (const char *undef,
 extern lookup_t _dl_lookup_symbol_internal (const char *undef,
                                            struct link_map *undef_map,
                                            const ElfW(Sym) **sym,
-                                           struct r_scope_elem *symbol_scope[],
+                                           struct r_scope_elem *symbolscope[],
                                            int type_class, int flags)
-     internal_function;
+     internal_function attribute_hidden;
 
 enum
   {
@@ -565,7 +567,7 @@ extern lookup_t _dl_lookup_versioned_symbol_internal (const char *undef,
                                                      const struct r_found_version *version,
                                                      int type_class,
                                                      int explicit)
-     internal_function;
+     internal_function attribute_hidden;
 
 /* For handling RTLD_NEXT we must be able to skip shared objects.  */
 extern lookup_t _dl_lookup_symbol_skip (const char *undef,
@@ -593,7 +595,7 @@ extern ElfW(Addr) _dl_symbol_value (struct link_map *map, const char *name)
    and enter it into the _dl_main_map list.  */
 extern struct link_map *_dl_new_object (char *realname, const char *libname,
                                        int type, struct link_map *loader)
-     internal_function;
+     internal_function attribute_hidden;
 
 /* Relocate the given object (if it hasn't already been).
    SCOPE is passed to _dl_lookup_symbol in symbol lookups.
@@ -603,7 +605,8 @@ extern void _dl_relocate_object (struct link_map *map,
                                 int lazy, int consider_profiling);
 extern void _dl_relocate_object_internal (struct link_map *map,
                                          struct r_scope_elem *scope[],
-                                         int lazy, int consider_profiling);
+                                         int lazy, int consider_profiling)
+     attribute_hidden;
 
 /* Call _dl_signal_error with a message about an unhandled reloc type.
    TYPE is the result of ELFW(R_TYPE) (r_info), i.e. an R_<CPU>_* value.
@@ -660,7 +663,7 @@ extern void _dl_start_profile (struct link_map *map, const char *output_dir)
      internal_function;
 extern void _dl_start_profile_internal (struct link_map *map,
                                        const char *output_dir)
-     internal_function;
+     internal_function attribute_hidden;
 
 /* The actual functions used to keep book on the calls.  */
 extern void _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc);
@@ -696,14 +699,14 @@ extern const char *_dl_load_cache_lookup (const char *name)
    Therefore we provide this function to close the file and open it again
    once needed.  */
 extern void _dl_unload_cache (void);
-extern void _dl_unload_cache_internal (void);
+extern void _dl_unload_cache_internal (void) attribute_hidden;
 
 /* System-dependent function to read a file's whole contents in the
    most convenient manner available.  *SIZEP gets the size of the
    file.  On error MAP_FAILED is returned.  */
 extern void *_dl_sysdep_read_whole_file (const char *file, size_t *sizep,
                                         int prot)
-     internal_function;
+     internal_function attribute_hidden;
 
 /* System-specific function to do initial startup for the dynamic linker.
    After this, file access calls and getenv must work.  This is responsible
@@ -712,10 +715,11 @@ extern void *_dl_sysdep_read_whole_file (const char *file, size_t *sizep,
 extern ElfW(Addr) _dl_sysdep_start (void **start_argptr,
                                    void (*dl_main) (const ElfW(Phdr) *phdr,
                                                     ElfW(Word) phnum,
-                                                    ElfW(Addr) *user_entry));
+                                                    ElfW(Addr) *user_entry))
+     attribute_hidden;
 
 extern void _dl_sysdep_start_cleanup (void)
-     internal_function;
+     internal_function attribute_hidden;
 
 
 /* Determine next available module ID.  */
index 0baf411..d2a2b33 100644 (file)
@@ -74,9 +74,16 @@ static void timeout_handler (int signum) {};
   fl.l_type = F_UNLCK;                                                  \
   __fcntl ((fd), F_SETLKW, &fl);                                        \
                                                                         \
-  /* Reset the signal handler and alarm.  */                            \
+  /* Reset the signal handler and alarm.  We must reset the alarm      \
+     before resetting the handler so our alarm does not generate a     \
+     spurious SIGALRM seen by the user.  However, we cannot just set   \
+     the user's old alarm before restoring the handler, because then   \
+     it's possible our handler could catch the user alarm's SIGARLM    \
+     and then the user would never see the signal he expected.  */     \
+  alarm (0);                                                           \
   __sigaction (SIGALRM, &old_action, NULL);                             \
-  alarm (old_timeout);                                                  \
+  if (old_timeout != 0)                                                        \
+    alarm (old_timeout);                                                \
 } while (0)
 
 
index 09c1a9b..c499875 100644 (file)
@@ -34,6 +34,35 @@ elf_machine_matches_host (const Elf32_Ehdr *ehdr)
 }
 
 
+#if defined PI_STATIC_AND_HIDDEN \
+    && defined HAVE_VISIBILITY_ATTRIBUTE && defined HAVE_HIDDEN \
+    && !defined HAVE_BROKEN_VISIBILITY_ATTRIBUTE
+
+/* Return the link-time address of _DYNAMIC.  Conveniently, this is the
+   first element of the GOT, a special entry that is never relocated.  */
+static inline Elf32_Addr __attribute__ ((unused, const))
+elf_machine_dynamic (void)
+{
+  /* This produces a GOTOFF reloc that resolves to zero at link time, so in
+     fact just loads from the GOT register directly.  By doing it without
+     an asm we can let the compiler choose any register.  */
+  extern const Elf32_Addr _GLOBAL_OFFSET_TABLE_[] attribute_hidden;
+  return _GLOBAL_OFFSET_TABLE_[0];
+}
+
+/* Return the run-time load address of the shared object.  */
+static inline Elf32_Addr __attribute__ ((unused))
+elf_machine_load_address (void)
+{
+  /* Compute the difference between the runtime address of _DYNAMIC as seen
+     by a GOTOFF reference, and the link-time address found in the special
+     unrelocated first GOT entry.  */
+  extern Elf32_Dyn bygotoff[] asm ("_DYNAMIC") attribute_hidden;
+  return (Elf32_Addr) &bygotoff - elf_machine_dynamic ();
+}
+
+#else  /* Without .hidden support, we can't compile the code above.  */
+
 /* Return the link-time address of _DYNAMIC.  Conveniently, this is the
    first element of the GOT.  This must be inlined in a function which
    uses global data.  */
@@ -60,6 +89,9 @@ elf_machine_load_address (void)
   return addr;
 }
 
+#endif
+
+
 #if !defined PROF && !__BOUNDED_POINTERS__
 /* We add a declaration of this function here so that in dl-runtime.c
    the ELF_MACHINE_RUNTIME_TRAMPOLINE macro really can pass the parameters