All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: Anthony PERARD <anthony.perard@citrix.com>
Subject: [Xen-devel] [RFC XEN PATCH 07/23] xen, Kbuild: Handle obj-bin-y and %.init.o objects
Date: Wed, 23 Oct 2019 17:48:21 +0100	[thread overview]
Message-ID: <20191023164837.2700240-8-anthony.perard@citrix.com> (raw)
In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com>

SPECIAL_DATA_SECTIONS is put in Kbuild.include so it can be use in
kbuild makefiles.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 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))
-- 
Anthony PERARD

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-10-23 16:49 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-23 16:48 [Xen-devel] [RFC XEN PATCH 00/23] Kconfig update + WIP of using Kbuild Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 01/23] xen: Fix strange byte in common/Kconfig Anthony PERARD
2019-10-24 10:41   ` [Xen-devel] [PATCH for-4.13 " Andrew Cooper
2019-10-24 10:48     ` Jürgen Groß
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 02/23] xen: Makefile: Remove outdated comment Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 04/23] build: Import Kbuild from Linux v5.3 Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 05/23] xen: Kbuild: Remove extra -include from C flags Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 06/23] xen, Kbuild: filter-out -Wa, % from CFLAGS for %.i:%.c rules Anthony PERARD
2019-10-23 16:48 ` Anthony PERARD [this message]
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 08/23] xen, Kbuild: Change filechk_offsets Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 09/23] xen, Kbuild: Filter-out -Wa, in %.s:%.c rules Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 10/23] xen,Kbuild: Handle __OBJECT_*__ Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 11/23] First conversion to kbuild makefiles Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 12/23] Build guest_walk* in arch/x86/mm Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 13/23] convert common/libelf/Makefile to kbuild makefile Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 14/23] convert common/libfdt " Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 15/23] convert tools/Makefile to kbuild Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 16/23] convert include/Makefile to Kbuild Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 17/23] convert arch/x86/boot/Makefile to kbuild Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 18/23] arch/x86: Start moving build targets out of Makefile into Kbuild Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 19/23] update *FLAGS for arch/x86/Makefile Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 20/23] update arch/Makefile Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 21/23] Import root Makefile from Linux v5.3 Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 22/23] Changes to root Makefile Anthony PERARD
2019-10-23 16:48 ` [Xen-devel] [RFC XEN PATCH 23/23] xen/tools/kconfig: Delete duplicate makefiles Anthony PERARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191023164837.2700240-8-anthony.perard@citrix.com \
    --to=anthony.perard@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.