diff options
author | Pedro Alves <pedro@palves.net> | 2023-06-07 10:38:14 +0100 |
---|---|---|
committer | Pedro Alves <pedro@palves.net> | 2023-07-06 17:57:48 +0100 |
commit | 31a56a22c45d76df4c597439f337e3f75ac3065c (patch) | |
tree | 556d93758f3f61ceba629139ff7cbd49145e8b22 /gdb/tracectf.c | |
parent | c0c3bb70f2f13e07295041cdf24a4d2997fe99a4 (diff) | |
download | gdb-31a56a22c45d76df4c597439f337e3f75ac3065c.zip gdb-31a56a22c45d76df4c597439f337e3f75ac3065c.tar.gz gdb-31a56a22c45d76df4c597439f337e3f75ac3065c.tar.bz2 |
Linux: Avoid pread64/pwrite64 for high memory addresses (PR gdb/30525)
Since commit 05c06f318fd9 ("Linux: Access memory even if threads are
running"), GDB prefers pread64/pwrite64 to access inferior memory
instead of ptrace. That change broke reading shared libraries on
SPARC64 Linux, as reported by PR gdb/30525 ("gdb cannot read shared
libraries on SPARC64").
On SPARC64 Linux, surprisingly (to me), userspace shared libraries are
mapped at high 64-bit addresses:
(gdb) info sharedlibrary
Cannot access memory at address 0xfff80001002011e0
Cannot access memory at address 0xfff80001002011d8
Cannot access memory at address 0xfff80001002011d8
From To Syms Read Shared Object Library
0xfff80001000010a0 0xfff8000100021f80 Yes (*) /lib64/ld-linux.so.2
(*): Shared library is missing debugging information.
Those addresses are 64-bit addresses with the high bits set. When
interpreted as signed, they're negative.
The Linux kernel rejects pread64/pwrite64 if the offset argument of
type off_t (a signed type) is negative, which happens if the memory
address we're accessing has its high bit set. See
linux/fs/read_write.c sys_pread64 and sys_pwrite64 in Linux.
Thankfully, lseek does not fail in that situation. So the fix is to
use the 'lseek + read|write' path if the offset would be negative.
Fix this in both native GDB and GDBserver.
Tested on a SPARC64 GNU/Linux and x86-64 GNU/Linux.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30525
Change-Id: I79c724f918037ea67b7396fadb521bc9d1b10dc5
Diffstat (limited to 'gdb/tracectf.c')
0 files changed, 0 insertions, 0 deletions