History

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.

Linus Torvalds committed 19 years ago

Commit efa5bf11 parent d6f2fe92 files · +0 −82Browse files

Showing the changes to scripts (2 of 2 files). Show all

Unified · Split

2 files
  1. scripts/mod/modpost.c +0 −79
  2. scripts/mod/modpost.h +0 −3
scripts/mod/modpost.c+0−79
@@ -384,7 +384,6 @@ static int parse_elf(struct elf_info *info, const char *filename) · 383 unmodified lines
384384 sechdrs[i].sh_size = TO_NATIVE(sechdrs[i].sh_size);
385385 sechdrs[i].sh_link = TO_NATIVE(sechdrs[i].sh_link);
386386 sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name);
387− sechdrs[i].sh_info = TO_NATIVE(sechdrs[i].sh_info);
388387 }
389388 /* Find symbol table. */
390389 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
754753 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
755754 if (sym->st_shndx != relsym->st_shndx)
756755 continue;
757− if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
758− continue;
759756 if (sym->st_value == addr)
760757 return sym;
761758 }
@@ -898,68 +895,6 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, · 136 unmodified lines
898895 }
899896 }
900897
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−
963898 /**
964899 * A module includes a number of sections that are discarded
965900 * 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
1003938 r.r_offset = TO_NATIVE(rela->r_offset);
1004939 #if KERNEL_ELFCLASS == ELFCLASS64
1005940 if (hdr->e_machine == EM_MIPS) {
1006− unsigned int r_typ;
1007941 r_sym = ELF64_MIPS_R_SYM(rela->r_info);
1008942 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);
1011943 } else {
1012944 r.r_info = TO_NATIVE(rela->r_info);
1013945 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
1040972 r.r_offset = TO_NATIVE(rel->r_offset);
1041973 #if KERNEL_ELFCLASS == ELFCLASS64
1042974 if (hdr->e_machine == EM_MIPS) {
1043− unsigned int r_typ;
1044975 r_sym = ELF64_MIPS_R_SYM(rel->r_info);
1045976 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);
1048977 } else {
1049978 r.r_info = TO_NATIVE(rel->r_info);
1050979 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
1054983 r_sym = ELF_R_SYM(r.r_info);
1055984 #endif
1056985 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− }
1065986 sym = elf->symtab_start + r_sym;
1066987 /* Skip special sections */
1067988 if (sym->st_shndx >= SHN_LORESERVE)
scripts/mod/modpost.h+0−3
@@ -60,9 +60,6 @@ typedef union · 59 unmodified lines
6060 #define ELF64_MIPS_R_SYM(i) \
6161 ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym)
6262
63−#define ELF64_MIPS_R_TYPE(i) \
64− ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type1)
65−
6663 #if KERNEL_ELFDATA != HOST_ELFDATA
6764
6865 static inline void __endian(const void *src, void *dest, unsigned int size)