From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A182C433DB for ; Sat, 23 Jan 2021 20:17:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED1B722D50 for ; Sat, 23 Jan 2021 20:17:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726173AbhAWUQ4 (ORCPT ); Sat, 23 Jan 2021 15:16:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:38638 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726249AbhAWUQz (ORCPT ); Sat, 23 Jan 2021 15:16:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611432928; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WlLkcbbh75RGPk5JxgfyipxpMbnbZsxB7tUvYuilHNg=; b=OqOTrHqRz1mNdMiuw6KG10bvNi3oUMCy4q325mwAKHuRjZg08/QXhLG0R1niwHS8lzQiI8 dKrPKNEvGSnbtfexZmqw02U+Z6rRJugGr7USJ6RY518JXrBhNK/Bl0JH8bM7LHzdLVScKp B1A1Gw/7g0rs8zB868ggA51bZ+O9/PU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-588-MK3q52p4Oeenwe1ynbkLVQ-1; Sat, 23 Jan 2021 15:15:24 -0500 X-MC-Unique: MK3q52p4Oeenwe1ynbkLVQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 285D0801FAE; Sat, 23 Jan 2021 20:15:22 +0000 (UTC) Received: from krava (unknown [10.40.192.55]) by smtp.corp.redhat.com (Postfix) with SMTP id 3E25B19C44; Sat, 23 Jan 2021 20:15:14 +0000 (UTC) Date: Sat, 23 Jan 2021 21:15:14 +0100 From: Jiri Olsa To: Mark Wielaard Cc: Andrii Nakryiko , Jiri Olsa , Arnaldo Carvalho de Melo , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , dwarves@vger.kernel.org, Networking , bpf , Yonghong Song , Hao Luo , Martin KaFai Lau , Song Liu , John Fastabend , KP Singh , Joe Lawrence Subject: Re: [PATCH 2/3] bpf_encoder: Translate SHN_XINDEX in symbol's st_shndx values Message-ID: <20210123201514.GB117714@krava> References: <20210121202203.9346-1-jolsa@kernel.org> <20210121202203.9346-3-jolsa@kernel.org> <20210122204654.GB70760@krava> <20210123185143.GA117714@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Sat, Jan 23, 2021 at 09:08:15PM +0100, Mark Wielaard wrote: > Hi Jiri, > > On Sat, 2021-01-23 at 19:51 +0100, Jiri Olsa wrote: > > On Fri, Jan 22, 2021 at 02:55:51PM -0800, Andrii Nakryiko wrote: > > > > > > > I don't understand this.. gelf_getsymshndx will return both > > > > symbol and proper index, no? also sym_sec_idx is already > > > > assigned from previou call > > > > > > Reading (some) implementation of gelf_getsymshndx() that I found > > > online, it won't set sym_sec_idx, if the symbol *doesn't* use > > > extended > > > numbering. But it will still return symbol data. So to return the > > > > the latest upstream code seems to set it always, > > but I agree we should be careful > > > > Mark, any insight in here? thanks > > GElf_Sym * > gelf_getsymshndx (Elf_Data *symdata, Elf_Data *shndxdata, int ndx, > GElf_Sym *dst, Elf32_Word *dstshndx) > > Will always set *dst, but only set *dstshndx if both it and shndxdata > are not NULL and no error occurred (the function returns NULL and set > libelf_error in case of error). > > So as long as shndxdata != NULL you can rely on *dstshndx being set. > Otherwise you get the section index from dst->st_shndx. ok, so it's as Andrii said, I'll make the extra check then thanks, jirka