Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp911383ybb; Fri, 10 Apr 2020 12:40:12 -0700 (PDT) X-Google-Smtp-Source: APiQypK3/AikQ2XSjVVAzV0gkaZYskQQLz0b3q7CneErjBc821uVyVnrEL8Q4JK31UgmQu2CkOXv X-Received: by 2002:a05:620a:a4f:: with SMTP id j15mr3596083qka.186.1586547612735; Fri, 10 Apr 2020 12:40:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586547612; cv=none; d=google.com; s=arc-20160816; b=L7EEKM8aL6jjqd8QEfGIKhe3prIJLXiCaLacuWm5r65aguqBtxUQFcMGJwVZh5hHb3 km4IaC9rP+GCvujL4x63b/Ow3lirkDnW7FeGw7/BojUI5euh0DvvpgpMnfNPS8XtlNU0 ngX1udDTyVMI43ZG9Pz/BTxSBUgv+FP5t6XFkJMKYS1gAYsdnStv2r8m9coZ3SwSo2Nm qQL1yKMYfnQQt44SzsYj9inP9Audxaf/xT4faeDrIoNl8Jci4XztKhEBIFVoBDue+9em DT1Zea8V4dXbCL0PVoZc9E9mBfdBNEMY/Kt1BgbHG7uEl8w/ifdcI0rDhQJUVjbtvpQn wGaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=mOD3UDimIjCea5dktHyiVtsc4qWHuSt7vAWBMr11jkw=; b=gGV7w1NsRluZEJgF5nmHPUaDzFhXL4Hvbfs+rihLoGX5ZxGqrjcKcySmfbANFC+40H Ly49m0j6dROp3mvKrPjWFx8GKGU9YhNar0YWS3XgKfGd1dI/M5c54L53m8u3xK952J7+ CuOA/yBlJ8deeRIg1IRJcaxA6s+peTEeXI/erydF3yqtqzX2ieUMCs2Z2ld6Mkb+LAcx TBlNpMKJunQhaWK7JxjgvRuEbCf9M7+w29Ls41mWl2LYZLbYaTR14f9jWlDVak6tCDVL 6dO5d9mwvkdrnnObg5eXq4KPVaAfuxkJm5AViVGzCOVpQ82Eq87+Zk3y26vcrora74zj FDCA== 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=QUARANTINE sp=NONE dis=NONE) header.from=vmware.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d13si1546821qvo.115.2020.04.10.12.39.57; Fri, 10 Apr 2020 12:40:12 -0700 (PDT) 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=QUARANTINE sp=NONE dis=NONE) header.from=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727041AbgDJTia (ORCPT + 99 others); Fri, 10 Apr 2020 15:38:30 -0400 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:28711 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726795AbgDJTi3 (ORCPT ); Fri, 10 Apr 2020 15:38:29 -0400 Received: from sc9-mailhost2.vmware.com (10.113.161.72) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Fri, 10 Apr 2020 12:38:24 -0700 Received: from sc9-mailhost3.vmware.com (unknown [10.166.69.226]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 3CCBFB2C9B; Fri, 10 Apr 2020 15:38:24 -0400 (EDT) From: Matt Helsley To: CC: Josh Poimboeuf , Peter Zijlstra , Julien Thierry , Ingo Molnar , Steven Rostedt , Miroslav Benes , Matt Helsley Subject: [RFC][PATCH 23/36] objtool: mcount: Move nop_mcount() Date: Fri, 10 Apr 2020 12:35:46 -0700 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII Received-SPF: None (EX13-EDG-OU-001.vmware.com: mhelsley@vmware.com does not designate permitted sender hosts) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The nop_mcount() function overwrites mcount calls that should be ignored with no-ops. This operation varies by architecture and wordsize so we retain the function pointers used to implement the fundamental operation while nop_mcount() itself is responsible for walking the relocations, determining if they should be turned into no-ops, then calling the arch-specific code. Since none of these use the recordmcount ELF wrappers anymore we can move it out of the wrapper. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 47 +++++++++++++++++++++++++++++++++ tools/objtool/recordmcount.h | 50 ------------------------------------ 2 files changed, 47 insertions(+), 50 deletions(-) diff --git a/tools/objtool/recordmcount.c b/tools/objtool/recordmcount.c index 65b7a34f2619..99938d5a5bb1 100644 --- a/tools/objtool/recordmcount.c +++ b/tools/objtool/recordmcount.c @@ -398,6 +398,53 @@ static int find_section_sym_index(unsigned const txtndx, return missing_sym; } +/* + * Read the relocation table again, but this time its called on sections + * that are not going to be traced. The mcount calls here will be converted + * into nops. + */ +static int nop_mcount(struct section * const rels, + const char *const txtname) +{ + struct rela *rela; + struct section *txts = find_section_by_index(lf, rels->sh.sh_info); + unsigned mcountsym = 0; + int once = 0; + + list_for_each_entry(rela, &rels->rela_list, list) { + int ret = -1; + + if (!mcountsym) + mcountsym = get_mcountsym(rela); + + if (mcountsym == GELF_R_INFO(rela->sym->idx, rela->type) && !is_fake_mcount(rela)) { + if (make_nop) { + ret = make_nop(txts, rela->offset); + if (ret < 0) + return -1; + } + if (warn_on_notrace_sect && !once) { + printf("Section %s has mcount callers being ignored\n", + txtname); + once = 1; + /* just warn? */ + if (!make_nop) + return 0; + } + } + + /* + * If we successfully removed the mcount, mark the relocation + * as a nop (don't do anything with it). + */ + if (!ret) { + rela->type = rel_type_nop; + rels->changed = true; + } + } + return 0; +} + /* 32 bit and 64 bit are very similar */ #include "recordmcount.h" #define RECORD_MCOUNT_64 diff --git a/tools/objtool/recordmcount.h b/tools/objtool/recordmcount.h index 4971258a2ab7..4bbdb6c107b8 100644 --- a/tools/objtool/recordmcount.h +++ b/tools/objtool/recordmcount.h @@ -20,7 +20,6 @@ #undef append_func #undef mcount_adjust #undef sift_rel_mcount -#undef nop_mcount #undef has_rel_mcount #undef tot_relsize #undef do_func @@ -37,7 +36,6 @@ #ifdef RECORD_MCOUNT_64 # define append_func append64 # define sift_rel_mcount sift64_rel_mcount -# define nop_mcount nop_mcount_64 # define has_rel_mcount has64_rel_mcount # define tot_relsize tot64_relsize # define do_func do64 @@ -53,7 +51,6 @@ #else # define append_func append32 # define sift_rel_mcount sift32_rel_mcount -# define nop_mcount nop_mcount_32 # define has_rel_mcount has32_rel_mcount # define tot_relsize tot32_relsize # define do_func do32 @@ -171,53 +168,6 @@ static uint_t *sift_rel_mcount(uint_t *mlocp, return mlocp; } -/* - * Read the relocation table again, but this time its called on sections - * that are not going to be traced. The mcount calls here will be converted - * into nops. - */ -static int nop_mcount(struct section * const rels, - const char *const txtname) -{ - struct rela *rela; - struct section *txts = find_section_by_index(lf, rels->sh.sh_info); - unsigned mcountsym = 0; - int once = 0; - - list_for_each_entry(rela, &rels->rela_list, list) { - int ret = -1; - - if (!mcountsym) - mcountsym = get_mcountsym(rela); - - if (mcountsym == GELF_R_INFO(rela->sym->idx, rela->type) && !is_fake_mcount(rela)) { - if (make_nop) { - ret = make_nop(txts, rela->offset); - if (ret < 0) - return -1; - } - if (warn_on_notrace_sect && !once) { - printf("Section %s has mcount callers being ignored\n", - txtname); - once = 1; - /* just warn? */ - if (!make_nop) - return 0; - } - } - - /* - * If we successfully removed the mcount, mark the relocation - * as a nop (don't do anything with it). - */ - if (!ret) { - rela->type = rel_type_nop; - rels->changed = true; - } - } - return 0; -} - static char const *has_rel_mcount(const struct section * const rels) { const struct section *txts; -- 2.20.1