Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4192968pxv; Tue, 29 Jun 2021 00:57:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdKzVSgVe/vgxXN4Ku8xnw4QzGd8HW0QfXIgRNbvG0Tv3riCMRKTIECaAY07YQCXrjX4fQ X-Received: by 2002:aa7:db0c:: with SMTP id t12mr39008063eds.112.1624953440355; Tue, 29 Jun 2021 00:57:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624953440; cv=none; d=google.com; s=arc-20160816; b=rPZ7p3tQUjLQ6UCQgeBNpW5FvRnbWNFpyaV3OyHiRYU1cuEwkhqARWvoGy/rkCw1Ks C1Y+K9cxe9tCPqL5yUJDqZUoe5jl/DG1QiNj9fUHmJHTu0hod9LU9hyjtLXzLplPjVdu 8VnFcUL+yKqK6vZe0CUpUy/PlQC/bCr/a49GayIFBJDwJ5utI9I417+IBDMvU91ItZDV bQOEudibVPByM7QdkD0HExrUE20DNdxrhtBli3xx2O2xJ46nH0lADvteF0truzydwzIQ szUrmWLen9pIozv7CzFtdyB6GbNoWzBTz18R3pIoi3eS4bG9g3NyipBgNxlYTGEn7F1l 5grA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature:dkim-signature; bh=y8kuYq5+fn9VlY2gb7eT3rq5F1CZFlH38xoKf54rl1A=; b=QOmOubZ9c6hCCDZ8eoHhxfkmdfMPHTQxTTUU2WhayyxYatA3lm/DG5XId1O/T8DP5N CcTg5XyE0TNHaO0YW28HABIoxQ++74QwkXSn3zYN3osVSWMpoQQ9oQQRyzm6HtvJ/487 9ECjz+LJt8CmiEPHkZA2iRYscJCubUaBf6AAN0vBBPmSljs4IYOsLUcpUpYK64DfCgBO JKHnV5YuZuOY4A5vXV9CIV4YS+vm8eyZEmZQKWNsIRt1XTNWnLN4/UttdjsqdYWfAVaJ LuwpVTMnyCnt9+jNCSTrtBgHSRzzNM1WMnhVpnQVNfzu+Ziq7Xxzhhp/q7bBUz2lM7oS raYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=GZx4BoaB; dkim=neutral (no key) header.i=@suse.cz header.b=hzL8E4Py; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o9si16214398edq.547.2021.06.29.00.56.57; Tue, 29 Jun 2021 00:57:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=GZx4BoaB; dkim=neutral (no key) header.i=@suse.cz header.b=hzL8E4Py; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232330AbhF2H5o (ORCPT + 99 others); Tue, 29 Jun 2021 03:57:44 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:54604 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232182AbhF2H5n (ORCPT ); Tue, 29 Jun 2021 03:57:43 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 31DF922618; Tue, 29 Jun 2021 07:55:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1624953316; h=from:from:reply-to: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=y8kuYq5+fn9VlY2gb7eT3rq5F1CZFlH38xoKf54rl1A=; b=GZx4BoaBQcuqmMYnqu8rkBicS8GbaZnUrpIYTL0L8LQbhB7gNhJ7A4NeDxIOpFhEJQIYSD rr0rxZKll/8gmi9K5e7W9zj/YAmoGXTlLnklza2VrgoKPktwktkfFDFNlHRfTrPRK2P6Pu TS/iyKPZt8zPOSKec+Ga+kJvgA7Sbl4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1624953316; h=from:from:reply-to: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=y8kuYq5+fn9VlY2gb7eT3rq5F1CZFlH38xoKf54rl1A=; b=hzL8E4PyiU0gW87JpJ5ulBr/V0daCHQ5bSNdv8RYhIEAQpOTo6MVsu6T0cQeYtzxTC4+IP EpWhPV7+MYCGgOCQ== Received: from pobox.suse.cz (pobox.suse.cz [10.100.2.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 22AF9A3B8C; Tue, 29 Jun 2021 07:55:16 +0000 (UTC) Date: Tue, 29 Jun 2021 09:55:16 +0200 (CEST) From: Miroslav Benes To: Michael Forney cc: Josh Poimboeuf , Peter Zijlstra , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] objtool: Update section header before relocations In-Reply-To: <20210509000103.11008-2-mforney@mforney.org> Message-ID: References: <20210509000103.11008-1-mforney@mforney.org> <20210509000103.11008-2-mforney@mforney.org> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 8 May 2021, Michael Forney wrote: > The libelf implemention from elftoolchain has a safety check in > gelf_update_rel[a] to check that the data corresponds to a section > that has type SHT_REL[A] [0]. If the relocation is updated before > the section header is updated with the proper type, this check > fails. > > To fix this, update the section header first, before the relocations. > Previously, the section size was calculated in elf_rebuild_reloc_section > by counting the number of entries in the reloc_list. However, we > now need the size during elf_write so instead keep a running total > and add to it for every new relocation. > > [0] https://sourceforge.net/p/elftoolchain/mailman/elftoolchain-developers/thread/CAGw6cBtkZro-8wZMD2ULkwJ39J+tHtTtAWXufMjnd3cQ7XG54g@mail.gmail.com/ > > Signed-off-by: Michael Forney Reviewed-by: Miroslav Benes M