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.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_2 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 1C1E2C433DF for ; Thu, 20 Aug 2020 17:36:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EFE14207DE for ; Thu, 20 Aug 2020 17:36:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730496AbgHTRgo convert rfc822-to-8bit (ORCPT ); Thu, 20 Aug 2020 13:36:44 -0400 Received: from wildebeest.demon.nl ([212.238.236.112]:46722 "EHLO gnu.wildebeest.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729122AbgHTRgl (ORCPT ); Thu, 20 Aug 2020 13:36:41 -0400 Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id DE21230278CD; Thu, 20 Aug 2020 19:36:37 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 8569E413CE8D; Thu, 20 Aug 2020 19:36:37 +0200 (CEST) Message-ID: Subject: Re: [PATCH bpf-next] tools/resolve_btfids: Fix sections with wrong alignment From: Mark Wielaard To: Yonghong Song , =?UTF-8?Q?F=C4=81ng-ru=C3=AC_S=C3=B2ng?= , Jiri Olsa Cc: Nick Desaulniers , Alexei Starovoitov , Daniel Borkmann , Nick Clifton , Jesper Dangaard Brouer , Network Development , bpf , Martin KaFai Lau , Song Liu , Andrii Nakryiko , John Fastabend , KP Singh , clang-built-linux Date: Thu, 20 Aug 2020 19:36:37 +0200 In-Reply-To: <7029ff8f-77d3-584b-2e7e-388c001cd648@fb.com> References: <20200819092342.259004-1-jolsa@kernel.org> <254246ed-1b76-c435-a7bd-0783a29094d9@fb.com> <20200819173618.GH177896@krava> <2e35cf9e-d815-5cd7-9106-7947e5b9fe3f@fb.com> <5ef90a283aa2f68018763258999fa66cd34cb3bb.camel@klomp.org> <7029ff8f-77d3-584b-2e7e-388c001cd648@fb.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Mailer: Evolution 3.28.5 (3.28.5-8.el7) Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi On Thu, 2020-08-20 at 08:51 -0700, Yonghong Song wrote: > > > Do you think we could skip these .debug_* sections somehow in elf > > > parsing in resolve_btfids? resolve_btfids does not need to read > > > these sections. This way, no need to change their alignment > > > either. > > > > The issue is that elfutils libelf will not allow writing out the > > section when it notices the sh_addralign field is setup wrongly. > > Maybe resolve_btfids can temporarily change sh_addralign to 4/8 > before elf manipulation (elf_write) to make libelf happy. > After all elf_write is done, change back to whatever the > original value (1). Does this work? Unfortunately no, because there is no elf_write, elf_update is how you write out the ELF image to disc. Since the code is using ELF_F_LAYOUT this will not change the actual layout of the ELF image if that is what you are worried about. And the workaround to set sh_addralign correctly before calling elf_update is precisely what the fix in elfutils libelf will do itself in the next release. Also binutils ld has been fixed to setup sh_addralign to 4/8 as appropriate now (in git). Cheers, Mark