]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sysdeps/mach/hurd/dl-sysdep.c
Fix typos.
[thirdparty/glibc.git] / sysdeps / mach / hurd / dl-sysdep.c
index 11493a74547be526e86b28bf1e7060881754d221..1788ede94e262bf3ac36bd1ccef27f182058e189 100644 (file)
@@ -1,5 +1,5 @@
 /* Operating system support for run-time dynamic linker.  Hurd version.
-   Copyright (C) 1995,96,97,98,99,2000,2001,2002 Free Software Foundation, Inc.
+   Copyright (C) 1995-2013 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
    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.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* In the static library, this is all handled by dl-support.c
+   or by the vanilla definitions in the rest of the C library.  */
+#ifdef SHARED
 
 #include <hurd.h>
 #include <link.h>
@@ -51,12 +54,20 @@ int __libc_enable_secure = 0;
 INTVARDEF(__libc_enable_secure)
 int __libc_multiple_libcs = 0; /* Defining this here avoids the inclusion
                                   of init-first.  */
-/* This variable containts the lowest stack address ever used.  */
+/* This variable contains the lowest stack address ever used.  */
 void *__libc_stack_end;
 
+#if HP_TIMING_AVAIL
+hp_timing_t _dl_cpuclock_offset;
+#endif
+
 
 struct hurd_startup_data *_dl_hurd_data;
 
+/* This is used only within ld.so, via dl-minimal.c's __errno_location.  */
+#undef errno
+int errno attribute_hidden;
+
 /* Defining these variables here avoids the inclusion of hurdsig.c.  */
 unsigned long int __hurd_sigthread_stack_base;
 unsigned long int __hurd_sigthread_stack_end;
@@ -107,11 +118,11 @@ static void fmh(void) {
 ElfW(Addr)
 _dl_sysdep_start (void **start_argptr,
                  void (*dl_main) (const ElfW(Phdr) *phdr, ElfW(Word) phent,
-                                  ElfW(Addr) *user_entry))
+                                  ElfW(Addr) *user_entry,
+                                  ElfW(auxv_t) *auxv))
 {
-  void go (int *argdata)
+  void go (intptr_t *argdata)
     {
-      extern unsigned int _dl_skip_args; /* rtld.c */
       char **p;
 
       /* Cache the information in various global variables.  */
@@ -188,7 +199,7 @@ unfmh();                    /* XXX */
         up and leave us to transfer control to USER_ENTRY.  */
       (*dl_main) ((const ElfW(Phdr) *) _dl_hurd_data->phdr,
                  _dl_hurd_data->phdrsz / sizeof (ElfW(Phdr)),
-                 &_dl_hurd_data->user_entry);
+                 &_dl_hurd_data->user_entry, NULL);
 
       /* The call above might screw a few things up.
 
@@ -243,7 +254,11 @@ unfmh();                   /* XXX */
   __mach_init ();
 
   /* Initialize frequently used global variable.  */
-  GL(dl_pagesize) = __getpagesize ();
+  GLRO(dl_pagesize) = __getpagesize ();
+
+#if HP_TIMING_AVAIL
+  HP_TIMING_NOW (_dl_cpuclock_offset);
+#endif
 
 fmh();                         /* XXX */
 
@@ -276,7 +291,7 @@ _dl_sysdep_start_cleanup (void)
    error.  If STAT is non-zero, stat the file into that stat buffer.  */
 static error_t
 open_file (const char *file_name, int flags,
-          mach_port_t *port, struct stat *stat)
+          mach_port_t *port, struct stat64 *stat)
 {
   enum retry_type doretry;
   char retryname[1024];                /* XXX string_t LOSES! */
@@ -302,7 +317,7 @@ open_file (const char *file_name, int flags,
       return MACH_PORT_NULL;
     }
 
-  assert (!(flags & ~O_READ));
+  assert (!(flags & ~(O_READ | O_CLOEXEC)));
 
   startdir = _dl_hurd_data->portarray[file_name[0] == '/' ?
                                      INIT_PORT_CRDIR : INIT_PORT_CWDIR];
@@ -354,6 +369,7 @@ __libc_read (int fd, void *buf, size_t nbytes)
   mach_msg_type_number_t nread;
 
   data = buf;
+  nread = nbytes;
   err = __io_read ((mach_port_t) fd, &data, &nread, -1, nbytes);
   if (err)
     return __hurd_fail (err);
@@ -366,6 +382,7 @@ __libc_read (int fd, void *buf, size_t nbytes)
 
   return nread;
 }
+libc_hidden_weak (__libc_read)
 
 __ssize_t weak_function
 __libc_write (int fd, const void *buf, size_t nbytes)
@@ -381,18 +398,23 @@ __libc_write (int fd, const void *buf, size_t nbytes)
 
   return nwrote;
 }
+libc_hidden_weak (__libc_write)
 
 /* This is only used for printing messages (see dl-misc.c).  */
 __ssize_t weak_function
 __writev (int fd, const struct iovec *iov, int niov)
 {
+  if (fd >= _hurd_init_dtablesize)
+    {
+      errno = EBADF;
+      return -1;
+    }
+
   int i;
   size_t total = 0;
   for (i = 0; i < niov; ++i)
     total += iov[i].iov_len;
 
-  assert (fd < _hurd_init_dtablesize);
-
   if (total != 0)
     {
       char buf[total], *bufp = buf;
@@ -413,8 +435,8 @@ __writev (int fd, const struct iovec *iov, int niov)
 }
 
 
-off_t weak_function
-__lseek (int fd, off_t offset, int whence)
+off64_t weak_function
+__libc_lseek64 (int fd, off64_t offset, int whence)
 {
   error_t err;
 
@@ -487,7 +509,7 @@ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
 }
 
 int weak_function
-__fxstat (int vers, int fd, struct stat *buf)
+__fxstat64 (int vers, int fd, struct stat64 *buf)
 {
   error_t err;
 
@@ -499,9 +521,10 @@ __fxstat (int vers, int fd, struct stat *buf)
 
   return 0;
 }
+libc_hidden_def (__fxstat64)
 
 int weak_function
-__xstat (int vers, const char *file, struct stat *buf)
+__xstat64 (int vers, const char *file, struct stat64 *buf)
 {
   error_t err;
   mach_port_t port;
@@ -516,6 +539,7 @@ __xstat (int vers, const char *file, struct stat *buf)
 
   return 0;
 }
+libc_hidden_def (__xstat64)
 
 /* This function is called by the dynamic linker (rtld.c) to check
    whether debugging malloc is allowed even for SUID binaries.  This
@@ -529,7 +553,7 @@ __access (const char *file, int type)
 }
 
 pid_t weak_function
-__getpid ()
+__getpid (void)
 {
   pid_t pid, ppid;
   int orphaned;
@@ -555,7 +579,7 @@ __getcwd (char *buf, size_t size)
   return NULL;
 }
 
-void weak_function
+void weak_function attribute_hidden
 _exit (int status)
 {
   __proc_mark_exit (_dl_hurd_data->portarray[INIT_PORT_PROC],
@@ -563,6 +587,9 @@ _exit (int status)
   while (__task_terminate (__mach_task_self ()))
     __mach_task_self_ = (__mach_task_self) ();
 }
+/* We need this alias to satisfy references from libc_pic.a objects
+   that were affected by the libc_hidden_proto declaration for _exit.  */
+strong_alias (_exit, __GI__exit)
 
 /* Try to get a machine dependent instruction which will make the
    program crash.  This is used in case everything else fails.  */
@@ -586,6 +613,10 @@ abort (void)
     /* Try for ever and ever.  */
     ABORT_INSTRUCTION;
 }
+
+/* We need this alias to satisfy references from libc_pic.a objects
+   that were affected by the libc_hidden_proto declaration for abort.  */
+strong_alias (abort, __GI_abort)
 \f
 /* This function is called by interruptible RPC stubs.  For initial
    dynamic linking, just use the normal mach_msg.  Since this defn is
@@ -614,28 +645,10 @@ _dl_show_auxv (void)
 }
 
 
-/* Return an array of useful/necessary hardware capability names.  */
-const struct r_strlenpair *
-internal_function
-_dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
-                     size_t *max_capstrlen)
-{
-  struct r_strlenpair *result;
-
-  /* Return an empty array.  Hurd has no hardware capabilities.  */
-  result = (struct r_strlenpair *) malloc (sizeof (*result));
-  if (result == NULL)
-    _dl_signal_error (ENOMEM, NULL, NULL, "cannot create capability list");
-
-  result[0].str = (char *) result;     /* Does not really matter.  */
-  result[0].len = 0;
-
-  *sz = 1;
-  return result;
-}
-
 void weak_function
 _dl_init_first (int argc, ...)
 {
   /* This no-op definition only gets used if libc is not linked in.  */
 }
+
+#endif /* SHARED */