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.
Unified · Split
| @@ -384,7 +384,6 @@ static int parse_elf(struct elf_info *info, const char *filename) · 383 unmodified lines | ||
| 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++) { |
| @@ -754,8 +753,6 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr, · 363 unmodified lines | ||
| 754 | 753 | for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { |
| 755 | 754 | if (sym->st_shndx != relsym->st_shndx) |
| 756 | 755 | continue; |
| 757 | − if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) | |
| 758 | − continue; | |
| 759 | 756 | if (sym->st_value == addr) |
| 760 | 757 | return sym; |
| 761 | 758 | } |
| @@ -898,68 +895,6 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, · 136 unmodified lines | ||
| 898 | 895 | } |
| 899 | 896 | } |
| 900 | 897 | |
| 901 | −static void addend_386_rel(struct elf_info *elf, int section, Elf_Rela *r) | |
| 902 | −{ | |
| 903 | − Elf_Shdr *sechdrs = elf->sechdrs; | |
| 904 | − unsigned int r_typ; | |
| 905 | − unsigned int *location; | |
| 906 | − | |
| 907 | − r_typ = ELF_R_TYPE(r->r_info); | |
| 908 | − location = (void *)elf->hdr + | |
| 909 | − sechdrs[sechdrs[section].sh_info].sh_offset + r->r_offset; | |
| 910 | − switch (r_typ) { | |
| 911 | − case R_386_32: | |
| 912 | − r->r_addend = TO_NATIVE(*location); | |
| 913 | − break; | |
| 914 | − case R_386_PC32: | |
| 915 | − r->r_addend = TO_NATIVE(*location) + 4; | |
| 916 | − break; | |
| 917 | − } | |
| 918 | −} | |
| 919 | − | |
| 920 | −static void addend_arm_rel(struct elf_info *elf, int section, Elf_Rela *r) | |
| 921 | −{ | |
| 922 | − Elf_Shdr *sechdrs = elf->sechdrs; | |
| 923 | − unsigned int r_typ; | |
| 924 | − unsigned int *location; | |
| 925 | − | |
| 926 | − r_typ = ELF_R_TYPE(r->r_info); | |
| 927 | − location = (void *)elf->hdr + | |
| 928 | − sechdrs[sechdrs[section].sh_info].sh_offset + r->r_offset; | |
| 929 | − switch (r_typ) { | |
| 930 | − case R_ARM_ABS32: | |
| 931 | − r->r_addend = TO_NATIVE(*location); | |
| 932 | − break; | |
| 933 | − case R_ARM_PC24: | |
| 934 | − r->r_addend = ((TO_NATIVE(*location) & 0x00ffffff) << 2) + 8; | |
| 935 | − break; | |
| 936 | − } | |
| 937 | −} | |
| 938 | − | |
| 939 | −static int addend_mips_rel(struct elf_info *elf, int section, Elf_Rela *r) | |
| 940 | −{ | |
| 941 | − Elf_Shdr *sechdrs = elf->sechdrs; | |
| 942 | − unsigned int r_typ; | |
| 943 | − unsigned int *location; | |
| 944 | − unsigned int inst; | |
| 945 | − | |
| 946 | − r_typ = ELF_R_TYPE(r->r_info); | |
| 947 | − if (r_typ == R_MIPS_HI16) | |
| 948 | − return 1; /* skip this */ | |
| 949 | − location = (void *)elf->hdr + | |
| 950 | − sechdrs[sechdrs[section].sh_info].sh_offset + r->r_offset; | |
| 951 | − inst = TO_NATIVE(*location); | |
| 952 | − switch (r_typ) { | |
| 953 | − case R_MIPS_LO16: | |
| 954 | − r->r_addend = ((inst & 0xffff) ^ 0x8000) - 0x8000; | |
| 955 | − break; | |
| 956 | − case R_MIPS_26: | |
| 957 | − r->r_addend = (inst & 0x03ffffff) << 2; | |
| 958 | − break; | |
| 959 | − } | |
| 960 | − return 0; | |
| 961 | −} | |
| 962 | − | |
| 963 | 898 | /** |
| 964 | 899 | * A module includes a number of sections that are discarded |
| 965 | 900 | * either when loaded or when used as built-in. |
| @@ -1003,11 +938,8 @@ static void check_sec_ref(struct module *mod, const char *modname, · 37 unmodified lines | ||
| 1003 | 938 | r.r_offset = TO_NATIVE(rela->r_offset); |
| 1004 | 939 | #if KERNEL_ELFCLASS == ELFCLASS64 |
| 1005 | 940 | if (hdr->e_machine == EM_MIPS) { |
| 1006 | − unsigned int r_typ; | |
| 1007 | 941 | r_sym = ELF64_MIPS_R_SYM(rela->r_info); |
| 1008 | 942 | r_sym = TO_NATIVE(r_sym); |
| 1009 | − r_typ = ELF64_MIPS_R_TYPE(rela->r_info); | |
| 1010 | − r.r_info = ELF64_R_INFO(r_sym, r_typ); | |
| 1011 | 943 | } else { |
| 1012 | 944 | r.r_info = TO_NATIVE(rela->r_info); |
| 1013 | 945 | r_sym = ELF_R_SYM(r.r_info); |
| @@ -1040,11 +972,8 @@ static void check_sec_ref(struct module *mod, const char *modname, · 26 unmodified lines | ||
| 1040 | 972 | r.r_offset = TO_NATIVE(rel->r_offset); |
| 1041 | 973 | #if KERNEL_ELFCLASS == ELFCLASS64 |
| 1042 | 974 | if (hdr->e_machine == EM_MIPS) { |
| 1043 | − unsigned int r_typ; | |
| 1044 | 975 | r_sym = ELF64_MIPS_R_SYM(rel->r_info); |
| 1045 | 976 | r_sym = TO_NATIVE(r_sym); |
| 1046 | − r_typ = ELF64_MIPS_R_TYPE(rel->r_info); | |
| 1047 | − r.r_info = ELF64_R_INFO(r_sym, r_typ); | |
| 1048 | 977 | } else { |
| 1049 | 978 | r.r_info = TO_NATIVE(rel->r_info); |
| 1050 | 979 | r_sym = ELF_R_SYM(r.r_info); |
| @@ -1054,14 +983,6 @@ static void check_sec_ref(struct module *mod, const char *modname, · 3 unmodified lines | ||
| 1054 | 983 | r_sym = ELF_R_SYM(r.r_info); |
| 1055 | 984 | #endif |
| 1056 | 985 | r.r_addend = 0; |
| 1057 | − if (hdr->e_machine == EM_386) | |
| 1058 | − addend_386_rel(elf, i, &r); | |
| 1059 | − else if (hdr->e_machine == EM_ARM) | |
| 1060 | − addend_arm_rel(elf, i, &r); | |
| 1061 | − else if (hdr->e_machine == EM_MIPS) { | |
| 1062 | − if (addend_mips_rel(elf, i, &r)) | |
| 1063 | − continue; | |
| 1064 | − } | |
| 1065 | 986 | sym = elf->symtab_start + r_sym; |
| 1066 | 987 | /* Skip special sections */ |
| 1067 | 988 | if (sym->st_shndx >= SHN_LORESERVE) |
| @@ -60,9 +60,6 @@ typedef union · 59 unmodified lines | ||
| 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) |