diff options
author | Jan Beulich <jbeulich@novell.com> | 2008-12-16 06:28:14 -0500 |
---|---|---|
committer | Sam Ravnborg <sam@ravnborg.org> | 2008-12-19 16:41:15 -0500 |
commit | ad7a953c522ceb496611d127e51e278bfe0ff483 (patch) | |
tree | f51a18ab282bb77244fc02ad33359a92b6b36eb9 /scripts/genksyms/genksyms.c | |
parent | 37a8d9f67f18de1e2cbc7387311ce22d4dbff518 (diff) |
kbuild: strip generated symbols from *.ko
This patch changes the way __crc_ symbols are being resolved from
using ld to do so to using the assembler, thus allowing these symbols
to be marked local (the linker creates then as global ones) and hence
allow stripping (for modules) or ignoring (for vmlinux) them. While at
this, also strip other generated symbols during module installation.
One potentially debatable point is the handling of the flags passeed
to gcc when translating the intermediate assembly file into an object:
passing $(c_flags) unchanged doesn't work as gcc passes --gdwarf2 to
gas whenever is sees any -g* option, even for -g0, and despite the
fact that the compiler would have already produced all necessary debug
info in the C->assembly translation phase. I took the approach of just
filtering out all -g* options, but an alternative to such negative
filtering might be to have a positive filter which might, in the ideal
case allow just all the -Wa,* options to pass through.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/genksyms/genksyms.c')
-rw-r--r-- | scripts/genksyms/genksyms.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c index 3a8297b5184c..f8bb4cabd62d 100644 --- a/scripts/genksyms/genksyms.c +++ b/scripts/genksyms/genksyms.c | |||
@@ -43,7 +43,7 @@ int cur_line = 1; | |||
43 | char *cur_filename; | 43 | char *cur_filename; |
44 | 44 | ||
45 | static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types, | 45 | static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types, |
46 | flag_preserve, flag_warnings; | 46 | flag_preserve, flag_warnings, flag_asm; |
47 | static const char *arch = ""; | 47 | static const char *arch = ""; |
48 | static const char *mod_prefix = ""; | 48 | static const char *mod_prefix = ""; |
49 | 49 | ||
@@ -610,8 +610,11 @@ void export_symbol(const char *name) | |||
610 | if (flag_dump_defs) | 610 | if (flag_dump_defs) |
611 | fputs(">\n", debugfile); | 611 | fputs(">\n", debugfile); |
612 | 612 | ||
613 | /* Used as a linker script. */ | 613 | /* Used as assembly source or a linker script. */ |
614 | printf("%s__crc_%s = 0x%08lx ;\n", mod_prefix, name, crc); | 614 | printf(flag_asm |
615 | ? ".equiv %s__crc_%s, %#08lx\n" | ||
616 | : "%s__crc_%s = %#08lx ;\n", | ||
617 | mod_prefix, name, crc); | ||
615 | } | 618 | } |
616 | } | 619 | } |
617 | 620 | ||
@@ -648,9 +651,10 @@ void error_with_pos(const char *fmt, ...) | |||
648 | 651 | ||
649 | static void genksyms_usage(void) | 652 | static void genksyms_usage(void) |
650 | { | 653 | { |
651 | fputs("Usage:\n" "genksyms [-adDTwqhV] > /path/to/.tmp_obj.ver\n" "\n" | 654 | fputs("Usage:\n" "genksyms [-aAdDTwqhV] > /path/to/.tmp_obj.ver\n" "\n" |
652 | #ifdef __GNU_LIBRARY__ | 655 | #ifdef __GNU_LIBRARY__ |
653 | " -a, --arch Select architecture\n" | 656 | " -a, --arch Select architecture\n" |
657 | " -A, --asm Generate assembly rather than linker script\n" | ||
654 | " -d, --debug Increment the debug level (repeatable)\n" | 658 | " -d, --debug Increment the debug level (repeatable)\n" |
655 | " -D, --dump Dump expanded symbol defs (for debugging only)\n" | 659 | " -D, --dump Dump expanded symbol defs (for debugging only)\n" |
656 | " -r, --reference file Read reference symbols from a file\n" | 660 | " -r, --reference file Read reference symbols from a file\n" |
@@ -662,6 +666,7 @@ static void genksyms_usage(void) | |||
662 | " -V, --version Print the release version\n" | 666 | " -V, --version Print the release version\n" |
663 | #else /* __GNU_LIBRARY__ */ | 667 | #else /* __GNU_LIBRARY__ */ |
664 | " -a Select architecture\n" | 668 | " -a Select architecture\n" |
669 | " -A Generate assembly rather than linker script\n" | ||
665 | " -d Increment the debug level (repeatable)\n" | 670 | " -d Increment the debug level (repeatable)\n" |
666 | " -D Dump expanded symbol defs (for debugging only)\n" | 671 | " -D Dump expanded symbol defs (for debugging only)\n" |
667 | " -r file Read reference symbols from a file\n" | 672 | " -r file Read reference symbols from a file\n" |
@@ -683,6 +688,7 @@ int main(int argc, char **argv) | |||
683 | #ifdef __GNU_LIBRARY__ | 688 | #ifdef __GNU_LIBRARY__ |
684 | struct option long_opts[] = { | 689 | struct option long_opts[] = { |
685 | {"arch", 1, 0, 'a'}, | 690 | {"arch", 1, 0, 'a'}, |
691 | {"asm", 0, 0, 'A'}, | ||
686 | {"debug", 0, 0, 'd'}, | 692 | {"debug", 0, 0, 'd'}, |
687 | {"warnings", 0, 0, 'w'}, | 693 | {"warnings", 0, 0, 'w'}, |
688 | {"quiet", 0, 0, 'q'}, | 694 | {"quiet", 0, 0, 'q'}, |
@@ -695,10 +701,10 @@ int main(int argc, char **argv) | |||
695 | {0, 0, 0, 0} | 701 | {0, 0, 0, 0} |
696 | }; | 702 | }; |
697 | 703 | ||
698 | while ((o = getopt_long(argc, argv, "a:dwqVDr:T:ph", | 704 | while ((o = getopt_long(argc, argv, "a:dwqVADr:T:ph", |
699 | &long_opts[0], NULL)) != EOF) | 705 | &long_opts[0], NULL)) != EOF) |
700 | #else /* __GNU_LIBRARY__ */ | 706 | #else /* __GNU_LIBRARY__ */ |
701 | while ((o = getopt(argc, argv, "a:dwqVDr:T:ph")) != EOF) | 707 | while ((o = getopt(argc, argv, "a:dwqVADr:T:ph")) != EOF) |
702 | #endif /* __GNU_LIBRARY__ */ | 708 | #endif /* __GNU_LIBRARY__ */ |
703 | switch (o) { | 709 | switch (o) { |
704 | case 'a': | 710 | case 'a': |
@@ -716,6 +722,9 @@ int main(int argc, char **argv) | |||
716 | case 'V': | 722 | case 'V': |
717 | fputs("genksyms version 2.5.60\n", stderr); | 723 | fputs("genksyms version 2.5.60\n", stderr); |
718 | break; | 724 | break; |
725 | case 'A': | ||
726 | flag_asm = 1; | ||
727 | break; | ||
719 | case 'D': | 728 | case 'D': |
720 | flag_dump_defs = 1; | 729 | flag_dump_defs = 1; |
721 | break; | 730 | break; |