mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
module: simplify version-attribute handling
Instead of using the array-of-pointers trick to avoid having gcc mess up
the built-in module-version array stride, specify type alignment when
declaring entries to prevent gcc from increasing alignment.
This is essentially an alternative (one-line) fix to the problem
addressed by commit b4bc842802
("module: deal with alignment issues in
built-in module versions").
gcc can increase the alignment of larger objects with static extent as
an optimisation, but this can be suppressed by using the aligned
attribute when declaring variables.
Note that we have been relying on this behaviour for kernel parameters
for 16 years and it indeed hasn't changed since the introduction of the
aligned attribute in gcc-3.1.
Link: https://lore.kernel.org/lkml/20201103175711.10731-1-johan@kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
This commit is contained in:
parent
0801a0073f
commit
b112082c89
2 changed files with 17 additions and 19 deletions
|
@ -266,20 +266,20 @@ extern typeof(name) __mod_##type##__##name##_device_table \
|
|||
#else
|
||||
#define MODULE_VERSION(_version) \
|
||||
MODULE_INFO(version, _version); \
|
||||
static struct module_version_attribute ___modver_attr = { \
|
||||
.mattr = { \
|
||||
.attr = { \
|
||||
.name = "version", \
|
||||
.mode = S_IRUGO, \
|
||||
static struct module_version_attribute __modver_attr \
|
||||
__used __section("__modver") \
|
||||
__aligned(__alignof__(struct module_version_attribute)) \
|
||||
= { \
|
||||
.mattr = { \
|
||||
.attr = { \
|
||||
.name = "version", \
|
||||
.mode = S_IRUGO, \
|
||||
}, \
|
||||
.show = __modver_version_show, \
|
||||
}, \
|
||||
.show = __modver_version_show, \
|
||||
}, \
|
||||
.module_name = KBUILD_MODNAME, \
|
||||
.version = _version, \
|
||||
}; \
|
||||
static const struct module_version_attribute \
|
||||
__used __section("__modver") \
|
||||
* __moduleparam_const __modver_attr = &___modver_attr
|
||||
.module_name = KBUILD_MODNAME, \
|
||||
.version = _version, \
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Optional firmware file (or files) needed by the module
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue