public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 00/15] Fixing GNU ifunc support
@ 2018-03-25 19:19 Pedro Alves
  2018-03-25 19:19 ` [PATCH v2 15/15] Fix resolving GNU ifunc bp locations when inferior runs resolver Pedro Alves
                   ` (15 more replies)
  0 siblings, 16 replies; 33+ messages in thread
From: Pedro Alves @ 2018-03-25 19:19 UTC (permalink / raw)
  To: gdb-patches

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

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2018-06-19 18:47 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-25 19:19 [PATCH v2 00/15] Fixing GNU ifunc support Pedro Alves
2018-03-25 19:19 ` [PATCH v2 15/15] Fix resolving GNU ifunc bp locations when inferior runs resolver Pedro Alves
2018-03-25 19:19 ` [PATCH v2 08/15] Eliminate find_pc_partial_function_gnu_ifunc Pedro Alves
2018-03-25 19:19 ` [PATCH v2 03/15] Calling ifunc functions when target has no debug info but resolver has Pedro Alves
2018-04-01  4:22   ` Simon Marchi
2018-04-10 21:48     ` Pedro Alves
2018-04-10 21:54       ` Pedro Alves
2018-03-25 19:19 ` [PATCH v2 01/15] Fix breakpoints in ifunc after inferior resolved it (@got.plt symbol creation) Pedro Alves
2018-04-01  3:35   ` Simon Marchi
2018-04-10 21:20     ` Pedro Alves
2018-04-14 16:36       ` Simon Marchi
2018-03-25 19:19 ` [PATCH v2 02/15] Fix calling ifunc functions when resolver has debug info and different name Pedro Alves
2018-04-01  3:44   ` Simon Marchi
2018-04-10 21:20     ` Pedro Alves
2018-03-25 19:19 ` [PATCH v2 05/15] Fix elf_gnu_ifunc_resolve_by_got buglet Pedro Alves
2018-04-01  4:32   ` Simon Marchi
2018-04-10 21:52     ` Pedro Alves
2018-03-25 19:19 ` [PATCH v2 11/15] Fix stepping past GNU ifunc resolvers (introduce lookup_msym_prefer) Pedro Alves
2018-06-18 20:26   ` [PATCH] Silence GCC "uninitialized" warning on minsyms.c:lookup_minimal_symbol_by_pc_section Sergio Durigan Junior
2018-06-19 15:22     ` Pedro Alves
2018-06-19 16:55       ` Sergio Durigan Junior
2018-06-19 18:47       ` Tom Tromey
2018-03-25 19:19 ` [PATCH v2 07/15] Breakpoints, don't skip prologue of ifunc resolvers with debug info Pedro Alves
2018-03-25 19:19 ` [PATCH v2 12/15] For PPC64/ELFv1: Introduce mst_data_gnu_ifunc Pedro Alves
2018-03-25 19:25 ` [PATCH v2 04/15] Calling ifunc functions when resolver has debug info, user symbol same name Pedro Alves
2018-03-25 19:25 ` [PATCH v2 09/15] Factor out minsym_found/find_function_start_sal overload Pedro Alves
2018-03-25 19:28 ` [PATCH v2 14/15] Extend GNU ifunc testcases Pedro Alves
2018-03-25 19:29 ` [PATCH v2 06/15] Fix setting breakpoints on ifunc functions after they're already resolved Pedro Alves
2018-03-25 19:29 ` [PATCH v2 10/15] For PPC64: elf_gnu_ifunc_record_cache: handle plt symbols in .text section Pedro Alves
2018-03-25 19:29 ` [PATCH v2 13/15] PPC64: always make synthetic .text symbols for GNU ifunc symbols Pedro Alves
2018-03-25 19:33   ` Pedro Alves
2018-03-26  7:54   ` Alan Modra
2018-04-26 12:23 ` [PATCH v2 00/15] Fixing GNU ifunc support Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).