Skip to content

Commit

Permalink
kldxref: Simplify elf_read_raw_data
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bsdjhb committed Mar 12, 2024
2 parents 1659ee7 + ed96fd7 commit 46cb759
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions usr.sbin/kldxref/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,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)
Expand Down

0 comments on commit 46cb759

Please sign in to comment.