Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3312248pxf; Mon, 15 Mar 2021 06:57:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwe1ODUWrSZiDIvj082d4nvmzfigYWDuRWwJtO4iE5D6TChEQXmubuybMtDzILzsjLTuffQ X-Received: by 2002:a17:906:7806:: with SMTP id u6mr3461576ejm.130.1615816636343; Mon, 15 Mar 2021 06:57:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615816636; cv=none; d=google.com; s=arc-20160816; b=mYoo24POxeNxoy6ig97dTQXQV0YMhGsID/2RK0X8JNF/WU4R2TfsCvg4uf+3RcXBOS QsXU8RmuVRSCHjokwwYOI4lnJQl4GtlPuhKH+IJIrgpcjG8UMGa8zghb6p+bzNTK1Rah 6MpTes4aZm2GobojNfoiFE6Tju+wHQMqhtpFE9gN1GdZhHjJr5SlPh2xxgxwsle48foP P79KWg+h6g8tBCGQPYgvO5TmwjPkusJXJy3i0y9dUCkA2bHDNqOxpe/UxFc+uZ3PU+1A yqjJbnbcCkhHloutjQZLqWh0LxbQzy2cqxe4WtH9/U75nbxJnl7LMnv/X/M9AFz69o2h KzRA== 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=PevMW51OEh2AAVsMpZiB10qEt35tLniYE4F6ghAQPcA=; b=OlKR2finwvWsxDcrKtAefxEQaOQfLYlW0gg5euwhfSWGgeKrsjLFK0Wi6XcMLgbRpw fiknwrfRgSDprYi6xJYQlVf7hayA+yQaur8ULI+SKlJ0EnV1E22+TvzQZDddYfLuhYGt 8KonQddWk38iVuAJAfrr4yqCD43D1Z8AeuxWxTdMyDctDvoNX1vBMzyhM7HG04E5RTP2 44Xa3g7qHOQbcFwZshXhxXghQeujlQ0vZP00HAi9E6IMxQv9zJ6xJIYoyfVKNGEED9gq fN3pxuw94Q5tVeZ/gI+ri6FY1iHpAPqBuGje20BqcefcUxtEyf9GqfSJjGT+VKh3xoVZ M7YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v+8LtCcL; 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 ca3si10979084ejb.561.2021.03.15.06.56.53; Mon, 15 Mar 2021 06:57:16 -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=v+8LtCcL; 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 S229771AbhCONzs (ORCPT + 99 others); Mon, 15 Mar 2021 09:55:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:56824 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230468AbhCONxo (ORCPT ); Mon, 15 Mar 2021 09:53:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 25E5764DAD; Mon, 15 Mar 2021 13:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816423; bh=+qXyopVlb6I52eh4Prd0dbNBohQZskhhj/Q2fdKsKLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v+8LtCcLrmqyfLKDDeTebK4UXTORkDiuOnm4EDgI8Uc6BTLH3zagZxi/15fYKrgsN 7Bqh8HXyDVEyoA+Re70dy9gbpKbpghcbWJGXFDizyviN5Y34IlqicK/hXvXemoSfka smWDL7fnvnG0jy6iLh0Dctt3xkMekIt2o0MEfPZI= 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.9 30/78] scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names Date: Mon, 15 Mar 2021 14:51:53 +0100 Message-Id: <20210315135213.061571101@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135212.060847074@linuxfoundation.org> References: <20210315135212.060847074@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 @@ -140,6 +140,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); @@ -505,6 +510,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();