[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC XEN PATCH 07/23] xen, Kbuild: Handle obj-bin-y and %.init.o objects


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Date: Wed, 23 Oct 2019 17:48:21 +0100
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@xxxxxxxxxx; spf=Pass smtp.mailfrom=anthony.perard@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Wed, 23 Oct 2019 16:48:53 +0000
  • Ironport-sdr: yKiBPdXyuu/vc7oB8ss7mW29PQ7Ayo/226IZUNZjpy1IlrGh/hamTc4s2R+AsgYH2alAn9c+CP FAIUt5QsmIIoAuETD8fG//zlq1oX9ots8e9VLlajhwr+cGaK3GnU1+eyOTKw1ad86nMdlIbfLE 9dKmSkkvSyP2zK8hu0/OboBSaDO7RPx7Ghqf1sWawfd96v+NkYGB73+rLfHCSNMUKcLBXAEsVX UdxxcoIcWwp3TgsXTYGmHYVhDcvTmSSV6ZuIKtzy5mdfnDKl26vqWqGc3AbnOFsmqG6wiZeptF rxo=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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

Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.