aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod/modpost.c
diff options
context:
space:
mode:
authorSam Ravnborg <sam@ravnborg.org>2008-01-28 14:13:13 -0500
committerSam Ravnborg <sam@ravnborg.org>2008-01-28 17:21:19 -0500
commite241a630374e06aecdae2884af8b652d3b4d6c37 (patch)
tree9b2bdf28122fe59a3479b7dcba2978db297409f0 /scripts/mod/modpost.c
parent588ccd732ba2d32db8228802ef9283b583d3395f (diff)
kbuild: warn about ld added unique sections
If there is a mixture of specifying sections for code in gcc and assembler then if the assembler code do not add the "ax" flags the linker will see this as two different sections and generate unique sections for each. ld does so by adding a dot and a number. Teach modpost to warn if a section shows up that match this pattern - but do this only for non-debug sections. It will result in warnings like this: WARNING: vmlinux.o (.sched.text.1): unexpected section name. The (.[number]+) following section name are ld generated and not expected. Did you forget to use "ax"/"aw" in a .S file? Note that for example <linux/init.h> contains section definitions for use in .S files. All warnings seen with a defconfig build for: x86 (32+64bit) and sparc64 has been fixed (via respective maintainers). arm, powerpc (64 bit), s390 (32 bit), ia64, alpha, sh4 checked - no warnings seen with a defconfig build. Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/mod/modpost.c')
-rw-r--r--scripts/mod/modpost.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 3cf1ba8220d2..f8efc93eb700 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -696,6 +696,43 @@ int match(const char *sym, const char * const pat[])
696static const char *section_white_list[] = 696static const char *section_white_list[] =
697 { ".debug*", ".stab*", ".note*", ".got*", ".toc*", NULL }; 697 { ".debug*", ".stab*", ".note*", ".got*", ".toc*", NULL };
698 698
699/*
700 * Is this section one we do not want to check?
701 * This is often debug sections.
702 * If we are going to check this section then
703 * test if section name ends with a dot and a number.
704 * This is used to find sections where the linker have
705 * appended a dot-number to make the name unique.
706 * The cause of this is often a section specified in assembler
707 * without "ax" / "aw" and the same section used in .c
708 * code where gcc add these.
709 */
710static int check_section(const char *modname, const char *sec)
711{
712 const char *e = sec + strlen(sec) - 1;
713 if (match(sec, section_white_list))
714 return 1;
715
716 if (*e && isdigit(*e)) {
717 /* consume all digits */
718 while (*e && e != sec && isdigit(*e))
719 e--;
720 if (*e == '.') {
721 warn("%s (%s): unexpected section name.\n"
722 "The (.[number]+) following section name are "
723 "ld generated and not expected.\n"
724 "Did you forget to use \"ax\"/\"aw\" "
725 "in a .S file?\n"
726 "Note that for example <linux/init.h> contains\n"
727 "section definitions for use in .S files.\n\n",
728 modname, sec);
729 }
730 }
731 return 0;
732}
733
734
735
699#define ALL_INIT_DATA_SECTIONS \ 736#define ALL_INIT_DATA_SECTIONS \
700 ".init.data$", ".devinit.data$", ".cpuinit.data$", ".meminit.data$" 737 ".init.data$", ".devinit.data$", ".cpuinit.data$", ".meminit.data$"
701#define ALL_EXIT_DATA_SECTIONS \ 738#define ALL_EXIT_DATA_SECTIONS \
@@ -1311,8 +1348,9 @@ static void section_rela(const char *modname, struct elf_info *elf,
1311 fromsec = sech_name(elf, sechdr); 1348 fromsec = sech_name(elf, sechdr);
1312 fromsec += strlen(".rela"); 1349 fromsec += strlen(".rela");
1313 /* if from section (name) is know good then skip it */ 1350 /* if from section (name) is know good then skip it */
1314 if (match(fromsec, section_white_list)) 1351 if (check_section(modname, fromsec))
1315 return; 1352 return;
1353
1316 for (rela = start; rela < stop; rela++) { 1354 for (rela = start; rela < stop; rela++) {
1317 r.r_offset = TO_NATIVE(rela->r_offset); 1355 r.r_offset = TO_NATIVE(rela->r_offset);
1318#if KERNEL_ELFCLASS == ELFCLASS64 1356#if KERNEL_ELFCLASS == ELFCLASS64
@@ -1354,7 +1392,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
1354 fromsec = sech_name(elf, sechdr); 1392 fromsec = sech_name(elf, sechdr);
1355 fromsec += strlen(".rel"); 1393 fromsec += strlen(".rel");
1356 /* if from section (name) is know good then skip it */ 1394 /* if from section (name) is know good then skip it */
1357 if (match(fromsec, section_white_list)) 1395 if (check_section(modname, fromsec))
1358 return; 1396 return;
1359 1397
1360 for (rel = start; rel < stop; rel++) { 1398 for (rel = start; rel < stop; rel++) {