Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3513502pxf; Mon, 15 Mar 2021 11:12:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqfGXLH8uRUqenFxPNsBU3aXliK7uQIrl1nH83Wr1s8QiGLze480Drb6sITDaNaPchWrVZ X-Received: by 2002:a17:906:2b9a:: with SMTP id m26mr24563610ejg.526.1615831963276; Mon, 15 Mar 2021 11:12:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615831963; cv=none; d=google.com; s=arc-20160816; b=XkEIlvjZfiWxM/vAOJSl0/vQ6ODp0uGoJar6Ka6Ir5foGzN3s4I7/fnSvg7LcRmohw yDcULPh2kalI/AgFRSHMNkycJRlMb+iDbVIZB4zumIjDmJ7SndbI7Ie/tmZQtToUR0oq /awKfPEv7aaJu8II88zMNBgl41VLYmMX3xvC0Jr6grm3wBBnL3RznjymACtvtaz3MTeA oG84EWhXZG055x8kf4vC9EWh+44im+MYdoZ1XNrCyXcid86uGb7qd01zbU9PIDxQ06kO HrgLhQZC3etjq3VP1dFmpfKzGC8GmqgIVUv8h6A0UgvkS2jZUIEqU0LYrnqmyPXCvbNT 9s9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=E2mOEcrlAWyHXmZlDTZ6aS4q8/CtTCvjOt/v1265bjw=; b=sPV4XThPGzkOOSL583544cn6CQU+TrRvmb1M1GpfEdXJOrQHqwMnFUSxrM4k/HpNL5 1YmZ+XOq435Oo9ZJ+xzsSOdnoqtemq3o1ov123zMOzL+DqXZPZC+2Yktay5UnQg8QI8p VabgChwBI8pAMRei20NI74mennx475WOc3eAW6rwMe8I2McCIibRiwP90e6gt1Bp42cq /kTyT1QONiN5Lxq59f9XZje7sFZjQkTyDc77HlzyZn9bcK+2pWSpzs6co1QNDIqfTgLN DAjM4RfANBts1JU0C6cQwavNjLYr8NbA9BOeWmg7gCIt9HdzrSCp9FxJKn22ZwMEyfO/ Jf+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Q4QbDMwh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w17si11325433ejk.520.2021.03.15.11.12.20; Mon, 15 Mar 2021 11:12:43 -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=@linuxfoundation.org header.s=korg header.b=Q4QbDMwh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235819AbhCOOLI (ORCPT + 99 others); Mon, 15 Mar 2021 10:11:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:37476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232301AbhCON6W (ORCPT ); Mon, 15 Mar 2021 09:58:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 93BE764F27; Mon, 15 Mar 2021 13:58:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816700; bh=JlX7I7P2oKyZTLg6QpqcGde9p+mPUDB9CsaboOaFBR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q4QbDMwhC+KLxPDYqT/s1q53ltKST8R37jlN4tVuDR1I9GlU2Tf0Aut09b/g0ZNoV d0cXajF6JTuXRKa6bvC52ei9tyzS3Xut2lc3A2vs3PdAmXLaCV9QcwJwwzROuJczpu v1hWQhXxisCTC/EMjEpmGpRTzPnKoH1k9tsJthCQ= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joe Lawrence , "Steven Rostedt (VMware)" , Manoj Gupta Subject: [PATCH 4.19 015/120] scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names Date: Mon, 15 Mar 2021 14:56:06 +0100 Message-Id: <20210315135720.514047684@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135720.002213995@linuxfoundation.org> References: <20210315135720.002213995@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Joe Lawrence commit 9c8e2f6d3d361439cc6744a094f1c15681b55269 upstream. When building with -ffunction-sections, the compiler will place each function into its own ELF section, prefixed with ".text". For example, a simple test module with functions test_module_do_work() and test_module_wq_func(): % objdump --section-headers test_module.o | awk '/\.text/{print $2}' .text .text.test_module_do_work .text.test_module_wq_func .init.text .exit.text Adjust the recordmcount scripts to look for ".text" as a section name prefix. This will ensure that those functions will be included in the __mcount_loc relocations: % objdump --reloc --section __mcount_loc test_module.o OFFSET TYPE VALUE 0000000000000000 R_X86_64_64 .text.test_module_do_work 0000000000000008 R_X86_64_64 .text.test_module_wq_func 0000000000000010 R_X86_64_64 .init.text Link: http://lkml.kernel.org/r/1542745158-25392-2-git-send-email-joe.lawrence@redhat.com Signed-off-by: Joe Lawrence Signed-off-by: Steven Rostedt (VMware) Cc: Manoj Gupta Signed-off-by: Greg Kroah-Hartman --- scripts/recordmcount.c | 2 +- scripts/recordmcount.pl | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) --- a/scripts/recordmcount.c +++ b/scripts/recordmcount.c @@ -401,7 +401,7 @@ static uint32_t (*w2)(uint16_t); static int is_mcounted_section_name(char const *const txtname) { - return strcmp(".text", txtname) == 0 || + return strncmp(".text", txtname, 5) == 0 || strcmp(".init.text", txtname) == 0 || strcmp(".ref.text", txtname) == 0 || strcmp(".sched.text", txtname) == 0 || --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl @@ -142,6 +142,11 @@ my %text_sections = ( ".text.unlikely" => 1, ); +# Acceptable section-prefixes to record. +my %text_section_prefixes = ( + ".text." => 1, +); + # Note: we are nice to C-programmers here, thus we skip the '||='-idiom. $objdump = 'objdump' if (!$objdump); $objcopy = 'objcopy' if (!$objcopy); @@ -523,6 +528,14 @@ while () { # Only record text sections that we know are safe $read_function = defined($text_sections{$1}); + if (!$read_function) { + foreach my $prefix (keys %text_section_prefixes) { + if (substr($1, 0, length $prefix) eq $prefix) { + $read_function = 1; + last; + } + } + } # print out any recorded offsets update_funcs();