From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21744 invoked by alias); 25 Mar 2018 19:19:48 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 21726 invoked by uid 89); 25 Mar 2018 19:19:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=investigated, factor, nowadays, UD:elf64-ppc.c X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 25 Mar 2018 19:19:46 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 035394067EF0 for ; Sun, 25 Mar 2018 19:19:45 +0000 (UTC) Received: from localhost.localdomain (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90BAF202699A for ; Sun, 25 Mar 2018 19:19:44 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v2 00/15] Fixing GNU ifunc support Date: Sun, 25 Mar 2018 19:19:00 -0000 Message-Id: <20180325191943.8246-1-palves@redhat.com> X-SW-Source: 2018-03/txt/msg00504.txt.bz2 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