Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1182984imu; Tue, 20 Nov 2018 13:06:27 -0800 (PST) X-Google-Smtp-Source: AFSGD/XYQXScXhECD3RzUfzWHmr3Yo0m1O5SwdWdoRFm7ZHmqF0Q8wADOTD4I5u3geO/DPyoNmL1 X-Received: by 2002:a17:902:8ec9:: with SMTP id x9mr3932200plo.27.1542747987618; Tue, 20 Nov 2018 13:06:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542747987; cv=none; d=google.com; s=arc-20160816; b=mw2GxAnXRpBPKC/HAt0Qquu6TjYdNTqjYt0tQMc+AnIojnAesgAEYQ0RQ5vOz8x5hg VcoJQP+4u+iNAwjFcjNMFWy6RqubXEK4LbEtjtTnroJBNWizdqXnP2UhQlqYpT6+x8tJ CgsL5E0ITKjnWCNvmoH+L1xYUxHuSWijWe62F4xbmxJWdRtCE42r/IgtFIw18TSG6kJi dx92njmlOR59CXjNy8PsVCCFl3d2rwe77A/Ud3afxkiqT0Z+LYvm++9mSOVWJdAgd/FO KAOodkjv3kZyx8Zg08xvQRfNEY+6G/bsMykmzj6TsYmSMYpgLokHe6Yr67EtriZmrmgT DPUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=C7luXOTCa3m45RP8zKHaaaYT04LLvHk+dg/kFH49Dx0=; b=k+8G4ux8mpOMM53xJOHLBgfTUN6CkHMJuazIkYmfz2uVFjQjQx1aHJVgsBQ4R/cSeV agTqq06ESoPym7RLWn6meImIBe+UcXI5fQ8+Fg/QLgfpunWg+RHhbchDmKaBxrAcVo43 irNrQduAKdbF8Lji5jqrRjKmOcXKUbCoNOiOtwzfRMpNzc3P7j8vCzfRoL9JfODYl5kD 4i9syUV+Msy4YKc0q7Xvqd/OeSACzYAU0OUMj3yAaDVu2grUZDlHaLKYvrttLeKgsHVq rW5vW5Xf9PORdlmTlYIlG6/YPNINYIdrSX/c22BlKsn10mPVK9eqwegmSAovrxYSQDGy rn5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c8si5068044pgl.507.2018.11.20.13.06.11; Tue, 20 Nov 2018 13:06:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727673AbeKUGuZ (ORCPT + 99 others); Wed, 21 Nov 2018 01:50:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59404 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725865AbeKUGuZ (ORCPT ); Wed, 21 Nov 2018 01:50:25 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C3DBD3082DDB; Tue, 20 Nov 2018 20:19:30 +0000 (UTC) Received: from jlaw-desktop.bos.com (dhcp-17-208.bos.redhat.com [10.18.17.208]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43F5568D4A; Tue, 20 Nov 2018 20:19:30 +0000 (UTC) From: Joe Lawrence To: linux-kernel@vger.kernel.org Cc: Steven Rostedt , Masahiro Yamada Subject: [RFC PATCH 1/1] scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names Date: Tue, 20 Nov 2018 15:19:18 -0500 Message-Id: <1542745158-25392-2-git-send-email-joe.lawrence@redhat.com> In-Reply-To: <1542745158-25392-1-git-send-email-joe.lawrence@redhat.com> References: <1542745158-25392-1-git-send-email-joe.lawrence@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 20 Nov 2018 20:19:30 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Joe Lawrence --- scripts/recordmcount.c | 2 +- scripts/recordmcount.pl | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c index 895c40e8679f..a50a2aa963ad 100644 --- a/scripts/recordmcount.c +++ b/scripts/recordmcount.c @@ -397,7 +397,7 @@ static uint32_t w2nat(uint16_t const x) 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 || diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index f599031260d5..68841d01162c 100755 --- 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); @@ -519,6 +524,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(); -- 1.8.3.1