Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "kbuild: make better section mismatch reports on i386, arm and mips"

This reverts commit f892b7d480eec809a5dfbd6e65742b3f3155e50e, which
totally broke the build on x86 with CONFIG_RELOCATABLE (which, as far as
I can tell, is the only case where it should even matter!) due to a
SIGSEGV in modpost.

Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

-82
-79
scripts/mod/modpost.c
··· 384 384 sechdrs[i].sh_size = TO_NATIVE(sechdrs[i].sh_size); 385 385 sechdrs[i].sh_link = TO_NATIVE(sechdrs[i].sh_link); 386 386 sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name); 387 - sechdrs[i].sh_info = TO_NATIVE(sechdrs[i].sh_info); 388 387 } 389 388 /* Find symbol table. */ 390 389 for (i = 1; i < hdr->e_shnum; i++) { ··· 753 754 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { 754 755 if (sym->st_shndx != relsym->st_shndx) 755 756 continue; 756 - if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) 757 - continue; 758 757 if (sym->st_value == addr) 759 758 return sym; 760 759 } ··· 895 898 } 896 899 } 897 900 898 - static void addend_386_rel(struct elf_info *elf, int section, Elf_Rela *r) 899 - { 900 - Elf_Shdr *sechdrs = elf->sechdrs; 901 - unsigned int r_typ; 902 - unsigned int *location; 903 - 904 - r_typ = ELF_R_TYPE(r->r_info); 905 - location = (void *)elf->hdr + 906 - sechdrs[sechdrs[section].sh_info].sh_offset + r->r_offset; 907 - switch (r_typ) { 908 - case R_386_32: 909 - r->r_addend = TO_NATIVE(*location); 910 - break; 911 - case R_386_PC32: 912 - r->r_addend = TO_NATIVE(*location) + 4; 913 - break; 914 - } 915 - } 916 - 917 - static void addend_arm_rel(struct elf_info *elf, int section, Elf_Rela *r) 918 - { 919 - Elf_Shdr *sechdrs = elf->sechdrs; 920 - unsigned int r_typ; 921 - unsigned int *location; 922 - 923 - r_typ = ELF_R_TYPE(r->r_info); 924 - location = (void *)elf->hdr + 925 - sechdrs[sechdrs[section].sh_info].sh_offset + r->r_offset; 926 - switch (r_typ) { 927 - case R_ARM_ABS32: 928 - r->r_addend = TO_NATIVE(*location); 929 - break; 930 - case R_ARM_PC24: 931 - r->r_addend = ((TO_NATIVE(*location) & 0x00ffffff) << 2) + 8; 932 - break; 933 - } 934 - } 935 - 936 - static int addend_mips_rel(struct elf_info *elf, int section, Elf_Rela *r) 937 - { 938 - Elf_Shdr *sechdrs = elf->sechdrs; 939 - unsigned int r_typ; 940 - unsigned int *location; 941 - unsigned int inst; 942 - 943 - r_typ = ELF_R_TYPE(r->r_info); 944 - if (r_typ == R_MIPS_HI16) 945 - return 1; /* skip this */ 946 - location = (void *)elf->hdr + 947 - sechdrs[sechdrs[section].sh_info].sh_offset + r->r_offset; 948 - inst = TO_NATIVE(*location); 949 - switch (r_typ) { 950 - case R_MIPS_LO16: 951 - r->r_addend = ((inst & 0xffff) ^ 0x8000) - 0x8000; 952 - break; 953 - case R_MIPS_26: 954 - r->r_addend = (inst & 0x03ffffff) << 2; 955 - break; 956 - } 957 - return 0; 958 - } 959 - 960 901 /** 961 902 * A module includes a number of sections that are discarded 962 903 * either when loaded or when used as built-in. ··· 938 1003 r.r_offset = TO_NATIVE(rela->r_offset); 939 1004 #if KERNEL_ELFCLASS == ELFCLASS64 940 1005 if (hdr->e_machine == EM_MIPS) { 941 - unsigned int r_typ; 942 1006 r_sym = ELF64_MIPS_R_SYM(rela->r_info); 943 1007 r_sym = TO_NATIVE(r_sym); 944 - r_typ = ELF64_MIPS_R_TYPE(rela->r_info); 945 - r.r_info = ELF64_R_INFO(r_sym, r_typ); 946 1008 } else { 947 1009 r.r_info = TO_NATIVE(rela->r_info); 948 1010 r_sym = ELF_R_SYM(r.r_info); ··· 972 1040 r.r_offset = TO_NATIVE(rel->r_offset); 973 1041 #if KERNEL_ELFCLASS == ELFCLASS64 974 1042 if (hdr->e_machine == EM_MIPS) { 975 - unsigned int r_typ; 976 1043 r_sym = ELF64_MIPS_R_SYM(rel->r_info); 977 1044 r_sym = TO_NATIVE(r_sym); 978 - r_typ = ELF64_MIPS_R_TYPE(rel->r_info); 979 - r.r_info = ELF64_R_INFO(r_sym, r_typ); 980 1045 } else { 981 1046 r.r_info = TO_NATIVE(rel->r_info); 982 1047 r_sym = ELF_R_SYM(r.r_info); ··· 983 1054 r_sym = ELF_R_SYM(r.r_info); 984 1055 #endif 985 1056 r.r_addend = 0; 986 - if (hdr->e_machine == EM_386) 987 - addend_386_rel(elf, i, &r); 988 - else if (hdr->e_machine == EM_ARM) 989 - addend_arm_rel(elf, i, &r); 990 - else if (hdr->e_machine == EM_MIPS) { 991 - if (addend_mips_rel(elf, i, &r)) 992 - continue; 993 - } 994 1057 sym = elf->symtab_start + r_sym; 995 1058 /* Skip special sections */ 996 1059 if (sym->st_shndx >= SHN_LORESERVE)
-3
scripts/mod/modpost.h
··· 60 60 #define ELF64_MIPS_R_SYM(i) \ 61 61 ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym) 62 62 63 - #define ELF64_MIPS_R_TYPE(i) \ 64 - ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type1) 65 - 66 63 #if KERNEL_ELFDATA != HOST_ELFDATA 67 64 68 65 static inline void __endian(const void *src, void *dest, unsigned int size)