From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Henderson To: binutils@sourceware.cygnus.com Subject: elf32-mips howto table Date: Thu, 29 Jul 1999 14:41:00 -0000 Message-id: <19990729144025.A1075@cygnus.com> X-SW-Source: 1999-07/msg00041.html The howto lookup in relocate section is incorrect. The howto entries aren't all in a flat table. r~ * elf32-mips.c (mips_info_to_howto_rel): Split out switch to ... (mips_rtype_to_howto): ... new function. (_bfd_mips_elf_relocate_section): Use it. Index: elf32-mips.c =================================================================== RCS file: /cvs/binutils/binutils/bfd/elf32-mips.c,v retrieving revision 1.34 diff -c -p -d -r1.34 elf32-mips.c *** elf32-mips.c 1999/07/28 08:19:34 1.34 --- elf32-mips.c 1999/07/29 21:28:38 *************** static bfd_reloc_status_type mips32_64bi *** 98,103 **** --- 98,105 ---- PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_code_real_type)); + static reloc_howto_type *mips_rtype_to_howto + PARAMS ((unsigned int)); static void mips_info_to_howto_rel PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *)); static void mips_info_to_howto_rela *************** bfd_elf32_bfd_reloc_type_lookup (abfd, c *** 1890,1925 **** /* Given a MIPS Elf32_Internal_Rel, fill in an arelent structure. */ ! static void ! mips_info_to_howto_rel (abfd, cache_ptr, dst) ! bfd *abfd; ! arelent *cache_ptr; ! Elf32_Internal_Rel *dst; { - unsigned int r_type; - - r_type = ELF32_R_TYPE (dst->r_info); switch (r_type) { case R_MIPS16_26: ! cache_ptr->howto = &elf_mips16_jump_howto; break; case R_MIPS16_GPREL: ! cache_ptr->howto = &elf_mips16_gprel_howto; break; case R_MIPS_GNU_VTINHERIT: ! cache_ptr->howto = &elf_mips_gnu_vtinherit_howto; break; case R_MIPS_GNU_VTENTRY: ! cache_ptr->howto = &elf_mips_gnu_vtentry_howto; break; default: BFD_ASSERT (r_type < (unsigned int) R_MIPS_max); ! cache_ptr->howto = &elf_mips_howto_table[r_type]; break; } /* The addend for a GPREL16 or LITERAL relocation comes from the GP value for the object file. We get the addend now, rather than when we do the relocation, because the symbol manipulations done --- 1892,1936 ---- /* Given a MIPS Elf32_Internal_Rel, fill in an arelent structure. */ ! static reloc_howto_type * ! mips_rtype_to_howto (r_type) ! unsigned int r_type; { switch (r_type) { case R_MIPS16_26: ! return &elf_mips16_jump_howto; break; case R_MIPS16_GPREL: ! return &elf_mips16_gprel_howto; break; case R_MIPS_GNU_VTINHERIT: ! return &elf_mips_gnu_vtinherit_howto; break; case R_MIPS_GNU_VTENTRY: ! return &elf_mips_gnu_vtentry_howto; break; default: BFD_ASSERT (r_type < (unsigned int) R_MIPS_max); ! return &elf_mips_howto_table[r_type]; break; } + } + + /* Given a MIPS Elf32_Internal_Rel, fill in an arelent structure. */ + static void + mips_info_to_howto_rel (abfd, cache_ptr, dst) + bfd *abfd; + arelent *cache_ptr; + Elf32_Internal_Rel *dst; + { + unsigned int r_type; + + r_type = ELF32_R_TYPE (dst->r_info); + cache_ptr->howto = mips_rtype_to_howto (r_type); + /* The addend for a GPREL16 or LITERAL relocation comes from the GP value for the object file. We get the addend now, rather than when we do the relocation, because the symbol manipulations done *************** _bfd_mips_elf_relocate_section (output_b *** 6461,6467 **** stored value is sign-extended to 64 bits. */ howto = elf_mips_howto_table + R_MIPS_32; else ! howto = elf_mips_howto_table + r_type; if (!use_saved_addend_p) { --- 6472,6478 ---- stored value is sign-extended to 64 bits. */ howto = elf_mips_howto_table + R_MIPS_32; else ! howto = mips_rtype_to_howto (r_type); if (!use_saved_addend_p) {