svn commit: r324952 - head/libexec/rtld-elf

Edward Tomasz Napierala trasz at FreeBSD.org
Tue Oct 24 12:04:09 UTC 2017


Author: trasz
Date: Tue Oct 24 12:04:07 2017
New Revision: 324952
URL: https://svnweb.freebsd.org/changeset/base/324952

Log:
  Replace lseek(2)/read(2) pair with pread(2), removing yet another syscall
  from the binary startup code.
  
  MFC after:	2 weeks
  Sponsored by:	DARPA, AFRL

Modified:
  head/libexec/rtld-elf/rtld.c

Modified: head/libexec/rtld-elf/rtld.c
==============================================================================
--- head/libexec/rtld-elf/rtld.c	Tue Oct 24 11:24:54 2017	(r324951)
+++ head/libexec/rtld-elf/rtld.c	Tue Oct 24 12:04:07 2017	(r324952)
@@ -1824,10 +1824,9 @@ cleanup1:
 		if (dl > hint_stat.st_size)
 			goto cleanup1;
 		p = xmalloc(hdr.dirlistlen + 1);
-
-		if (lseek(fd, hdr.strtab + hdr.dirlist, SEEK_SET) == -1 ||
-		    read(fd, p, hdr.dirlistlen + 1) !=
-		    (ssize_t)hdr.dirlistlen + 1 || p[hdr.dirlistlen] != '\0') {
+		if (pread(fd, p, hdr.dirlistlen + 1,
+		    hdr.strtab + hdr.dirlist) != (ssize_t)hdr.dirlistlen + 1 ||
+		    p[hdr.dirlistlen] != '\0') {
 			free(p);
 			goto cleanup1;
 		}


More information about the svn-src-head mailing list