diff mbox series

[2/2] x86: split .fixup section with new enough gas

Message ID d223a0f9-6a66-8d7d-a214-51ddc24bb40f@suse.com (mailing list archive)
State New, archived
Headers show
Series x86: adjustments to .fixup section handling | expand

Commit Message

Jan Beulich Jan. 5, 2023, 11:12 a.m. UTC
GNU as, as of version 2.26, allows deriving the name of a section to
switch to from the present section's name. For the replacement to occur
--sectname-subst needs to be passed to the assembler.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
Similarly (and perhaps of more interest) we could split .ex_table,
allowing to reduce the number of entries to search through post-init.
diff mbox series

Patch

--- a/Config.mk
+++ b/Config.mk
@@ -98,7 +98,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
--- a/xen/arch/x86/arch.mk
+++ b/xen/arch/x86/arch.mk
@@ -34,6 +34,9 @@  $(call as-option-add,CFLAGS,CC,\
 $(call as-option-add,CFLAGS,CC,\
     ".L1: .L2: .nops (.L2 - .L1)$$(comma)9",-DHAVE_AS_NOPS_DIRECTIVE)
 
+# Check to see whether the assmbler supports the --sectname-subst option.
+$(call cc-option-add,CFLAGS,CC,-Wa$$(comma)--sectname-subst -DHAVE_AS_SECTNAME_SUBST)
+
 CFLAGS += -mno-red-zone -fpic
 
 # Xen doesn't use MMX or SSE interally.  If the compiler supports it, also skip
--- a/xen/arch/x86/include/asm/asm_defns.h
+++ b/xen/arch/x86/include/asm/asm_defns.h
@@ -81,10 +81,18 @@  register unsigned long current_stack_poi
 
 /* Exception recovery code section */
 #ifdef __ASSEMBLY__
-# define _ASM_FIXUP     .pushsection .fixup, "ax", @progbits
+# ifdef HAVE_AS_SECTNAME_SUBST
+#  define _ASM_FIXUP    .pushsection .fixup%S, "ax", @progbits
+# else
+#  define _ASM_FIXUP    .pushsection .fixup, "ax", @progbits
+# endif
 # define _ASM_FIXUP_END .popsection
 #else
-# define _ASM_FIXUP     " .pushsection .fixup, \"ax\", @progbits"
+# ifdef HAVE_AS_SECTNAME_SUBST
+#  define _ASM_FIXUP    " .pushsection .fixup%%S, \"ax\", @progbits"
+# else
+#  define _ASM_FIXUP    " .pushsection .fixup, \"ax\", @progbits"
+# endif
 # define _ASM_FIXUP_END " .popsection"
 #endif
 
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -103,6 +103,12 @@  SECTIONS
        *(.text.__x86_indirect_thunk_*)
 
        *(.fixup)
+       *(.fixup.text)
+       *(.fixup.text.cold)
+       *(.fixup.text.unlikely .fixup.text.*_unlikely .fixup.text.unlikely.*)
+#ifdef CONFIG_CC_SPLIT_SECTIONS
+       *(.fixup.text.*)
+#endif
        *(.gnu.warning)
        _etext = .;             /* End of text section */
   } PHDR(text) = 0x9090
@@ -215,6 +221,8 @@  SECTIONS
        _sinittext = .;
        *(.init.text)
        *(.text.startup)
+       *(.fixup.init.text)
+       *(.fixup.text.startup)
        _einittext = .;
        /*
         * Here are the replacement instructions. The linker sticks them
--- a/xen/include/xen/xen.lds.h
+++ b/xen/include/xen/xen.lds.h
@@ -89,7 +89,9 @@ 
 #define DISCARD_SECTIONS     \
   /DISCARD/ : {              \
        *(.text.exit)         \
+       *(.fixup.text.exit)   \
        *(.exit.text)         \
+       *(.fixup.exit.text)   \
        *(.exit.data)         \
        *(.exitcall.exit)     \
        *(.discard)           \