From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark Mitchell To: binutils@sourceware.cygnus.com Subject: PATCH for GOT16 handling Date: Mon, 09 Aug 1999 15:48:00 -0000 Message-id: <19990809155231M.mitchell@codesourcery.com> X-SW-Source: 1999-08/msg00069.html Ralf and I jointly discovered that elf32-mips.c has historically lied about the source mask for GOT16/CALL16 entries. Since the new code cares, that was causing problems. Fixed here. Also fixed is a problem with looking for matching GOT16 entries in the GOT. Coming soon is a patch for the creation of dynamic relocations. It looks like the old code got the cases used in the N32 ABI wrong, while the new code gets the old cases wrong. Ian and I have hashed out the right solution; I will implement it. Ian, did you get a chance to review the elflink.h patch I sent in about a week ago? It was designed to avoid wasting relocation entries in the case that both REL and RELA relocations appear for a single section. -- Mark Mitchell mark@codesourcery.com CodeSourcery, LLC http://www.codesourcery.com 1999-08-09 Mark Mitchell * elf32-mips.c (elf_mips_howto_table): Fix src_mask for R_MIPS_GOT16 and R_MIPS_CALL16. (mips_elf_got16_entry): Use mips_elf_high to calculate the value to use wheen looking for a preexisting GOT entry. Index: elf32-mips.c =================================================================== RCS file: /cvs/binutils/binutils/bfd/elf32-mips.c,v retrieving revision 1.45 diff -c -p -r1.45 elf32-mips.c *** elf32-mips.c 1999/08/06 02:44:41 1.45 --- elf32-mips.c 1999/08/09 22:41:09 *************** static reloc_howto_type elf_mips_howto_t *** 602,608 **** _bfd_mips_elf_got16_reloc, /* special_function */ "R_MIPS_GOT16", /* name */ false, /* partial_inplace */ ! 0, /* src_mask */ 0xffff, /* dst_mask */ false), /* pcrel_offset */ --- 602,608 ---- _bfd_mips_elf_got16_reloc, /* special_function */ "R_MIPS_GOT16", /* name */ false, /* partial_inplace */ ! 0xffff, /* src_mask */ 0xffff, /* dst_mask */ false), /* pcrel_offset */ *************** static reloc_howto_type elf_mips_howto_t *** 632,638 **** bfd_elf_generic_reloc, /* special_function */ "R_MIPS_CALL16", /* name */ false, /* partial_inplace */ ! 0, /* src_mask */ 0xffff, /* dst_mask */ false), /* pcrel_offset */ --- 632,638 ---- bfd_elf_generic_reloc, /* special_function */ "R_MIPS_CALL16", /* name */ false, /* partial_inplace */ ! 0xffff, /* src_mask */ 0xffff, /* dst_mask */ false), /* pcrel_offset */ *************** mips_elf_got16_entry (abfd, info, value) *** 5537,5543 **** bfd_vma index; bfd_vma address; ! value &= 0xffff0000; g = mips_elf_got_info (elf_hash_table (info)->dynobj, &sgot); /* Look to see if we already have an appropriate entry. */ --- 5537,5547 ---- bfd_vma index; bfd_vma address; ! /* Although the ABI says that it is "the high-order 16 bits" that we ! want, it is really the %high value. The complete value is ! calculated with a `addiu' of a LO16 relocation, just as with a ! HI16/LO16 pair. */ ! value = mips_elf_high (value); g = mips_elf_got_info (elf_hash_table (info)->dynobj, &sgot); /* Look to see if we already have an appropriate entry. */