From patchwork Wed Oct 23 16:48:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207221 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A5221515 for ; Wed, 23 Oct 2019 16:50:07 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5679C21925 for ; Wed, 23 Oct 2019 16:50:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="bhPRlh2N" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5679C21925 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJob-0007Ps-AA; Wed, 23 Oct 2019 16:48:53 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJoa-0007PX-EJ for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 16:48:52 +0000 X-Inumbo-ID: f87304b8-f5b4-11e9-8aca-bc764e2007e4 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f87304b8-f5b4-11e9-8aca-bc764e2007e4; Wed, 23 Oct 2019 16:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571849322; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y0FIGjiDgCfrCtvVDl/alvj9oiarFxRbWo4lLPMs7go=; b=bhPRlh2NIp7GKhDiRSaNdkBVMbo0W6/f4kXvue5VUTrIjbKxX3zMeYIM H6v2j/Lr5jV12wUUjU+1bx8jEyGJ9nJljXfL4DVBn/CCVt1cxmVMzB7Cg hdZe804AWcJ6o8WJ8reKDPYcEsthVTxSYfI17lPR56oz8cV1MP2/FCsrd c=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: yKiBPdXyuu/vc7oB8ss7mW29PQ7Ayo/226IZUNZjpy1IlrGh/hamTc4s2R+AsgYH2alAn9c+CP FAIUt5QsmIIoAuETD8fG//zlq1oX9ots8e9VLlajhwr+cGaK3GnU1+eyOTKw1ad86nMdlIbfLE 9dKmSkkvSyP2zK8hu0/OboBSaDO7RPx7Ghqf1sWawfd96v+NkYGB73+rLfHCSNMUKcLBXAEsVX UdxxcoIcWwp3TgsXTYGmHYVhDcvTmSSV6ZuIKtzy5mdfnDKl26vqWqGc3AbnOFsmqG6wiZeptF rxo= X-SBRS: 2.7 X-MesageID: 7778031 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7778031" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:21 +0100 Message-ID: <20191023164837.2700240-8-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 07/23] xen, Kbuild: Handle obj-bin-y and %.init.o objects X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" SPECIAL_DATA_SECTIONS is put in Kbuild.include so it can be use in kbuild makefiles. Signed-off-by: Anthony PERARD --- xen/scripts/Kbuild.include | 10 ++++++++++ xen/scripts/Makefile.build | 24 ++++++++++++++++++++++++ xen/scripts/Makefile.lib | 7 +++++++ 3 files changed, 41 insertions(+) diff --git a/xen/scripts/Kbuild.include b/xen/scripts/Kbuild.include index 4b0432e095ae..6f95a2519f3c 100644 --- a/xen/scripts/Kbuild.include +++ b/xen/scripts/Kbuild.include @@ -326,6 +326,16 @@ endef # ############################################################################### +# For building %.init.o files, can be used in kbuild makefiles +SPECIAL_DATA_SECTIONS := rodata $(foreach a,1 2 4 8 16, \ + $(foreach w,1 2 4, \ + rodata.str$(w).$(a)) \ + rodata.cst$(a)) \ + $(foreach r,rel rel.ro,data.$(r).local) + +############################################################################### + + # delete partially updated (i.e. corrupted) files on error .DELETE_ON_ERROR: diff --git a/xen/scripts/Makefile.build b/xen/scripts/Makefile.build index dd972d5b5edb..68b504c9bdc5 100644 --- a/xen/scripts/Makefile.build +++ b/xen/scripts/Makefile.build @@ -384,6 +384,30 @@ $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE targets += $(filter-out $(subdir-obj-y), $(real-obj-y)) $(real-obj-m) $(lib-y) targets += $(extra-y) $(MAKECMDGOALS) $(always) +# %.init.o objects +# ---------------- + +quiet_cmd_obj_init_o = INIT_OBJ $@ +define cmd_obj_init_o + set -e; \ + $(OBJDUMP) -h $< | sed -n '/[0-9]/{s,00*,0,g;p;}' | while read idx name sz rest; do \ + case "$$name" in \ + .*.local) ;; \ + .text|.text.*|.data|.data.*|.bss) \ + test $$sz != 0 || continue; \ + echo "Error: size of $<:$$name is 0x$$sz" >&2; \ + exit $$(expr $$idx + 1);; \ + esac; \ + done; \ + $(OBJCOPY) $(foreach s,$(SPECIAL_DATA_SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@ +endef + +$(obj)/%.init.o: $(obj)/%.o FORCE + $(call if_changed,obj_init_o) + +# Add intermediates files into tagets +targets += $(patsubst %.init.o,%.o,$(filter %.init.o,$(targets))) + # Linker scripts preprocessor (.lds.S -> .lds) # --------------------------------------------------------------------------- quiet_cmd_cpp_lds_S = LDS $@ diff --git a/xen/scripts/Makefile.lib b/xen/scripts/Makefile.lib index b746199b7f6b..e022f053494e 100644 --- a/xen/scripts/Makefile.lib +++ b/xen/scripts/Makefile.lib @@ -16,6 +16,10 @@ KBUILD_CFLAGS += $(subdir-ccflags-y) # only build the compiled-in version obj-m := $(filter-out $(obj-y),$(obj-m)) +# For a non-LTO build, bundle obj-bin targets in with the normal objs. +obj-y += $(obj-bin-y) +obj-bin-y := + # Libraries are always collected in one lib file. # Filter out objects already built-in lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) @@ -108,6 +112,9 @@ name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote) basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) +# See comment about INIT_SECTIONS_ONLY in include/xen/compiler.h +$(filter %.init.o,$(real-obj-y) $(extra-y)): ccflags-y += -DINIT_SECTIONS_ONLY + orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ $(ccflags-y) $(CFLAGS_$(basetarget).o) _c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))