Re: [PATCH] Fix GDB internal error by using text (instead of data) section offset

Tom Tromey
2022-01-26T18:04:52Z

Kevin> #3 0x000000000097c630 in stap_probe::get_relocated_address (this=0xa1a17a0,
Kevin> objfile=0x4fa48f0)
Kevin> at gdb/stap-probe.c:1341

One oddity here is that get_relocated_address calls this->get_address(),
which returns m_address, which is documented as:

/* The address where the probe is inserted, relative to
SECT_OFF_TEXT. */
CORE_ADDR m_address;

So using SECT_OFF_DATA here seems wrong in the first place.

Kevin> The obvious solution is to use some other section offset instead - as
Kevin> I recall, on Linux, the section offsets (for those sections which
Kevin> exist) will all be the same.

Is this a Linux thing or an ELF thing? I don't know.

Kevin> So, what happens if there's no .text section?

Not probe-related but this is already a way to crash gdb:

https://sourceware.org/bugzilla/show_bug.cgi?id=19342
https://sourceware.org/bugzilla/show_bug.cgi?id=25678

... which is why I was curious about the ELF thing. Like perhaps this
could all be made more robust somehow.

Your patch seems fine to me, though I don't have any idea if the dtrace
part is correct.

Tom