diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2006-05-25 12:40:08 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-05-25 12:40:08 -0400 |
commit | c6a756795d5ba0637aae8da89dd11bb7e3a1ee74 (patch) | |
tree | 1c19f951f2604dbb6b867a6dcdf94d20c204cc5c /scripts | |
parent | 382066da251132f768380f4852ed5afb72d88f80 (diff) | |
parent | a8bd60705aa17a998516837d9c1e503ad4cbd7fc (diff) |
Merge branch 'master'
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/mod/modpost.c | 88 | ||||
-rw-r--r-- | scripts/mod/modpost.h | 23 |
2 files changed, 90 insertions, 21 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 6d04504b2fc1..d0f86ed43f7a 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -697,29 +697,79 @@ 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 + | 703 | unsigned int r_sym; |
704 | strlen(".rela"); | ||
705 | /* We want to process only relocation sections and not .init */ | 704 | /* We want to process only relocation sections and not .init */ |
706 | if (section_ref_ok(name) || (sechdrs[i].sh_type != SHT_RELA)) | 705 | if (sechdrs[i].sh_type == SHT_RELA) { |
707 | continue; | 706 | Elf_Rela *rela; |
707 | Elf_Rela *start = (void *)hdr + sechdrs[i].sh_offset; | ||
708 | Elf_Rela *stop = (void*)start + sechdrs[i].sh_size; | ||
709 | name += strlen(".rela"); | ||
710 | if (section_ref_ok(name)) | ||
711 | continue; | ||
708 | 712 | ||
709 | for (rela = start; rela < stop; rela++) { | 713 | for (rela = start; rela < stop; rela++) { |
710 | Elf_Rela r; | 714 | r.r_offset = TO_NATIVE(rela->r_offset); |
711 | const char *secname; | 715 | #if KERNEL_ELFCLASS == ELFCLASS64 |
712 | r.r_offset = TO_NATIVE(rela->r_offset); | 716 | if (hdr->e_machine == EM_MIPS) { |
713 | r.r_info = TO_NATIVE(rela->r_info); | 717 | r_sym = ELF64_MIPS_R_SYM(rela->r_info); |
714 | r.r_addend = TO_NATIVE(rela->r_addend); | 718 | r_sym = TO_NATIVE(r_sym); |
715 | sym = elf->symtab_start + ELF_R_SYM(r.r_info); | 719 | } else { |
716 | /* Skip special sections */ | 720 | r.r_info = TO_NATIVE(rela->r_info); |
717 | if (sym->st_shndx >= SHN_LORESERVE) | 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 | ||
727 | r.r_addend = TO_NATIVE(rela->r_addend); | ||
728 | sym = elf->symtab_start + r_sym; | ||
729 | /* Skip special sections */ | ||
730 | if (sym->st_shndx >= SHN_LORESERVE) | ||
731 | continue; | ||
732 | |||
733 | secname = secstrings + | ||
734 | sechdrs[sym->st_shndx].sh_name; | ||
735 | if (section(secname)) | ||
736 | warn_sec_mismatch(modname, name, | ||
737 | elf, sym, r); | ||
738 | } | ||
739 | } else if (sechdrs[i].sh_type == SHT_REL) { | ||
740 | Elf_Rel *rel; | ||
741 | Elf_Rel *start = (void *)hdr + sechdrs[i].sh_offset; | ||
742 | Elf_Rel *stop = (void*)start + sechdrs[i].sh_size; | ||
743 | name += strlen(".rel"); | ||
744 | if (section_ref_ok(name)) | ||
718 | continue; | 745 | continue; |
719 | 746 | ||
720 | secname = secstrings + sechdrs[sym->st_shndx].sh_name; | 747 | for (rel = start; rel < stop; rel++) { |
721 | if (section(secname)) | 748 | r.r_offset = TO_NATIVE(rel->r_offset); |
722 | warn_sec_mismatch(modname, name, elf, sym, r); | 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 | ||
761 | r.r_addend = 0; | ||
762 | sym = elf->symtab_start + r_sym; | ||
763 | /* Skip special sections */ | ||
764 | if (sym->st_shndx >= SHN_LORESERVE) | ||
765 | continue; | ||
766 | |||
767 | secname = secstrings + | ||
768 | sechdrs[sym->st_shndx].sh_name; | ||
769 | if (section(secname)) | ||
770 | warn_sec_mismatch(modname, name, | ||
771 | elf, sym, r); | ||
772 | } | ||
723 | } | 773 | } |
724 | } | 774 | } |
725 | } | 775 | } |
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index b14255c72a37..861d866fcd83 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #define ELF_ST_BIND ELF32_ST_BIND | 21 | #define ELF_ST_BIND ELF32_ST_BIND |
22 | #define ELF_ST_TYPE ELF32_ST_TYPE | 22 | #define ELF_ST_TYPE ELF32_ST_TYPE |
23 | 23 | ||
24 | #define Elf_Rel Elf32_Rel | ||
24 | #define Elf_Rela Elf32_Rela | 25 | #define Elf_Rela Elf32_Rela |
25 | #define ELF_R_SYM ELF32_R_SYM | 26 | #define ELF_R_SYM ELF32_R_SYM |
26 | #define ELF_R_TYPE ELF32_R_TYPE | 27 | #define ELF_R_TYPE ELF32_R_TYPE |
@@ -34,11 +35,31 @@ | |||
34 | #define ELF_ST_BIND ELF64_ST_BIND | 35 | #define ELF_ST_BIND ELF64_ST_BIND |
35 | #define ELF_ST_TYPE ELF64_ST_TYPE | 36 | #define ELF_ST_TYPE ELF64_ST_TYPE |
36 | 37 | ||
38 | #define Elf_Rel Elf64_Rel | ||
37 | #define Elf_Rela Elf64_Rela | 39 | #define Elf_Rela Elf64_Rela |
38 | #define ELF_R_SYM ELF64_R_SYM | 40 | #define ELF_R_SYM ELF64_R_SYM |
39 | #define ELF_R_TYPE ELF64_R_TYPE | 41 | #define ELF_R_TYPE ELF64_R_TYPE |
40 | #endif | 42 | #endif |
41 | 43 | ||
44 | /* The 64-bit MIPS ELF ABI uses an unusual reloc format. */ | ||
45 | typedef struct | ||
46 | { | ||
47 | Elf32_Word r_sym; /* Symbol index */ | ||
48 | unsigned char r_ssym; /* Special symbol for 2nd relocation */ | ||
49 | unsigned char r_type3; /* 3rd relocation type */ | ||
50 | unsigned char r_type2; /* 2nd relocation type */ | ||
51 | unsigned char r_type1; /* 1st relocation type */ | ||
52 | } _Elf64_Mips_R_Info; | ||
53 | |||
54 | typedef union | ||
55 | { | ||
56 | Elf64_Xword r_info_number; | ||
57 | _Elf64_Mips_R_Info r_info_fields; | ||
58 | } _Elf64_Mips_R_Info_union; | ||
59 | |||
60 | #define ELF64_MIPS_R_SYM(i) \ | ||
61 | ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym) | ||
62 | |||
42 | #if KERNEL_ELFDATA != HOST_ELFDATA | 63 | #if KERNEL_ELFDATA != HOST_ELFDATA |
43 | 64 | ||
44 | static inline void __endian(const void *src, void *dest, unsigned int size) | 65 | static inline void __endian(const void *src, void *dest, unsigned int size) |
@@ -48,8 +69,6 @@ static inline void __endian(const void *src, void *dest, unsigned int size) | |||
48 | ((unsigned char*)dest)[i] = ((unsigned char*)src)[size - i-1]; | 69 | ((unsigned char*)dest)[i] = ((unsigned char*)src)[size - i-1]; |
49 | } | 70 | } |
50 | 71 | ||
51 | |||
52 | |||
53 | #define TO_NATIVE(x) \ | 72 | #define TO_NATIVE(x) \ |
54 | ({ \ | 73 | ({ \ |
55 | typeof(x) __x; \ | 74 | typeof(x) __x; \ |