+2015-10-09 Jose E. Marchesi <jose.marchesi@oracle.com>
+
+ * linux-proc-maps.c (read_proc_memory): Use seek+read instead of
+ pread, as the later doesn't accept negative offsets.
+
2015-10-07 Mark Wielaard <mjw@redhat.com>
* dwfl_module_getdwarf.c (MAX): Removed.
size_t minread, size_t maxread)
{
const int fd = *(const int *) arg;
- ssize_t nread = pread64 (fd, data, maxread, (off64_t) address);
- /* Some kernels don't actually let us do this read, ignore those errors. */
- if (nread < 0 && (errno == EINVAL || errno == EPERM))
- return 0;
+
+ /* This code relies on the fact the Linux kernel accepts negative
+ offsets when seeking /dev/$$/mem files, as a special case. In
+ particular pread[64] cannot be used here, because it will always
+ return EINVAL when passed a negative offset. */
+
+ if (lseek (fd, (off64_t) address, SEEK_SET) == -1)
+ return -1;
+
+ ssize_t nread = read (fd, data, maxread);
+
if (nread > 0 && (size_t) nread < minread)
nread = 0;
return nread;