From ed96fd7fc652d77ae5e34727e54610e87854defc Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Fri, 22 Dec 2023 07:49:03 -0800 Subject: [PATCH] kldxref: Simplify elf_read_raw_data Use pread as a valid offset is always passed now. Originally the DSO code read the .hash section in two separate requests and relied on the implicit offset for the second read, but now the hash table is fetched in a single call. Reviewed by: imp Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D43125 --- usr.sbin/kldxref/elf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/usr.sbin/kldxref/elf.c b/usr.sbin/kldxref/elf.c index f8a6510ed352..cc9bf9e6cb38 100644 --- a/usr.sbin/kldxref/elf.c +++ b/usr.sbin/kldxref/elf.c @@ -170,11 +170,7 @@ elf_read_raw_data(struct elf_file *efile, off_t offset, void *dst, size_t len) { ssize_t nread; - if (offset != (off_t)-1) { - if (lseek(efile->ef_fd, offset, SEEK_SET) == -1) - return (EIO); - } - nread = read(efile->ef_fd, dst, len); + nread = pread(efile->ef_fd, dst, len, offset); if (nread == -1) return (errno); if (nread != len)