Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3311755pxf; Mon, 15 Mar 2021 06:56:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGcmu8RMADzx+YR7C2S8k451q1/HaGmwkkD0hP58q2NL+byftVvjPpirop84u7d95XO/WS X-Received: by 2002:aa7:c0c7:: with SMTP id j7mr30027502edp.298.1615816591957; Mon, 15 Mar 2021 06:56:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615816591; cv=none; d=google.com; s=arc-20160816; b=adn7R1EAz2kNg1lz8Yjpx6vDqE0wjLMHkoHPsoOmTWN6mOIzD6XpacKmuPQm96TLIa R+A2ZjZ19Pqb5I6PuafOBKzHQkvu2xcD5KMriGvxtsRC3ZOQKsksVpKHiI5W4/WGdJrG QdZJ/pGr19MYLgY+STHI79xvhyeZM+pnB23UiIYnetCPBc3RwqLKuebovgCWwIjVIv89 fmpFT7epUJMeK+3qi5GbEViGEhsLxuzQmK8EE0mJDQuaqcrTlFB42cHjybpvgg2Dx1cK o24YwxD7hK1W4tZQb7Of8CMqJIqqasPizJ7ARxoVnvx9uriX9q8g7ywmf+YEKwCoR5en xapg== 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=MxC+TMYgxmzIgKaRGFu271Sx2U7i1OLfw7hEDhFrI2Q=; b=Ll52+fdYVS/INQCAO7aZkwBqxPd+r/QOWfpfhnMBbxltZ+As/AB00MpliPtQelP5L5 KJZtV4v60zlmWnPvxwJXZ5dFNNyJKIb3w9Oqo84PuJyzGPwna0kLXnPp+fmiOps5upRJ w1W8wzr5B2K5jVIA0CYfRbCKWBzFNhd/5fd4wgklzteLAy6w4tMPjf0MPHkbKIb67sbu ASzKoDZq/KlYppsFsrEDsRz5M9AG/NOlqBDYAwmmXMOHYcbK2Avnk5EpWcMfibyH8Cew 33DD0RIpbTEi5K0X3FNGZKU4h9NyQ5m8wXucVOV2/TAlKONybFfTOhAmLHbp38/cate7 wbow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2RxDrTIX; 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 i6si10655231ejz.383.2021.03.15.06.56.09; Mon, 15 Mar 2021 06:56:31 -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=2RxDrTIX; 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 S231702AbhCONzJ (ORCPT + 99 others); Mon, 15 Mar 2021 09:55:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:56020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229862AbhCONxf (ORCPT ); Mon, 15 Mar 2021 09:53:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 710EF64E89; Mon, 15 Mar 2021 13:53:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816415; bh=FtIlBKzTfqgeGJmalhihGEyYPSM9sR2gGgMJ3OCec/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2RxDrTIXgn/1Tz1qB3nnya4ln1VznaxPPdYitI02jNjP5FkuGEptSzQ02tJjLgYiV LkbkCcJ+WmP+CglSI5nKxzmhJiKQ2XFYTfpYxy/wNRdy+iOOpb6Y2OylYmzWzcSWoo Rzdbc/NZuU0NP6QUfP0ER7hdwGKTstxLt9HzgplI= 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.4 30/75] scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names Date: Mon, 15 Mar 2021 14:51:44 +0100 Message-Id: <20210315135209.245759526@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135208.252034256@linuxfoundation.org> References: <20210315135208.252034256@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) [Manoj: Resolve conflict on 4.4.y/4.9.y because of missing 42c269c88dc1] Signed-off-by: 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 @@ -362,7 +362,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(".ref.text", txtname) == 0 || strcmp(".sched.text", txtname) == 0 || strcmp(".spinlock.text", txtname) == 0 || --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl @@ -138,6 +138,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); @@ -503,6 +508,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();