aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod/modpost.c
diff options
context:
space:
mode:
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>2006-05-20 18:00:28 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-05-21 15:59:21 -0400
commiteae07ac607f317ee6781983d3f9d8f77ef144b45 (patch)
tree4eb308235b077a69794d52d72b9241e2dd48f990 /scripts/mod/modpost.c
parent2c1a51f39d9551a514d7a089d01c23c0c3a54ab8 (diff)
[PATCH] kbuild: fix modpost segfault for 64bit mipsel kernel
Here is an updated r_info layout fix. Please apply "check SHT_REL sections" patch before this. 64bit mips has different r_info layout. This patch fixes modpost segfault for 64bit little endian mips kernel. 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.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 1aa52a86c2cf..d0f86ed43f7a 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -700,6 +700,7 @@ static void check_sec_ref(struct module *mod, const char *modname,
700 const char *name = secstrings + sechdrs[i].sh_name; 700 const char *name = secstrings + sechdrs[i].sh_name;
701 const char *secname; 701 const char *secname;
702 Elf_Rela r; 702 Elf_Rela r;
703 unsigned int r_sym;
703 /* We want to process only relocation sections and not .init */ 704 /* We want to process only relocation sections and not .init */
704 if (sechdrs[i].sh_type == SHT_RELA) { 705 if (sechdrs[i].sh_type == SHT_RELA) {
705 Elf_Rela *rela; 706 Elf_Rela *rela;
@@ -711,9 +712,20 @@ static void check_sec_ref(struct module *mod, const char *modname,
711 712
712 for (rela = start; rela < stop; rela++) { 713 for (rela = start; rela < stop; rela++) {
713 r.r_offset = TO_NATIVE(rela->r_offset); 714 r.r_offset = TO_NATIVE(rela->r_offset);
714 r.r_info = TO_NATIVE(rela->r_info); 715#if KERNEL_ELFCLASS == ELFCLASS64
716 if (hdr->e_machine == EM_MIPS) {
717 r_sym = ELF64_MIPS_R_SYM(rela->r_info);
718 r_sym = TO_NATIVE(r_sym);
719 } else {
720 r.r_info = TO_NATIVE(rela->r_info);
721 r_sym = ELF_R_SYM(r.r_info);
722 }
723#else
724 r.r_info = TO_NATIVE(rela->r_info);
725 r_sym = ELF_R_SYM(r.r_info);
726#endif
715 r.r_addend = TO_NATIVE(rela->r_addend); 727 r.r_addend = TO_NATIVE(rela->r_addend);
716 sym = elf->symtab_start + ELF_R_SYM(r.r_info); 728 sym = elf->symtab_start + r_sym;
717 /* Skip special sections */ 729 /* Skip special sections */
718 if (sym->st_shndx >= SHN_LORESERVE) 730 if (sym->st_shndx >= SHN_LORESERVE)
719 continue; 731 continue;
@@ -734,9 +746,20 @@ static void check_sec_ref(struct module *mod, const char *modname,
734 746
735 for (rel = start; rel < stop; rel++) { 747 for (rel = start; rel < stop; rel++) {
736 r.r_offset = TO_NATIVE(rel->r_offset); 748 r.r_offset = TO_NATIVE(rel->r_offset);
737 r.r_info = TO_NATIVE(rel->r_info); 749#if KERNEL_ELFCLASS == ELFCLASS64
750 if (hdr->e_machine == EM_MIPS) {
751 r_sym = ELF64_MIPS_R_SYM(rel->r_info);
752 r_sym = TO_NATIVE(r_sym);
753 } else {
754 r.r_info = TO_NATIVE(rel->r_info);
755 r_sym = ELF_R_SYM(r.r_info);
756 }
757#else
758 r.r_info = TO_NATIVE(rel->r_info);
759 r_sym = ELF_R_SYM(r.r_info);
760#endif
738 r.r_addend = 0; 761 r.r_addend = 0;
739 sym = elf->symtab_start + ELF_R_SYM(r.r_info); 762 sym = elf->symtab_start + r_sym;
740 /* Skip special sections */ 763 /* Skip special sections */
741 if (sym->st_shndx >= SHN_LORESERVE) 764 if (sym->st_shndx >= SHN_LORESERVE)
742 continue; 765 continue;