[Lldb-commits] [PATCH] D74598: [lldb/gdb-remote] Add support for the qOffsets packet

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Feb 14 02:39:59 PST 2020


labath created this revision.
labath added reviewers: clayborg, jasonmolenda.
Herald added a project: LLDB.

This packet is necessary to make lldb work with the remote-gdb stub in
user mode qemu when running position-independent binaries. It reports
the relative position (load bias) of the loaded executable wrt. the
addresses in the file itself.

Lldb needs to know this information in order to correctly set the load
address of the executable. Normally, lldb would be able to find this out
on its own by following the breadcrumbs in the process auxiliary vector,
but we can't do this here because qemu does not support the
qXfer:auxv:read packet.

This patch does not implement full scope of the qOffsets packet (which
supports having different biases for code, data and bss sections). This
is because the relevant lldb interfaces (e.g., Module::SetLoadAddress)
do not support passing different values for different sections, and it's
not clear how would such a thing apply to typicall object files. And
qemu will always
(https://github.com/qemu/qemu/blob/master/linux-user/elfload.c#L2436)
return the same value for code and data offsets. In fact, even gdb
ignores the offset for the bss sections, and uses the "data" offset
instead.  So, until the we need more of this packet, I think it's best
to stick to the simplest solution possible. This patch simply rejects
replies with non-uniform offsets.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74598

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
  lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/test/API/functionalities/gdb_remote_client/qOffsets.yaml
  lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74598.244600.patch
Type: text/x-patch
Size: 6951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200214/dfdb083f/attachment.bin>


More information about the lldb-commits mailing list