This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v2 00/15] Fixing GNU ifunc support


What changed in v2:

  After Simon asked about it in response to patch #2 in v1, I
  investigated whether rela.plt ever contained relocations for .plt,
  or whether that patch fixing a mistake that was always there.
  Testing on some older systems I discovered that yes, indeed it used
  to be the case that rela.plt contained relocations for .plt on
  x86-64, so we still need to support that.  And, testing on PPC64
  showed another variant that we need to support as well.

  Also, testing on PPC64 (ELFv1) on the compile farm I discovered that
  most of the new tests added by the series failed there...  The main
  reason is that we don't currently handle gnu ifunc symbols on PPC64
  / function descriptors very well.  This is now fixed in this version
  of the series, and is the reason the series is now bigger.

Blurb from v1 follows:

Jakub Jelinek noticed that on Fedora 28, GDB can't call strlen:

  (top-gdb) p strlen("hello")
  $1 = (size_t (*)(const char *)) 0x7ffff554aac0 <__strlen_avx2>

That's clearly GDB printing the pointer to the ifunc target function
that implements strlen, instead of calling that function and printing
the result...

Suspecting that that might have been caused by my earlier improvements
to calling functions with no debug info, and improved support for
function aliases, I took a look.  And then I started writing a test,
which then uncovered a ton of problems...  All fixed by this series.

The main issue is that GDB's current ifunc support assumes that (and
the testcase exercises that) the resolver must be compiled without
debug info, and that the resolver has the same name as the user
visible function.

However, glibc nowadays implements ifunc resolvers in C using GCC's
__attribute__((ifunc)), and compiles them with debug info.
With __attribute__((ifunc)), the ifunc symbol has the user visible
name, and the resolver gets a regular function symbol with a different
name (what is passed to the attribute).

While fixing that, I thought I'd extend the existing testcase to
exercise all combination of

 - An ifunc set with __attribute__(ifunc) [different name as the
   user-visible symbol], vs set with

     asm (".type gnu_ifunc, %gnu_indirect_function");

   i.e., with the same name as the user-visible symbol.

 - ifunc resolver compiled with and without debug info.

 - ifunc target function compiled with and without debug info.

Of course that uncovered a whole slew of problems...

And then along the way noticed several other issues and added several
tests for them.  The testcase patch is added torward the end of the
series, because I honestly don't think I can effectively split it down
and split chunks into the patches that implement the fix.  Most of the
testcase changes need all the fixes in place to do any meaningful
testing.  The exception is the last patch in the series.

Pedro Alves (15):
  Fix breakpoints in ifunc after inferior resolved it (@got.plt symbol
    creation)
  Fix calling ifunc functions when resolver has debug info and different
    name
  Calling ifunc functions when target has no debug info but resolver has
  Calling ifunc functions when resolver has debug info, user symbol same
    name
  Fix elf_gnu_ifunc_resolve_by_got buglet
  Fix setting breakpoints on ifunc functions after they're already
    resolved
  Breakpoints, don't skip prologue of ifunc resolvers with debug info
  Eliminate find_pc_partial_function_gnu_ifunc
  Factor out minsym_found/find_function_start_sal overload
  For PPC64: elf_gnu_ifunc_record_cache: handle plt symbols in .text
    section
  Fix stepping past GNU ifunc resolvers (introduce lookup_msym_prefer)
  For PPC64/ELFv1: Introduce mst_data_gnu_ifunc
  PPC64: always make synthetic .text symbols for GNU ifunc symbols
  Extend GNU ifunc testcases
  Fix resolving GNU ifunc bp locations when inferior runs resolver

 bfd/elf64-ppc.c                             |  22 +-
 gdb/blockframe.c                            |  62 +++--
 gdb/breakpoint.c                            |  31 +--
 gdb/breakpoint.h                            |   8 +
 gdb/c-exp.y                                 |  25 +-
 gdb/elfread.c                               | 102 ++++---
 gdb/eval.c                                  |  25 +-
 gdb/gdbtypes.c                              |   4 -
 gdb/infcall.c                               |  58 ++--
 gdb/infcall.h                               |   9 +-
 gdb/linespec.c                              | 123 +++++---
 gdb/minsyms.c                               | 130 +++++----
 gdb/minsyms.h                               |  39 ++-
 gdb/parse.c                                 |  45 ++-
 gdb/symmisc.c                               |   1 +
 gdb/symtab.c                                |  88 ++++--
 gdb/symtab.h                                |  48 +++-
 gdb/testsuite/gdb.base/gnu-ifunc-final.c    |  22 ++
 gdb/testsuite/gdb.base/gnu-ifunc-lib.c      |  12 +-
 gdb/testsuite/gdb.base/gnu-ifunc.c          |   6 -
 gdb/testsuite/gdb.base/gnu-ifunc.exp        | 418 ++++++++++++++++++++++------
 gdb/testsuite/gdb.compile/compile-ifunc.exp |   9 +-
 22 files changed, 905 insertions(+), 382 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/gnu-ifunc-final.c

-- 
2.14.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]