Skip to contentSkip to conversation

What exactly is __ALIGN_STR in pnpbios/bioscalls.c for?

DISCUSSION Adrian Bunk 3 participants 3 messages Nov 21, 2004 Generic include/asm header files

lore
Share & tools
lore
#0 lore raw

Hi,

include/linux/linkage.h in kernel 2.6 includes #define's for __ALIGN and __ALIGN_STR. In include/asm-i386/linkage.h, their values are changed #ifdef CONFIG_X86_ALIGNMENT_16.

It isn't obvious what exacly CONFIG_X86_ALIGNMENT_16 is for (I've heard more than one opinion), and since the __ALIGN_STR usage in drivers/pnp/pnpbios/bioscalls.c is the only non-m68k usage of one of these two #define's I wonder whether you might be able to enlighten me what CONFIG_X86_ALIGNMENT_16 exactly is for?

TIA
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#1 lore raw
Quoted 9 lines · Adrian Bunk

include/linux/linkage.h in kernel 2.6 includes #define's for __ALIGN and __ALIGN_STR. In include/asm-i386/linkage.h, their values are changed #ifdef CONFIG_X86_ALIGNMENT_16.

It isn't obvious what exacly CONFIG_X86_ALIGNMENT_16 is for (I've heard more than one opinion), and since the __ALIGN_STR usage in drivers/pnp/pnpbios/bioscalls.c is the only non-m68k usage of one of these two #define's I wonder whether you might be able to enlighten me what CONFIG_X86_ALIGNMENT_16 exactly is for?

It's for aligning function entries to a 16 byte boundary instead of only 4 bytes, used together with -malign-functions. See also the ENTRY macro. Note that the default value of __ALIGN is actually useless for anything but x86 and x86-64.

Andreas.

Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#2 lore raw
Quoted 6 lines · Andreas Schwab

Adrian Bunk <[email protected]> writes:

It's for aligning function entries to a 16 byte boundary instead of only 4 bytes, used together with -malign-functions. See also the ENTRY macro. Note that the default value of __ALIGN is actually useless for anything but x86 and x86-64.

Recently someone complained that __sched_text_start changed address during pass one and two of kallsyms. The actual culprint was that an address changed due to different section layout.
The fix I posted was to align .sched.text to an 8 byte boundary.

Can we say anything about alignment of functions across architectures?

Patch in question below.
Grepping tells me to use FUNCTION_ALIGN if I push this for inclusion.

Sam

===== include/asm-generic/vmlinux.lds.h 1.16 vs edited =====

include/asm-generic/vmlinux.lds.h +7 -0
@@ -6,6 +6,11 @@
 #define VMLINUX_SYMBOL(_sym_) _sym_
 #endif
 
+/* Aling functions to a 8 byte boundary.
+ * This prevents lables defined to mark start/end of section to differ
+ * during pass 1 and pass 2 when generating System.map */
+#define ALIGN_FUNCTION()  . = ALIGN(8)
+
 #define RODATA								\
 	.rodata           : AT(ADDR(.rodata) - LOAD_OFFSET) {		\
 		*(.rodata) *(.rodata.*)					\
@@ -77,11 +82,13 @@
 	}
 
 #define SCHED_TEXT							\
+		ALIGN_FUNCTION();					\
 		VMLINUX_SYMBOL(__sched_text_start) = .;			\
 		*(.sched.text)						\
 		VMLINUX_SYMBOL(__sched_text_end) = .;
 
 #define LOCK_TEXT							\
+		ALIGN_FUNCTION();					\
 		VMLINUX_SYMBOL(__lock_text_start) = .;			\
 		*(.spinlock.text)					\
 		VMLINUX_SYMBOL(__lock_text_end) = .;