?? dl-sysdep.c
字號:
if (err) __mach_port_deallocate (__mach_task_self (), *port); } return err;}int weak_function__open (const char *file_name, int mode, ...){ mach_port_t port; error_t err = open_file (file_name, mode, &port, 0); if (err) return __hurd_fail (err); else return (int)port;}int weak_function__close (int fd){ if (fd != (int) MACH_PORT_NULL) __mach_port_deallocate (__mach_task_self (), (mach_port_t) fd); return 0;}__ssize_t weak_function__libc_read (int fd, void *buf, size_t nbytes){ error_t err; char *data; mach_msg_type_number_t nread; data = buf; err = __io_read ((mach_port_t) fd, &data, &nread, -1, nbytes); if (err) return __hurd_fail (err); if (data != buf) { memcpy (buf, data, nread); __vm_deallocate (__mach_task_self (), (vm_address_t) data, nread); } return nread;}libc_hidden_weak (__libc_read)__ssize_t weak_function__libc_write (int fd, const void *buf, size_t nbytes){ error_t err; mach_msg_type_number_t nwrote; assert (fd < _hurd_init_dtablesize); err = __io_write (_hurd_init_dtable[fd], buf, nbytes, -1, &nwrote); if (err) return __hurd_fail (err); 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; if (total != 0) { char buf[total], *bufp = buf; error_t err; mach_msg_type_number_t nwrote; for (i = 0; i < niov; ++i) bufp = (memcpy (bufp, iov[i].iov_base, iov[i].iov_len) + iov[i].iov_len); err = __io_write (_hurd_init_dtable[fd], buf, total, -1, &nwrote); if (err) return __hurd_fail (err); return nwrote; } return 0;}off64_t weak_function__libc_lseek64 (int fd, off64_t offset, int whence){ error_t err; err = __io_seek ((mach_port_t) fd, offset, whence, &offset); if (err) return __hurd_fail (err); return offset;}__ptr_t weak_function__mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset){ error_t err; vm_prot_t vmprot; vm_address_t mapaddr; mach_port_t memobj_rd, memobj_wr; vmprot = VM_PROT_NONE; if (prot & PROT_READ) vmprot |= VM_PROT_READ; if (prot & PROT_WRITE) vmprot |= VM_PROT_WRITE; if (prot & PROT_EXEC) vmprot |= VM_PROT_EXECUTE; if (flags & MAP_ANON) memobj_rd = MACH_PORT_NULL; else { assert (!(flags & MAP_SHARED)); err = __io_map ((mach_port_t) fd, &memobj_rd, &memobj_wr); if (err) return __hurd_fail (err), MAP_FAILED; __mach_port_deallocate (__mach_task_self (), memobj_wr); } mapaddr = (vm_address_t) addr; err = __vm_map (__mach_task_self (), &mapaddr, (vm_size_t) len, ELF_MACHINE_USER_ADDRESS_MASK, !(flags & MAP_FIXED), memobj_rd, (vm_offset_t) offset, flags & (MAP_COPY|MAP_PRIVATE), vmprot, VM_PROT_ALL, (flags & MAP_SHARED) ? VM_INHERIT_SHARE : VM_INHERIT_COPY); if (err == KERN_NO_SPACE && (flags & MAP_FIXED)) { /* XXX this is not atomic as it is in unix! */ /* The region is already allocated; deallocate it first. */ err = __vm_deallocate (__mach_task_self (), mapaddr, len); if (! err) err = __vm_map (__mach_task_self (), &mapaddr, (vm_size_t) len, ELF_MACHINE_USER_ADDRESS_MASK, !(flags & MAP_FIXED), memobj_rd, (vm_offset_t) offset, flags & (MAP_COPY|MAP_PRIVATE), vmprot, VM_PROT_ALL, (flags & MAP_SHARED) ? VM_INHERIT_SHARE : VM_INHERIT_COPY); } if ((flags & MAP_ANON) == 0) __mach_port_deallocate (__mach_task_self (), memobj_rd); if (err) return __hurd_fail (err), MAP_FAILED; return (__ptr_t) mapaddr;}int weak_function__fxstat64 (int vers, int fd, struct stat64 *buf){ error_t err; assert (vers == _STAT_VER); err = __io_stat ((mach_port_t) fd, buf); if (err) return __hurd_fail (err); return 0;}libc_hidden_def (__fxstat64)int weak_function__xstat64 (int vers, const char *file, struct stat64 *buf){ error_t err; mach_port_t port; assert (vers == _STAT_VER); err = open_file (file, 0, &port, buf); if (err) return __hurd_fail (err); __mach_port_deallocate (__mach_task_self (), port); 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 stub will always fail, which means that malloc-debugging is always disabled for SUID binaries. */int weak_function__access (const char *file, int type){ errno = ENOSYS; return -1;}pid_t weak_function__getpid (){ pid_t pid, ppid; int orphaned; if (__proc_getpids (_dl_hurd_data->portarray[INIT_PORT_PROC], &pid, &ppid, &orphaned)) return -1; return pid;}/* This is called only in some strange cases trying to guess a value for $ORIGIN for the executable. The dynamic linker copes with getcwd failing (dl-object.c), and it's too much hassle to include the functionality here. (We could, it just requires duplicating or reusing getcwd.c's code but using our special lookup function as in `open', above.) */char *weak_function__getcwd (char *buf, size_t size){ errno = ENOSYS; return NULL;}void weak_function attribute_hidden_exit (int status){ __proc_mark_exit (_dl_hurd_data->portarray[INIT_PORT_PROC], W_EXITCODE (status, 0), 0); 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. */#include <abort-instr.h>#ifndef ABORT_INSTRUCTION/* No such instruction is available. */# define ABORT_INSTRUCTION#endifvoid weak_functionabort (void){ /* Try to abort using the system specific command. */ ABORT_INSTRUCTION; /* If the abort instruction failed, exit. */ _exit (127); /* If even this fails, make sure we never return. */ while (1) /* 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)/* This function is called by interruptible RPC stubs. For initial dynamic linking, just use the normal mach_msg. Since this defn is weak, the real defn in libc.so will override it if we are linked into the user program (-ldl). */error_t weak_function_hurd_intr_rpc_mach_msg (mach_msg_header_t *msg, mach_msg_option_t option, mach_msg_size_t send_size, mach_msg_size_t rcv_size, mach_port_t rcv_name, mach_msg_timeout_t timeout, mach_port_t notify){ return __mach_msg (msg, option, send_size, rcv_size, rcv_name, timeout, notify);}voidinternal_function_dl_show_auxv (void){ /* There is nothing to print. Hurd has no auxiliary vector. */}/* 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. */}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -