aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/genksyms
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2017-02-03 04:54:05 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-02-03 11:28:25 -0500
commit56067812d5b0e737ac2063e94a50f76b810d6ca3 (patch)
tree1627e6abc9001f0b519ed65daa86be46d52c4117 /scripts/genksyms
parent34e00accf612bc5448ae709245c2b408edf39f46 (diff)
kbuild: modversions: add infrastructure for emitting relative CRCs
This add the kbuild infrastructure that will allow architectures to emit vmlinux symbol CRCs as 32-bit offsets to another location in the kernel where the actual value is stored. This works around problems with CRCs being mistaken for relocatable symbols on kernels that self relocate at runtime (i.e., powerpc with CONFIG_RELOCATABLE=y) For the kbuild side of things, this comes down to the following: - introducing a Kconfig symbol MODULE_REL_CRCS - adding a -R switch to genksyms to instruct it to emit the CRC symbols as references into the .rodata section - making modpost distinguish such references from absolute CRC symbols by the section index (SHN_ABS) - making kallsyms disregard non-absolute symbols with a __crc_ prefix Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/genksyms')
-rw-r--r--scripts/genksyms/genksyms.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
index 06121ce524a7..c9235d8340f1 100644
--- a/scripts/genksyms/genksyms.c
+++ b/scripts/genksyms/genksyms.c
@@ -44,7 +44,7 @@ char *cur_filename, *source_file;
44int in_source_file; 44int in_source_file;
45 45
46static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types, 46static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types,
47 flag_preserve, flag_warnings; 47 flag_preserve, flag_warnings, flag_rel_crcs;
48static const char *mod_prefix = ""; 48static const char *mod_prefix = "";
49 49
50static int errors; 50static int errors;
@@ -693,7 +693,10 @@ void export_symbol(const char *name)
693 fputs(">\n", debugfile); 693 fputs(">\n", debugfile);
694 694
695 /* Used as a linker script. */ 695 /* Used as a linker script. */
696 printf("%s__crc_%s = 0x%08lx ;\n", mod_prefix, name, crc); 696 printf(!flag_rel_crcs ? "%s__crc_%s = 0x%08lx;\n" :
697 "SECTIONS { .rodata : ALIGN(4) { "
698 "%s__crc_%s = .; LONG(0x%08lx); } }\n",
699 mod_prefix, name, crc);
697 } 700 }
698} 701}
699 702
@@ -730,7 +733,7 @@ void error_with_pos(const char *fmt, ...)
730 733
731static void genksyms_usage(void) 734static void genksyms_usage(void)
732{ 735{
733 fputs("Usage:\n" "genksyms [-adDTwqhV] > /path/to/.tmp_obj.ver\n" "\n" 736 fputs("Usage:\n" "genksyms [-adDTwqhVR] > /path/to/.tmp_obj.ver\n" "\n"
734#ifdef __GNU_LIBRARY__ 737#ifdef __GNU_LIBRARY__
735 " -s, --symbol-prefix Select symbol prefix\n" 738 " -s, --symbol-prefix Select symbol prefix\n"
736 " -d, --debug Increment the debug level (repeatable)\n" 739 " -d, --debug Increment the debug level (repeatable)\n"
@@ -742,6 +745,7 @@ static void genksyms_usage(void)
742 " -q, --quiet Disable warnings (default)\n" 745 " -q, --quiet Disable warnings (default)\n"
743 " -h, --help Print this message\n" 746 " -h, --help Print this message\n"
744 " -V, --version Print the release version\n" 747 " -V, --version Print the release version\n"
748 " -R, --relative-crc Emit section relative symbol CRCs\n"
745#else /* __GNU_LIBRARY__ */ 749#else /* __GNU_LIBRARY__ */
746 " -s Select symbol prefix\n" 750 " -s Select symbol prefix\n"
747 " -d Increment the debug level (repeatable)\n" 751 " -d Increment the debug level (repeatable)\n"
@@ -753,6 +757,7 @@ static void genksyms_usage(void)
753 " -q Disable warnings (default)\n" 757 " -q Disable warnings (default)\n"
754 " -h Print this message\n" 758 " -h Print this message\n"
755 " -V Print the release version\n" 759 " -V Print the release version\n"
760 " -R Emit section relative symbol CRCs\n"
756#endif /* __GNU_LIBRARY__ */ 761#endif /* __GNU_LIBRARY__ */
757 , stderr); 762 , stderr);
758} 763}
@@ -774,13 +779,14 @@ int main(int argc, char **argv)
774 {"preserve", 0, 0, 'p'}, 779 {"preserve", 0, 0, 'p'},
775 {"version", 0, 0, 'V'}, 780 {"version", 0, 0, 'V'},
776 {"help", 0, 0, 'h'}, 781 {"help", 0, 0, 'h'},
782 {"relative-crc", 0, 0, 'R'},
777 {0, 0, 0, 0} 783 {0, 0, 0, 0}
778 }; 784 };
779 785
780 while ((o = getopt_long(argc, argv, "s:dwqVDr:T:ph", 786 while ((o = getopt_long(argc, argv, "s:dwqVDr:T:phR",
781 &long_opts[0], NULL)) != EOF) 787 &long_opts[0], NULL)) != EOF)
782#else /* __GNU_LIBRARY__ */ 788#else /* __GNU_LIBRARY__ */
783 while ((o = getopt(argc, argv, "s:dwqVDr:T:ph")) != EOF) 789 while ((o = getopt(argc, argv, "s:dwqVDr:T:phR")) != EOF)
784#endif /* __GNU_LIBRARY__ */ 790#endif /* __GNU_LIBRARY__ */
785 switch (o) { 791 switch (o) {
786 case 's': 792 case 's':
@@ -823,6 +829,9 @@ int main(int argc, char **argv)
823 case 'h': 829 case 'h':
824 genksyms_usage(); 830 genksyms_usage();
825 return 0; 831 return 0;
832 case 'R':
833 flag_rel_crcs = 1;
834 break;
826 default: 835 default:
827 genksyms_usage(); 836 genksyms_usage();
828 return 1; 837 return 1;