Skip to content

Commit 4c5afb7

Browse files
Reiner HuoberJessica Yu
authored andcommitted
module: combine constructors in module linker script
The constructor code for modules must be aware of init code inside different sections. Newer GCC compilers write constructors in more than one section, e.g. ".ctors.65435". These must be combined into a single ".ctors" section. In the module loader, only the ".ctors" section is searched and the constructors therein are initialized, when CONFIG_CONSTRUCTORS=y is set. Other constructors are ignored. This change combines all ".ctors.*" and the ".ctors" section, if any, in <module>.ko into a single ."ctors" section. For code coverage in GCC, this is necessary to show the code coverage for modules, since code coverage uses such constructors when initializing a module in newer version of GCC. Signed-off-by: Reiner Huober <[email protected]> Signed-off-by: Jessica Yu <[email protected]>
1 parent e73f0f0 commit 4c5afb7

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

scripts/module.lds.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ SECTIONS {
2424
__kcrctab 0 : { *(SORT(___kcrctab+*)) }
2525
__kcrctab_gpl 0 : { *(SORT(___kcrctab_gpl+*)) }
2626

27+
.ctors 0 : ALIGN(8) { *(SORT(.ctors.*)) *(.ctors) }
2728
.init_array 0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) }
2829

2930
__jump_table 0 : ALIGN(8) { KEEP(*(__jump_table)) }

0 commit comments

Comments
 (0)