[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1625576575-1008-1-git-send-email-reiner.huober@nokia.com>
Date: Tue, 6 Jul 2021 15:02:52 +0200
From: Reiner Huober <reiner.huober@...ia.com>
To: reiner.huober@...ia.com
Cc: Kees Cook <keescook@...omium.org>, Jessica Yu <jeyu@...nel.org>,
Sami Tolvanen <samitolvanen@...gle.com>,
Miroslav Benes <mbenes@...e.cz>,
Emil Velikov <emil.l.velikov@...il.com>,
Sean Christopherson <seanjc@...gle.com>,
Masahiro Yamada <masahiroy@...nel.org>,
linux-kernel@...r.kernel.org
Subject: [PATCH] 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@...ia.com>
---
scripts/module.lds.S | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/module.lds.S b/scripts/module.lds.S
index 04c5685..1d0e1e4 100644
--- a/scripts/module.lds.S
+++ b/scripts/module.lds.S
@@ -24,6 +24,7 @@ SECTIONS {
__kcrctab 0 : { *(SORT(___kcrctab+*)) }
__kcrctab_gpl 0 : { *(SORT(___kcrctab_gpl+*)) }
+ .ctors 0 : ALIGN(8) { *(SORT(.ctors.*)) *(.ctors) }
.init_array 0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) }
__jump_table 0 : ALIGN(8) { KEEP(*(__jump_table)) }
--
2.6.2
Powered by blists - more mailing lists