qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [Qemu-devel] [PATCH] linux-user: Support gdb 'qOffset


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] linux-user: Support gdb 'qOffsets' query for ELF
Date: Thu, 5 Sep 2019 12:54:13 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0

Cc'ing Alex.

On 9/3/19 9:19 PM, Josh Kunz via Qemu-devel wrote:
> The `Data` and `Code` flags in `qOffsets` are actually section offsets
> rather than segment offsets. GDB relocates the symbols in those sections
> relative to their location in the binary. So we have to use `load_bias`.
> 
> See here for a more detailed description:
> https://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html#General-Query-Packets

Maybe we can amend a reference to
http://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html#index-qOffsets-packet
in the commit.

Reviewed-by: Philippe Mathieu-Daudé <address@hidden>

> On Mon, Aug 26, 2019 at 1:29 AM Laurent Vivier <address@hidden> wrote:
> 
>> Le 17/08/2019 à 01:34, Josh Kunz via Qemu-devel a écrit :
>>> This is needed to support debugging PIE ELF binaries running under QEMU
>>> user mode. Currently, `code_offset` and `data_offset` remain unset for
>>> all ELF binaries, so GDB is unable to correctly locate the position of
>>> the binary's text and data.
>>>
>>> The fields `code_offset`, and `data_offset` were originally added way
>>> back in 2006 to support debugging of bFMT executables (978efd6aac6),
>>> and support was just never added for ELF. Since non-PIE binaries are
>>> loaded at exactly the address specified in the binary, GDB does not need
>>> to relocate any symbols, so the buggy behavior is not normally observed.
>>>
>>> Buglink: https://bugs.launchpad.net/qemu/+bug/1528239
>>> Signed-off-by: Josh Kunz <address@hidden>
>>> ---
>>>  linux-user/elfload.c | 2 ++
>>>  1 file changed, 2 insertions(+)
>>
>> As it seems they are text and data segment offsets, why it's not based
>> on info->start_code and info->start_data?
>>
>> Thanks,
>> Laurent
>>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]