diff options
Diffstat (limited to 'recipes-kernel/linux/linux-fslc-imx/0002-include-linux-module.h-copy-__init-__exit-attrs-to-i.patch')
-rw-r--r-- | recipes-kernel/linux/linux-fslc-imx/0002-include-linux-module.h-copy-__init-__exit-attrs-to-i.patch | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/recipes-kernel/linux/linux-fslc-imx/0002-include-linux-module.h-copy-__init-__exit-attrs-to-i.patch b/recipes-kernel/linux/linux-fslc-imx/0002-include-linux-module.h-copy-__init-__exit-attrs-to-i.patch deleted file mode 100644 index 8472a151..00000000 --- a/recipes-kernel/linux/linux-fslc-imx/0002-include-linux-module.h-copy-__init-__exit-attrs-to-i.patch +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | From 2d75d1869fb3d9d7d47ae7c0ac6fab4e7dd9487e Mon Sep 17 00:00:00 2001 | ||
2 | From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> | ||
3 | Date: Fri, 2 Aug 2019 12:37:57 +0200 | ||
4 | Subject: [PATCH 2/2] include/linux/module.h: copy __init/__exit attrs to | ||
5 | init/cleanup_module | ||
6 | |||
7 | commit a6e60d84989fa0e91db7f236eda40453b0e44afa upstream. | ||
8 | |||
9 | The upcoming GCC 9 release extends the -Wmissing-attributes warnings | ||
10 | (enabled by -Wall) to C and aliases: it warns when particular function | ||
11 | attributes are missing in the aliases but not in their target. | ||
12 | |||
13 | In particular, it triggers for all the init/cleanup_module | ||
14 | aliases in the kernel (defined by the module_init/exit macros), | ||
15 | ending up being very noisy. | ||
16 | |||
17 | These aliases point to the __init/__exit functions of a module, | ||
18 | which are defined as __cold (among other attributes). However, | ||
19 | the aliases themselves do not have the __cold attribute. | ||
20 | |||
21 | Since the compiler behaves differently when compiling a __cold | ||
22 | function as well as when compiling paths leading to calls | ||
23 | to __cold functions, the warning is trying to point out | ||
24 | the possibly-forgotten attribute in the alias. | ||
25 | |||
26 | In order to keep the warning enabled, we decided to silence | ||
27 | this case. Ideally, we would mark the aliases directly | ||
28 | as __init/__exit. However, there are currently around 132 modules | ||
29 | in the kernel which are missing __init/__exit in their init/cleanup | ||
30 | functions (either because they are missing, or for other reasons, | ||
31 | e.g. the functions being called from somewhere else); and | ||
32 | a section mismatch is a hard error. | ||
33 | |||
34 | A conservative alternative was to mark the aliases as __cold only. | ||
35 | However, since we would like to eventually enforce __init/__exit | ||
36 | to be always marked, we chose to use the new __copy function | ||
37 | attribute (introduced by GCC 9 as well to deal with this). | ||
38 | With it, we copy the attributes used by the target functions | ||
39 | into the aliases. This way, functions that were not marked | ||
40 | as __init/__exit won't have their aliases marked either, | ||
41 | and therefore there won't be a section mismatch. | ||
42 | |||
43 | Note that the warning would go away marking either the extern | ||
44 | declaration, the definition, or both. However, we only mark | ||
45 | the definition of the alias, since we do not want callers | ||
46 | (which only see the declaration) to be compiled as if the function | ||
47 | was __cold (and therefore the paths leading to those calls | ||
48 | would be assumed to be unlikely). | ||
49 | |||
50 | Link: https://lore.kernel.org/lkml/259986242.BvXPX32bHu@devpool35/ | ||
51 | Cc: <stable@vger.kernel.org> | ||
52 | Link: https://lore.kernel.org/lkml/20190123173707.GA16603@gmail.com/ | ||
53 | Link: https://lore.kernel.org/lkml/20190206175627.GA20399@gmail.com/ | ||
54 | Suggested-by: Martin Sebor <msebor@gcc.gnu.org> | ||
55 | Acked-by: Jessica Yu <jeyu@kernel.org> | ||
56 | Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> | ||
57 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||
58 | --- | ||
59 | include/linux/module.h | 4 ++-- | ||
60 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
61 | |||
62 | diff --git a/include/linux/module.h b/include/linux/module.h | ||
63 | index 0c3207d26ac0..06aca48417c9 100644 | ||
64 | --- a/include/linux/module.h | ||
65 | +++ b/include/linux/module.h | ||
66 | @@ -129,13 +129,13 @@ extern void cleanup_module(void); | ||
67 | #define module_init(initfn) \ | ||
68 | static inline initcall_t __inittest(void) \ | ||
69 | { return initfn; } \ | ||
70 | - int init_module(void) __attribute__((alias(#initfn))); | ||
71 | + int init_module(void) __copy(initfn) __attribute__((alias(#initfn))); | ||
72 | |||
73 | /* This is only required if you want to be unloadable. */ | ||
74 | #define module_exit(exitfn) \ | ||
75 | static inline exitcall_t __exittest(void) \ | ||
76 | { return exitfn; } \ | ||
77 | - void cleanup_module(void) __attribute__((alias(#exitfn))); | ||
78 | + void cleanup_module(void) __copy(exitfn) __attribute__((alias(#exitfn))); | ||
79 | |||
80 | #endif | ||
81 | |||
82 | -- | ||
83 | 2.17.1 | ||
84 | |||