[PATCH v2] gdbserver: Check r_version < 1 for Linux debugger interface

H.J. Lu hjl.tools@gmail.com
Tue Aug 17 14:04:25 GMT 2021


On Tue, Aug 17, 2021 at 6:48 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu via Gdb-patches:
>
> > Set r_version == 2 breaks GDB due to
> >
> > static CORE_ADDR
> > solib_svr4_r_ldsomap (struct svr4_info *info)
> > {
> >   struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
> >   struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
> >   enum bfd_endian byte_order = type_byte_order (ptr_type);
> >   ULONGEST version = 0;
> >
> >   try
> >     {
> >       /* Check version, and return zero if `struct r_debug' doesn't have
> >          the r_ldsomap member.  */
> >       version
> >         = read_memory_unsigned_integer (info->debug_base +
> > lmo->r_version_offset,
> >                                         lmo->r_version_size, byte_order);
> >     }
> >   catch (const gdb_exception_error &ex)
> >     {
> >       exception_print (gdb_stderr, ex);
> >     }
> >
> >   if (version < 2 || lmo->r_ldsomap_offset == -1)
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >
> > glibc doesn't have r_ldsomap.  But r_ldsomap_offset is set
> > unconditionally.   Shouldn't it be set only if the target debugger
> > interface has it?
>
> glibc should add r_ldsomap_offset and switch its own version number to
> 3, I think.

We can add an OS flavor field to struct link_map_offsets for this.

-- 
H.J.


More information about the Libc-alpha mailing list