Ensure that the static structs emitted by the MODULE_DEPEND() and

MODULE_VERSION() macros don't end up as .comm symbols, when all the
version fields are zero.

Normally, such symbols will end up in .bss, but for kernel module
version objects, this can lead to "garbage" version numbers.

Fix this by instructing the compiler to always put these structs in the
.data segment instead.

Reported by:	delphij, ae
MFC after:	1 week
This commit is contained in:
Dimitry Andric 2015-05-21 17:40:53 +00:00
parent 6a11fa4e31
commit 4deaeac3c5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=283254

View File

@ -107,7 +107,8 @@ struct mod_metadata {
DATA_SET(modmetadata_set, _mod_metadata##uniquifier)
#define MODULE_DEPEND(module, mdepend, vmin, vpref, vmax) \
static struct mod_depend _##module##_depend_on_##mdepend = { \
static struct mod_depend _##module##_depend_on_##mdepend \
__section(".data") = { \
vmin, \
vpref, \
vmax \
@ -147,7 +148,8 @@ struct mod_metadata {
DECLARE_MODULE_WITH_MAXVER(name, data, sub, order, __FreeBSD_version)
#define MODULE_VERSION(module, version) \
static struct mod_version _##module##_version = { \
static struct mod_version _##module##_version \
__section(".data") = { \
version \
}; \
MODULE_METADATA(_##module##_version, MDT_VERSION, \