* [PATCH 0/2] modpost: small size reduction
@ 2014-08-25 10:25 Mathias Krause
2014-08-25 10:25 ` [PATCH 1/2] modpost: reduce visibility of symbols and constify r/o arrays Mathias Krause
2014-08-25 10:25 ` [PATCH 2/2] modpost: simplify file name generation of *.mod.c files Mathias Krause
0 siblings, 2 replies; 4+ messages in thread
From: Mathias Krause @ 2014-08-25 10:25 UTC (permalink / raw)
To: Rusty Russell; +Cc: linux-kernel, Mathias Krause
Hi Rusty,
the following two patches lead to a small size reduction of modpost.
Please apply!
Thanks,
Mathias
Mathias Krause (2):
modpost: reduce visibility of symbols and constify r/o arrays
modpost: simplify file name generation of *.mod.c files
scripts/mod/modpost.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
--
1.7.10.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] modpost: reduce visibility of symbols and constify r/o arrays
2014-08-25 10:25 [PATCH 0/2] modpost: small size reduction Mathias Krause
@ 2014-08-25 10:25 ` Mathias Krause
2014-08-27 10:59 ` Rusty Russell
2014-08-25 10:25 ` [PATCH 2/2] modpost: simplify file name generation of *.mod.c files Mathias Krause
1 sibling, 1 reply; 4+ messages in thread
From: Mathias Krause @ 2014-08-25 10:25 UTC (permalink / raw)
To: Rusty Russell; +Cc: linux-kernel, Mathias Krause
Internally used symbols of modpost don't need to be externally visible;
make them static. Also constify the string arrays so they resist in the
r/o section instead of being runtime writable.
Those changes lead to a small size reduction as can be seen below:
text data bss dec hex filename
51381 2640 12416 66437 10385 scripts/mod/modpost.old
51765 2224 12416 66405 10365 scripts/mod/modpost.new
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
...checkpatch warnings grossly ignored to comply to the coding style of
modpost.c
scripts/mod/modpost.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 091d90573b..c2ebdc788f 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -24,9 +24,9 @@
#include "../../include/linux/export.h"
/* Are we using CONFIG_MODVERSIONS? */
-int modversions = 0;
+static int modversions = 0;
/* Warn about undefined symbols? (do so if we have vmlinux) */
-int have_vmlinux = 0;
+static int have_vmlinux = 0;
/* Is CONFIG_MODULE_SRCVERSION_ALL set? */
static int all_versions = 0;
/* If we are modposting external module set to 1 */
@@ -229,7 +229,7 @@ static struct symbol *find_symbol(const char *name)
return NULL;
}
-static struct {
+static const struct {
const char *str;
enum export export;
} export_list[] = {
@@ -805,7 +805,7 @@ static int match(const char *sym, const char * const pat[])
}
/* sections that we do not want to do full section mismatch check on */
-static const char *section_white_list[] =
+static const char *const section_white_list[] =
{
".comment*",
".debug*",
@@ -882,17 +882,18 @@ static void check_section(const char *modname, struct elf_info *elf,
#define MEM_EXIT_SECTIONS ".memexit.*"
/* init data sections */
-static const char *init_data_sections[] = { ALL_INIT_DATA_SECTIONS, NULL };
+static const char *const init_data_sections[] =
+ { ALL_INIT_DATA_SECTIONS, NULL };
/* all init sections */
-static const char *init_sections[] = { ALL_INIT_SECTIONS, NULL };
+static const char *const init_sections[] = { ALL_INIT_SECTIONS, NULL };
/* All init and exit sections (code + data) */
-static const char *init_exit_sections[] =
+static const char *const init_exit_sections[] =
{ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL };
/* data section */
-static const char *data_sections[] = { DATA_SECTIONS, NULL };
+static const char *const data_sections[] = { DATA_SECTIONS, NULL };
/* symbols in .data that may refer to init/exit sections */
@@ -906,8 +907,8 @@ static const char *data_sections[] = { DATA_SECTIONS, NULL };
"*_probe_one", \
"*_console"
-static const char *head_sections[] = { ".head.text*", NULL };
-static const char *linker_symbols[] =
+static const char *const head_sections[] = { ".head.text*", NULL };
+static const char *const linker_symbols[] =
{ "__init_begin", "_sinittext", "_einittext", NULL };
enum mismatch {
@@ -929,7 +930,7 @@ struct sectioncheck {
const char *symbol_white_list[20];
};
-const struct sectioncheck sectioncheck[] = {
+static const struct sectioncheck sectioncheck[] = {
/* Do not reference init/exit code/data from
* normal code and data
*/
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] modpost: simplify file name generation of *.mod.c files
2014-08-25 10:25 [PATCH 0/2] modpost: small size reduction Mathias Krause
2014-08-25 10:25 ` [PATCH 1/2] modpost: reduce visibility of symbols and constify r/o arrays Mathias Krause
@ 2014-08-25 10:25 ` Mathias Krause
1 sibling, 0 replies; 4+ messages in thread
From: Mathias Krause @ 2014-08-25 10:25 UTC (permalink / raw)
To: Rusty Russell; +Cc: linux-kernel, Mathias Krause
Avoid the variable length array (vla), just use PATH_MAX instead.
This not only makes this code clang friedly, it also leads to a
code size reduction:
text data bss dec hex filename
51765 2224 12416 66405 10365 scripts/mod/modpost.old
51677 2224 12416 66317 1030d scripts/mod/modpost.new
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
scripts/mod/modpost.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index c2ebdc788f..3b405c726e 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2212,7 +2212,7 @@ int main(int argc, char **argv)
err = 0;
for (mod = modules; mod; mod = mod->next) {
- char fname[strlen(mod->name) + 10];
+ char fname[PATH_MAX];
if (mod->skip)
continue;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] modpost: reduce visibility of symbols and constify r/o arrays
2014-08-25 10:25 ` [PATCH 1/2] modpost: reduce visibility of symbols and constify r/o arrays Mathias Krause
@ 2014-08-27 10:59 ` Rusty Russell
0 siblings, 0 replies; 4+ messages in thread
From: Rusty Russell @ 2014-08-27 10:59 UTC (permalink / raw)
To: Mathias Krause; +Cc: linux-kernel, Mathias Krause
Mathias Krause <minipli@googlemail.com> writes:
> Internally used symbols of modpost don't need to be externally visible;
> make them static. Also constify the string arrays so they resist in the
> r/o section instead of being runtime writable.
I'm not convinced of the second patch, but I've applied it anyway.
Thanks,
Rusty.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-08-27 11:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-25 10:25 [PATCH 0/2] modpost: small size reduction Mathias Krause
2014-08-25 10:25 ` [PATCH 1/2] modpost: reduce visibility of symbols and constify r/o arrays Mathias Krause
2014-08-27 10:59 ` Rusty Russell
2014-08-25 10:25 ` [PATCH 2/2] modpost: simplify file name generation of *.mod.c files Mathias Krause
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.