module: combine constructors in module linker script
authorReiner Huober <reiner.huober@nokia.com>
Tue, 6 Jul 2021 13:02:52 +0000 (15:02 +0200)
committerJessica Yu <jeyu@kernel.org>
Mon, 19 Jul 2021 12:51:40 +0000 (14:51 +0200)
commit4c5afb74d9450edc2e2e37243b469cc278b120d4
tree18d38a799ac6f8a5588c836d3e610d9311fb5713
parente73f0f0ee7541171d89f2e2491130c7771ba58d3
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 <reiner.huober@nokia.com>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
scripts/module.lds.S