From patchwork Mon Jul 22 13:26:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Monakov X-Patchwork-Id: 260696 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 68F872C0095 for ; Mon, 22 Jul 2013 23:26:48 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=liWmvEhDhYvpfOo8U6L/4OG51siNBbkoSXd/0FGbHcUFblunOHbJQ nt2ps7slL3EhjrA7LJoeBzy0TGJhcOkjP95yX6RHKNprJ72GLTfK43kSZhMCOg2E tCWrD8Sf5OqGxPuupENvqHC4ktH+LePYGPiAZ7SJvZpXnfvWfLPmKY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=AEF8INTxCGWwKzYn1g1w0dR17YI=; b=pgacF9xVUpgA2eXyQgl7 42D4oMNi4hxAT5CqpYtn6qIyztSUtj7pNqEU4l+816XR8JGOEME46HGSWNzwEg+F nPH365+T4PtyfAv7k8G7+lZrg+6a5RcikICnawIa0p/EPa99LrOM2DtuwrObkv5f KmXP/zt02guxTXaxskWNObM= Received: (qmail 22456 invoked by alias); 22 Jul 2013 13:26:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 22429 invoked by uid 89); 22 Jul 2013 13:26:41 -0000 X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL, BAYES_50, RDNS_NONE autolearn=no version=3.3.1 Received: from Unknown (HELO smtp.ispras.ru) (83.149.199.79) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 22 Jul 2013 13:26:39 +0000 Received: from [10.10.3.121] (unknown [83.149.199.91]) by smtp.ispras.ru (Postfix) with ESMTP id A859022221 for ; Mon, 22 Jul 2013 17:26:31 +0400 (MSK) Date: Mon, 22 Jul 2013 17:26:21 +0400 (MSK) From: Alexander Monakov To: gcc-patches@gcc.gnu.org Subject: libbacktrace: walk the elf_syminfo_data chain in elf_syminfo Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Hello, this fixes a bug (found by inspection) that would prevent elf_syminfo from looking up symbols defined in modules other than the executable. Bootstrapped and regtested together with the next patch on x86_64-linux (excluding Java, including Go), OK for trunk? libbacktrace/Changelog: 2013-07-22 Alexander Monakov * elf.c (elf_syminfo): Loop over the elf_syminfo_data chain. diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c index ef9bcdf..a90afaa 100644 --- a/libbacktrace/elf.c +++ b/libbacktrace/elf.c @@ -454,12 +454,15 @@ elf_syminfo (struct backtrace_state *state, uintptr_t pc, void *data) { struct elf_syminfo_data *edata; - struct elf_symbol *sym; + struct elf_symbol *sym = NULL; + + for (edata = (struct elf_syminfo_data *) state->syminfo_data; + edata && sym == NULL; + edata = edata->next) + sym = ((struct elf_symbol *) + bsearch (&pc, edata->symbols, edata->count, + sizeof (struct elf_symbol), elf_symbol_search)); - edata = (struct elf_syminfo_data *) state->syminfo_data; - sym = ((struct elf_symbol *) - bsearch (&pc, edata->symbols, edata->count, - sizeof (struct elf_symbol), elf_symbol_search)); if (sym == NULL) callback (data, pc, NULL, 0); else