-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for responding with library relocation offsets #20
Comments
Hmm, googling It looks like the cleaner (and more modern?) way to address the underlying issue would be to implement If it's not too much trouble, would you be willing to experiment with implementing one/both of these packets, and seeing if they work as intended? Working with XML might be a bit clunky, but it shouldn't be too tricky to get things working. Oh, and you may need to add some logic to the P.S: What sort of project are you using |
I know the gdb-stub in qemu does respond to (My project is an emulator that exposes a simple (also emulated) Linux userland -- I previously had my own gdb stub implementation (the protocol is a bit of a mess isn't it?), but it was much more limited than your |
qOffsets
query
Awesome, excited to see what you come up with! And yeah, the protocol's a real mess, eh? EDIT: ignore that 7-bit ASCII comment. Newer versions of the protocol assume an 8-bit clean connection. This means that logging data sent to/from the guest requires escaping characters, which can be a bit annoying... Sounds like a cool projects, thanks for sharing! |
I snuck a peek at your fork and saw that you had a rough implementation of While the |
Yeah, I think supporting regular For dynamically linked glibc binaries, generally what I do is load the dynamically linker Inside of the address-space of For the stub to properly support Still, it would be nice to properly support this (allowing targets that use a different dynamic linker to work) – but it is not something I am likely get to any time soon. For Should we support both response here? |
Oh, wow. I didn't realize just how much work a "proper" I totally understand why you might not want to spend the time to implement it 😄
I'm not entirely sure that's the case.
Also, the code you linked is for the slightly different I could be totally wrong here (after all, I've never actually worked with this particular feature myself), but I just thought I'd mention this in case it ends up being useful for whoever ends up implementing As for It looks like both replies follow a similar structure, so the handler should be pretty straight forward as well. |
I think What I think the docs are trying to say, is that if GDB can extract the offsets from the dynamic loader then you do not need to implement either of the two commands (except for optimization purposes). So, what |
Hmm, I think that sounds about right? Oh, and let me know if you hit any roadbumps while working on the I know there's been quite a bit of "churn" on the |
For some targets, sections may be relocated from their base address. As a result, the stub may need to tell GDB the final section addresses to ensure that debug symbols are resolved correctly after relocation.
Depending on the target this can be done using several mechanisms:
For targets where library offsets are maintained externally (e.g. Windows) this can be done by responding to
qXfer:library:read
.For System-V architectures, GDB is capable of extracting library offsets from memory if it knows the base address of the dynamic linker. The base address can be specified by either implementing the
qOffsets
command or by including aAT_BASE
entry in the response to the more modern qXfer:auxv:read command. Alternatively, a target can implementqXfer:library-svr4:read
, however this may involve digging into the internals of the dynamic linker.Currently, only the
qOffsets
command has been implemented (see: #30).Original issue:
For targets that relocate an image before execution, the debug symbols in GDB will have the incorrect offsets. The
qOffsets
query allows GDB to query the stub for the text segment offset after relocation.I implemented the functionality I needed here: mchesser@db347e0 however there appears to be two different methods of reporting the offset (I think one is relative, and one is absolute), and I'm not entirely sure if I missed anything in the implementation
The text was updated successfully, but these errors were encountered: