aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod/modpost.c
diff options
context:
space:
mode:
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>2006-05-20 18:00:26 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-05-21 15:59:21 -0400
commit2c1a51f39d9551a514d7a089d01c23c0c3a54ab8 (patch)
treee938e986a1a6f41ac701ad231601d90d4c824ffb /scripts/mod/modpost.c
parent92f63cd000059366af18712367216d96180e0ec0 (diff)
[PATCH] kbuild: check SHT_REL sections
I found that modpost can not detect section mismatch on mips and i386. On mips64, the modpost (with r_info layout fix) can detect it. The current modpst only checks SHT_RELA section but I suppose SHT_REL section should be checked also. This patch does not contain r_info layout fix. I'll post an updated r_info layout fix on next mail. Check SHT_REL sections as like as SHT_RELA sections to detect section mismatch. Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Cc: Sam Ravnborg <sam@ravnborg.org> Cc: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'scripts/mod/modpost.c')
-rw-r--r--scripts/mod/modpost.c65
1 files changed, 46 insertions, 19 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 6d04504b2fc1..1aa52a86c2cf 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -697,29 +697,56 @@ static void check_sec_ref(struct module *mod, const char *modname,
697 697
698 /* Walk through all sections */ 698 /* Walk through all sections */
699 for (i = 0; i < hdr->e_shnum; i++) { 699 for (i = 0; i < hdr->e_shnum; i++) {
700 Elf_Rela *rela; 700 const char *name = secstrings + sechdrs[i].sh_name;
701 Elf_Rela *start = (void *)hdr + sechdrs[i].sh_offset; 701 const char *secname;
702 Elf_Rela *stop = (void*)start + sechdrs[i].sh_size; 702 Elf_Rela r;
703 const char *name = secstrings + sechdrs[i].sh_name +
704 strlen(".rela");
705 /* We want to process only relocation sections and not .init */ 703 /* We want to process only relocation sections and not .init */
706 if (section_ref_ok(name) || (sechdrs[i].sh_type != SHT_RELA)) 704 if (sechdrs[i].sh_type == SHT_RELA) {
707 continue; 705 Elf_Rela *rela;
706 Elf_Rela *start = (void *)hdr + sechdrs[i].sh_offset;
707 Elf_Rela *stop = (void*)start + sechdrs[i].sh_size;
708 name += strlen(".rela");
709 if (section_ref_ok(name))
710 continue;
708 711
709 for (rela = start; rela < stop; rela++) { 712 for (rela = start; rela < stop; rela++) {
710 Elf_Rela r; 713 r.r_offset = TO_NATIVE(rela->r_offset);
711 const char *secname; 714 r.r_info = TO_NATIVE(rela->r_info);
712 r.r_offset = TO_NATIVE(rela->r_offset); 715 r.r_addend = TO_NATIVE(rela->r_addend);
713 r.r_info = TO_NATIVE(rela->r_info); 716 sym = elf->symtab_start + ELF_R_SYM(r.r_info);
714 r.r_addend = TO_NATIVE(rela->r_addend); 717 /* Skip special sections */
715 sym = elf->symtab_start + ELF_R_SYM(r.r_info); 718 if (sym->st_shndx >= SHN_LORESERVE)
716 /* Skip special sections */ 719 continue;
717 if (sym->st_shndx >= SHN_LORESERVE) 720
721 secname = secstrings +
722 sechdrs[sym->st_shndx].sh_name;
723 if (section(secname))
724 warn_sec_mismatch(modname, name,
725 elf, sym, r);
726 }
727 } else if (sechdrs[i].sh_type == SHT_REL) {
728 Elf_Rel *rel;
729 Elf_Rel *start = (void *)hdr + sechdrs[i].sh_offset;
730 Elf_Rel *stop = (void*)start + sechdrs[i].sh_size;
731 name += strlen(".rel");
732 if (section_ref_ok(name))
718 continue; 733 continue;
719 734
720 secname = secstrings + sechdrs[sym->st_shndx].sh_name; 735 for (rel = start; rel < stop; rel++) {
721 if (section(secname)) 736 r.r_offset = TO_NATIVE(rel->r_offset);
722 warn_sec_mismatch(modname, name, elf, sym, r); 737 r.r_info = TO_NATIVE(rel->r_info);
738 r.r_addend = 0;
739 sym = elf->symtab_start + ELF_R_SYM(r.r_info);
740 /* Skip special sections */
741 if (sym->st_shndx >= SHN_LORESERVE)
742 continue;
743
744 secname = secstrings +
745 sechdrs[sym->st_shndx].sh_name;
746 if (section(secname))
747 warn_sec_mismatch(modname, name,
748 elf, sym, r);
749 }
723 } 750 }
724 } 751 }
725} 752}