Skip to contentSkip to conversation

module: set .init_array alignment to 8

PATCH In review David Daney 4 participants 4 messages Mar 8, 2017 – Mar 13, 2017 Module support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 module: set .init_array alignment to 8

The proper idiom for aligning linker sections in modules is different than for built-in sections. ". = ALIGN();" followed by a forced output address of 0 does nothing, as forcing the address changes the value of ".".

Use output section alignment specifier instead.

Fixes 9ddf82521c86 ("kernel: add support for .init_array.* constructors")

---

I noticed this when doing the __jump_table thing. Doesn't seem to break a defconfig build, but otherwise untested.

 scripts/module-common.lds | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
scripts/module-common.lds +1 -2
index 9b6e246..d61b9e8 100644
@@ -20,8 +20,7 @@ SECTIONS {
 	__kcrctab_unused_gpl	0 : { *(SORT(___kcrctab_unused_gpl+*)) }
 	__kcrctab_gpl_future	0 : { *(SORT(___kcrctab_gpl_future+*)) }
 
-	. = ALIGN(8);
-	.init_array		0 : { *(SORT(.init_array.*)) *(.init_array) }
+	.init_array		0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) }
 
 	__jump_table		0 : ALIGN(8) { KEEP(*(__jump_table)) }
 }
Signature · 1 line
2.9.3
#1 lore raw

It looks like Andrey's e-mail changed. Replying with what I hope is a valid e-mail for Andrey.

Quoted 32 lines · David Daney

The proper idiom for aligning linker sections in modules is different than for built-in sections. ". = ALIGN();" followed by a forced output address of 0 does nothing, as forcing the address changes the value of ".".

Use output section alignment specifier instead.

Fixes 9ddf82521c86 ("kernel: add support for .init_array.* constructors")

---

I noticed this when doing the __jump_table thing. Doesn't seem to break a defconfig build, but otherwise untested.

 scripts/module-common.lds | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
scripts/module-common.lds +1 -2
index 9b6e246..d61b9e8 100644
@@ -20,8 +20,7 @@ SECTIONS {
 	__kcrctab_unused_gpl	0 : { *(SORT(___kcrctab_unused_gpl+*)) }
 	__kcrctab_gpl_future	0 : { *(SORT(___kcrctab_gpl_future+*)) }
 
-	. = ALIGN(8);
-	.init_array		0 : { *(SORT(.init_array.*)) *(.init_array) }
+	.init_array		0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) }
 
 	__jump_table		0 : ALIGN(8) { KEEP(*(__jump_table)) }
 }
Reviewed-by on v1 1/1
#2 lore raw
In reply to David Daney
Quoted 9 lines · David Daney

The proper idiom for aligning linker sections in modules is different than for built-in sections. ". = ALIGN();" followed by a forced output address of 0 does nothing, as forcing the address changes the value of ".".

Use output section alignment specifier instead.

Fixes 9ddf82521c86 ("kernel: add support for .init_array.* constructors")
Quoted 23 lines

---

I noticed this when doing the __jump_table thing. Doesn't seem to break a defconfig build, but otherwise untested.

 scripts/module-common.lds | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
scripts/module-common.lds +1 -2
index 9b6e246..d61b9e8 100644
@@ -20,8 +20,7 @@ SECTIONS {
 	__kcrctab_unused_gpl	0 : { *(SORT(___kcrctab_unused_gpl+*)) }
 	__kcrctab_gpl_future	0 : { *(SORT(___kcrctab_gpl_future+*)) }
 
-	. = ALIGN(8);
-	.init_array		0 : { *(SORT(.init_array.*)) *(.init_array) }
+	.init_array		0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) }
 
 	__jump_table		0 : ALIGN(8) { KEEP(*(__jump_table)) }
 }
#3 lore raw
In reply to David Daney

+++ David Daney [07/03/17 17:31 -0800]:

Quoted 9 lines

The proper idiom for aligning linker sections in modules is different than for built-in sections. ". = ALIGN();" followed by a forced output address of 0 does nothing, as forcing the address changes the value of ".".

Use output section alignment specifier instead.

Fixes 9ddf82521c86 ("kernel: add support for .init_array.* constructors")

Good catch, thanks. I've applied this to modules-next.

Jessica

Quoted 23 lines

I noticed this when doing the __jump_table thing. Doesn't seem to break a defconfig build, but otherwise untested.

scripts/module-common.lds | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
scripts/module-common.lds +1 -2
index 9b6e246..d61b9e8 100644
@@ -20,8 +20,7 @@ SECTIONS {
 	__kcrctab_unused_gpl	0 : { *(SORT(___kcrctab_unused_gpl+*)) }
 	__kcrctab_gpl_future	0 : { *(SORT(___kcrctab_gpl_future+*)) }
 
-	. = ALIGN(8);
-	.init_array		0 : { *(SORT(.init_array.*)) *(.init_array) }
+	.init_array		0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) }
 
 	__jump_table		0 : ALIGN(8) { KEEP(*(__jump_table)) }
 }
Signature · 1 line
2.9.3