public inbox for dwarves@vger.kernel.org
 help / color / mirror / Atom feed
From: Yonghong Song <yonghong.song@linux.dev>
To: Yao Zi <me@ziyao.cc>, Alan Maguire <alan.maguire@oracle.com>
Cc: dwarves@vger.kernel.org, bpf@vger.kernel.org, q66 <me@q66.moe>
Subject: Re: [PATCH dwarves] dwarf_loader: Handle DW_AT_location attrs containing DW_OP_plus_uconst
Date: Tue, 16 Dec 2025 20:12:52 -0800	[thread overview]
Message-ID: <7e57cc87-9258-4d9e-a01c-c76f8938ae46@linux.dev> (raw)
In-Reply-To: <aT0hjyVstASDsl-E@pie>



On 12/13/25 12:20 AM, Yao Zi wrote:
> Hi Yonghong,
>
> Sorry for the late reply,
>
> On Wed, Dec 03, 2025 at 04:46:20PM -0800, Yonghong Song wrote:
>>
>> On 11/29/25 7:21 PM, Yao Zi wrote:
> ...
>
>>> diff --git a/dwarf_loader.c b/dwarf_loader.c
>>> index 79be3f516a26..635015676389 100644
>>> --- a/dwarf_loader.c
>>> +++ b/dwarf_loader.c
>>> @@ -708,6 +708,11 @@ static enum vscope dwarf__location(Dwarf_Die *die, uint64_t *addr, struct locati
>>>    		case DW_OP_addrx:
>>>    			scope = VSCOPE_GLOBAL;
>>>    			*addr = expr[0].number;
>>> +
>>> +			if (location->exprlen == 2 &&
>>> +			    expr[1].atom == DW_OP_plus_uconst)
>>> +				addr += expr[1].number;
>> This does not work. 'addr' is the parameter and the above new 'addr' value won't
>> pass back to caller so the above is effectively a noop.
> Oops, this is a silly problem.
>
>> I think we need to add an additional parameter to pass the 'expr[1].number' back
>> to the caller, e.g.,
> However, I don't think it's necessary. See my explanation below,
>
>> static enum vscope dwarf__location(Dwarf_Die *die, uint64_t *addr, uint32_t *offset, struct location *location) { ... }
>>
>> and
>>
>>     in the above
>>         *offset = expr[1].number.
>>
>> Now the caller has the following information:
>>    . The deference of *addr stores the index to .debug_addr
> No, dwarf__location() invokes attr_location(), which calls
> dwarf_getlocation() and dwarf_formaddr(), the latter already performs a
> lookup in .debug_addr[1], so what is stored in *addr is right the symbol
> address.
>
> Thus I think it's enough to keep the signature, but add the offset to
> *addr.

Indeed, this does make sense. Thanks for explanation.

>
>>    . The offset to the address in .debug_addr
>> and the final address will be debug_addr[*addr] + offset.
>>
>>> +
>>>    			break;
>>>    		case DW_OP_reg1 ... DW_OP_reg31:
>>>    		case DW_OP_breg0 ... DW_OP_breg31:
> Thanks for your review, I'll soon send a patch with the missing pointer
> dereference to addr added.
>
> Best regards,
> Yao Zi
>
> [1]: https://github.com/sourceware-org/elfutils/blob/67199e1c974db37f2bd200dcca7d7103f42ed06e/libdw/dwarf_formaddr.c#L37-L77


      reply	other threads:[~2025-12-17  4:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-30  3:21 [PATCH dwarves] dwarf_loader: Handle DW_AT_location attrs containing DW_OP_plus_uconst Yao Zi
2025-12-04  0:46 ` Yonghong Song
2025-12-13  8:20   ` Yao Zi
2025-12-17  4:12     ` Yonghong Song [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7e57cc87-9258-4d9e-a01c-c76f8938ae46@linux.dev \
    --to=yonghong.song@linux.dev \
    --cc=alan.maguire@oracle.com \
    --cc=bpf@vger.kernel.org \
    --cc=dwarves@vger.kernel.org \
    --cc=me@q66.moe \
    --cc=me@ziyao.cc \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox