From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22266 invoked by alias); 25 Mar 2018 19:19:51 -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 22172 invoked by uid 89); 25 Mar 2018 19:19:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-22.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD,UNSUBSCRIBE_BODY autolearn=ham version=3.3.2 spammy= 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:49 +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 2860A84256 for ; Sun, 25 Mar 2018 19:19:48 +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 CD9F3202699A for ; Sun, 25 Mar 2018 19:19:47 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v2 05/15] Fix elf_gnu_ifunc_resolve_by_got buglet Date: Sun, 25 Mar 2018 19:19:00 -0000 Message-Id: <20180325191943.8246-6-palves@redhat.com> In-Reply-To: <20180325191943.8246-1-palves@redhat.com> References: <20180325191943.8246-1-palves@redhat.com> X-SW-Source: 2018-03/txt/msg00505.txt.bz2 The next patch will add a call to elf_gnu_ifunc_resolve_by_got that trips on a latent buglet -- the function is writing to its output parameter even if the address wasn't found, confusing the caller. The function's intro comment says: /* Try to find the target resolved function entry address of a STT_GNU_IFUNC function NAME. If the address is found it is stored to *ADDR_P (if ADDR_P is not NULL) and the function returns 1. It returns 0 otherwise. So fix the function accordingly. gdb/ChangeLog: yyyy-mm-dd Pedro Alves * elfread.c (elf_gnu_ifunc_resolve_by_got): Don't write to *ADDR_P unless we actually resolved the ifunc. --- gdb/elfread.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gdb/elfread.c b/gdb/elfread.c index 9ffbf99db6e..82ab3d891ce 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -840,10 +840,12 @@ elf_gnu_ifunc_resolve_by_got (const char *name, CORE_ADDR *addr_p) ¤t_target); addr = gdbarch_addr_bits_remove (gdbarch, addr); - if (addr_p) - *addr_p = addr; if (elf_gnu_ifunc_record_cache (name, addr)) - return 1; + { + if (addr_p) + *addr_p = addr; + return 1; + } } return 0; -- 2.14.3