@@ -102,7 +102,7 @@ cc-option = $(shell if test -z "`echo 'v
# Usage: $(call cc-option-add CFLAGS,CC,-march=winchip-c6)
cc-option-add = $(eval $(call cc-option-add-closure,$(1),$(2),$(3)))
define cc-option-add-closure
- ifneq ($$(call cc-option,$$($(2)),$(3),n),n)
+ ifneq ($$(call cc-option,$$($(2)),$(firstword $(3)),n),n)
$(1) += $(3)
endif
endef
@@ -407,6 +407,9 @@ AFLAGS += -D__ASSEMBLY__
$(call cc-option-add,AFLAGS,CC,-Wa$(comma)--noexecstack)
+# Check to see whether the assmbler supports the --sectname-subst option.
+$(call cc-option-add,AFLAGS,CC,-Wa$$(comma)--sectname-subst -DHAVE_AS_SECTNAME_SUBST)
+
LDFLAGS-$(call ld-option,--warn-rwx-segments) += --no-warn-rwx-segments
CFLAGS += $(CFLAGS-y)
@@ -154,6 +154,9 @@ SECTIONS
.init.text : {
_sinittext = .;
*(.init.text)
+#ifdef CONFIG_CC_SPLIT_SECTIONS
+ *(.init.text.*)
+#endif
_einittext = .;
. = ALIGN(PAGE_SIZE); /* Avoid mapping alt insns executable */
*(.altinstr_replacement)
@@ -90,6 +90,9 @@ SECTIONS
.init.text : {
_sinittext = .;
*(.init.text)
+#ifdef CONFIG_CC_SPLIT_SECTIONS
+ *(.init.text.*)
+#endif
_einittext = .;
. = ALIGN(PAGE_SIZE); /* Avoid mapping alt insns executable */
} :text
@@ -89,6 +89,9 @@ SECTIONS
.init.text : {
_sinittext = .;
*(.init.text)
+#ifdef CONFIG_CC_SPLIT_SECTIONS
+ *(.init.text.*)
+#endif
_einittext = .;
. = ALIGN(PAGE_SIZE); /* Avoid mapping alt insns executable */
} :text
@@ -86,6 +86,9 @@ SECTIONS
. = ALIGN(PAGE_SIZE);
_stextentry = .;
*(.text.entry)
+#ifdef CONFIG_CC_SPLIT_SECTIONS
+ *(.text.entry.*)
+#endif
. = ALIGN(PAGE_SIZE);
_etextentry = .;
@@ -214,6 +217,9 @@ SECTIONS
#endif
_sinittext = .;
*(.init.text)
+#ifdef CONFIG_CC_SPLIT_SECTIONS
+ *(.init.text.*)
+#endif
*(.text.startup)
_einittext = .;
/*
@@ -21,6 +21,14 @@
#define SYM_ALIGN(algn...) .balign algn
+#if defined(HAVE_AS_SECTNAME_SUBST) && defined(CONFIG_CC_SPLIT_SECTIONS)
+# define SYM_PUSH_SECTION(name, attr) \
+ .pushsection %S.name, attr, %progbits; \
+ .equ .Lsplit_section, 1
+#else
+# define SYM_PUSH_SECTION(name, attr)
+#endif
+
#define SYM_L_GLOBAL(name) .globl name; .hidden name
#define SYM_L_WEAK(name) .weak name
#define SYM_L_LOCAL(name) /* nothing */
@@ -35,7 +43,14 @@
SYM_ALIGN(algn); \
name:
-#define END(name) .size name, . - name
+#define END(name) \
+ .size name, . - name; \
+ .ifdef .Lsplit_section; \
+ .if .Lsplit_section; \
+ .popsection; \
+ .equ .Lsplit_section, 0; \
+ .endif; \
+ .endif
/*
* CODE_FILL in particular may need to expand to nothing (e.g. for RISC-V), in
@@ -49,6 +64,7 @@
#endif
#define FUNC(name, algn...) \
+ SYM_PUSH_SECTION(name, "ax"); \
SYM(name, FUNC, GLOBAL, DO_CODE_ALIGN(algn))
#define LABEL(name, algn...) \
SYM(name, NONE, GLOBAL, DO_CODE_ALIGN(algn))
@@ -56,6 +72,7 @@
SYM(name, DATA, GLOBAL, LASTARG(DATA_ALIGN, ## algn), DATA_FILL)
#define FUNC_LOCAL(name, algn...) \
+ SYM_PUSH_SECTION(name, "ax"); \
SYM(name, FUNC, LOCAL, DO_CODE_ALIGN(algn))
#define LABEL_LOCAL(name, algn...) \
SYM(name, NONE, LOCAL, DO_CODE_ALIGN(algn))
Leverage the new infrastructure in xen/linkage.h to also switch to per- function sections (when configured), deriving the specific name from the "base" section in use at the time FUNC() is invoked. Signed-off-by: Jan Beulich <jbeulich@suse.com> --- TBD: Since we use .subsection in UNLIKELY_START(), a perhaps not really wanted side effect of this change is that respective out-of-line code now moves much closer to its original (invoking) code. TBD: Of course something with the same overall effect, but less impactful might do in Config.mk. E.g. $(filter-out -D%,$(3)) instead of $(firstword (3)). Note that we'd need to split DATA() in order to separate r/w and r/o contributions. Further splitting might be needed to also support more advanced attributes (e.g. merge), hence why this isn't done right here. Sadly while a new section's name can be derived from the presently in use, its attributes cannot be. Perhaps the only thing we can do is give DATA() a 2nd mandatory parameter. Then again I guess most data definitions could be moved to C anyway. --- v4: Re-base. v2: Make detection properly fail on old gas (by adjusting cc-option-add-closure).