Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3835154ybf; Tue, 3 Mar 2020 13:51:09 -0800 (PST) X-Google-Smtp-Source: ADFU+vvcLY7JYiaSTYcSXhbpUXw61D5ALvJWGr3PeJWBXVJ6IHPkwGMOpKTGkYo2EAOroJAMBnaP X-Received: by 2002:aca:1b11:: with SMTP id b17mr448170oib.45.1583272268797; Tue, 03 Mar 2020 13:51:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583272268; cv=none; d=google.com; s=arc-20160816; b=tFWc9I/8S7V5NxeiYkL5uW8Z4LbwYmEFs7/xy6dKFCYx6L4ubVyIFZbd3KyKpSb4DU zhaesXzDWbjis9xzcFF1HkEtozvPyrLVb0o5yU2xsEXscCOFmm5H6dJGl/GaDZkOdDPQ oNGzWAyItKWxZv+mFuuDndklyXU3jUST1pdfjGQg3op7xAzVvgnrRHJFtzqzWdrqacnE J3XCwcpg/dvGob9uN/gEIgDh9MIi93oMOejK/scL2mhe+cZwim+sNa6dDfmzR44JH17r wMQMds+Y/jyZNNoxcWNQk7DkLNvldg204kH9yOijOGKssPGWkUUsj0ZfJdlGs9g1PJnI S7eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ILFaru9VkZkMm/uyrzqiQJ9WG3dQIfoo+O/VJBbEFZM=; b=0CMwtwHf8xjCYBYl9MEiAJG9rr8dbmqKKQxboXcivKVAFxfdWv4McUBXM1T5kHx0LT UiJLGCtD2RshGgxFyomiSPd/hbC6Aah0o3d3HAQcFj6675adIA88t7txWt6hTxXmxbDR Vq0TJH1HpySWuHBfQA8U0rjkw6gYdYqZ/i1U0EnYCIonvirroytX5ifwM/oP7uqUp1BP 93RBgpeMHXDkVQ9Bq/u8jxohFTb8PovPoFhxBL8P8eZV4G2xDfnISjU9VcR14wsVRd4L QE13tbxfWYhvpOv4t0rgqoKEYUilBAdLgR5Fbm/cZBeVRBHNdUN94iP0Euk36heH83/U xYcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iGTGKK10; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1si8767979otk.154.2020.03.03.13.50.57; Tue, 03 Mar 2020 13:51:08 -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; dkim=pass header.i=@chromium.org header.s=google header.b=iGTGKK10; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732242AbgCCVGq (ORCPT + 99 others); Tue, 3 Mar 2020 16:06:46 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42393 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729880AbgCCVGq (ORCPT ); Tue, 3 Mar 2020 16:06:46 -0500 Received: by mail-pf1-f194.google.com with SMTP id f5so2099253pfk.9 for ; Tue, 03 Mar 2020 13:06:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ILFaru9VkZkMm/uyrzqiQJ9WG3dQIfoo+O/VJBbEFZM=; b=iGTGKK10+oxxGN/v1WRzlg2M7NJw6f+qRsLtaBqc7c4Ps8N8OV1wA0nsn8Qi0vXheX 2I7VybJAPo/CSFrdzqO8O7NJ4eZf42BLLr1BvTvx0qahY/5511jVg9WApd8aKL87j7Wo JwGHVbPh6NYNAW7PSci6bP5TQNZ8U1XfDSCSY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ILFaru9VkZkMm/uyrzqiQJ9WG3dQIfoo+O/VJBbEFZM=; b=Bo9JyuBuQojmvZAvzDGkHZZ+rPtFrza3kr1yGgypYUPERT22ZM/noPeClOi09m88o+ lE0qFgXevx+7bRt3x15wK9JKhfAPJYytGmm8RUmnBpczpiX5MAAY96IuFDEnFDnnNlCf ejq5b5cuMQXtlqX2GjI+O6D0YFxbPJZMWz/gchMKzxuMt+UhbfPyJunX3y2H5BcBmPdh aKKW1fz+KSuNxgbVQLTzdXXIchg1yvT95OoG+gi6vpQJMW0lNkaLirir6ENJBeaadBB1 FJjAoXKzQbDzCobd2xrFcfeVM4cRqRJSq1NuurK2UnTDMJFSU9ZJWisz4VZ683yGEFwo Y15g== X-Gm-Message-State: ANhLgQ01/rIpFBMMHw2ARMe6PPbIbUUgb//gTUWel/1pSHKFRJTT+Gf0 0NzpFfFdAruetzA9ToWpgexd1Q== X-Received: by 2002:a63:385e:: with SMTP id h30mr5587070pgn.230.1583269605143; Tue, 03 Mar 2020 13:06:45 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id gx18sm135662pjb.8.2020.03.03.13.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 13:06:44 -0800 (PST) Date: Tue, 3 Mar 2020 13:06:43 -0800 From: Kees Cook To: Andrii Nakryiko Cc: Masahiro Yamada , Michal Marek , Linux Kbuild mailing list , open list Subject: Re: [PATCH] kbuild: Remove debug info from kallsyms linking Message-ID: <202003031301.083CF048C2@keescook> References: <202002242114.CBED7F1@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 02, 2020 at 10:55:04PM -0800, Andrii Nakryiko wrote: > On Mon, Feb 24, 2020 at 9:17 PM Kees Cook wrote: > > > > When CONFIG_DEBUG_INFO is enabled, the two kallsyms linking steps spend > > time collecting and writing the dwarf sections to the temporary output > > files. kallsyms does not need this information, and leaving it off > > halves their linking time. This is especially noticeable without > > CONFIG_DEBUG_INFO_REDUCED. The BTF linking stage, however, does still > > need those details. > > > > Refactor the BTF and kallsyms generation stages slightly for more > > regularized temporary names. Skip debug during kallsyms links. > > > > For a full debug info build with BTF, my link time goes from 1m06s to > > 0m54s, saving about 12 seconds, or 18%. > > > > Signed-off-by: Kees Cook > > --- > > I've tested locally, seems to be generating BTF properly (I haven't > timed anything, though). See nit below, but otherwise: > > Acked-by: Andrii Nakryiko Thanks! > > > scripts/link-vmlinux.sh | 28 +++++++++++++++++++--------- > > 1 file changed, 19 insertions(+), 9 deletions(-) > > > > [...] > > > @@ -106,6 +114,8 @@ gen_btf() > > { > > local pahole_ver > > local bin_arch > > + local bin_format > > + local bin_file > > > > if ! [ -x "$(command -v ${PAHOLE})" ]; then > > echo >&2 "BTF: ${1}: pahole (${PAHOLE}) is not available" > > @@ -118,8 +128,9 @@ gen_btf() > > return 1 > > fi > > > > - info "BTF" ${2} > > vmlinux_link ${1} > > + > > + info "BTF" ${2} > > Any reason to exclude linking from "BTF" step? It's still a part of > BTF generation, so seems fair to have BTF encompass both vmlinux > linking and BTF generation/deduplication? I'm not sure I'm following what you're saying here. If you're asking why BTF linking is separate from the final vmlinux link, it's because of how kallsyms is generated. Currently it's using a rather brute-force approach to figure out exactly where everything is going to be in the final link, and for that it need to have both the BTF symbols present and the kallysms symbols present. So, unfortunately, each needs to be a separate step. I spent some time trying to merge BTF and kallsyms phase 1, but I didn't find a viable solution. I'm *sure* there is a better way to handle kallsyms, but I haven't had the time to really investigate it. I think it would require some close coordination with linker behavior changes... > > > LLVM_OBJCOPY=${OBJCOPY} ${PAHOLE} -J ${1} > > > > # dump .BTF section into raw binary file to link with final vmlinux BTW, in looking at BTF generation, why is this cut up into three steps: pahole, objcopy, objcopy... shouldn't pahole just gross an output method to dump the final .o file? That would be MUCH nicer. Especially since the first step ends up rewriting (?!) the original ELF. This is a lot of needless IO... -- Kees Cook