This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[patch] readelf: Incorrect interpretation of MIPS64 relocations
- From: "Maciej W. Rozycki" <macro at linux-mips dot org>
- To: binutils at sources dot redhat dot com
- Date: Mon, 4 Apr 2005 15:42:26 +0100 (BST)
- Subject: [patch] readelf: Incorrect interpretation of MIPS64 relocations
Hello,
When parsing DWARF2 information readelf interprets MIPS64 symbol indices
incorrectly. "Skipping unexpected symbol type" messages result. MIPS64
relocations are laid out a bit unusually, due to the need to encode three
relocation types in a single entry. We have suitable code to deal with it
when dumping relocations in dump_relocations(), but it's missing from
debug_apply_rela_addends() which is used for DWARF2 processing.
The following patch fixes the problem for me.
2005-04-04 Maciej W. Rozycki <macro@linux-mips.org>
* readelf.c (debug_apply_rela_addends): Reorder r_info as
necessary for 64-bit MIPS.
OK to apply?
Maciej
binutils-2.15.96-20050331-mips64-readelf-r_info.patch
diff -up --recursive --new-file binutils-2.15.96-20050331.macro/binutils/readelf.c binutils-2.15.96-20050331/binutils/readelf.c
--- binutils-2.15.96-20050331.macro/binutils/readelf.c 2005-03-21 04:25:10.000000000 +0000
+++ binutils-2.15.96-20050331/binutils/readelf.c 2005-04-02 16:54:47.000000000 +0000
@@ -7329,6 +7329,18 @@ debug_apply_rela_addends (FILE *file,
}
else
{
+ /* In MIPS little-endian objects, r_info isn't really a
+ 64-bit little-endian value: it has a 32-bit little-endian
+ symbol index followed by four individual byte fields.
+ Reorder INFO accordingly. */
+ if (elf_header.e_machine == EM_MIPS
+ && elf_header.e_ident[EI_DATA] != ELFDATA2MSB)
+ rp->r_info = (((rp->r_info & 0xffffffff) << 32)
+ | ((rp->r_info >> 56) & 0xff)
+ | ((rp->r_info >> 40) & 0xff00)
+ | ((rp->r_info >> 24) & 0xff0000)
+ | ((rp->r_info >> 8) & 0xff000000));
+
sym = symtab + ELF64_R_SYM (rp->r_info);
if (ELF64_R_SYM (rp->r_info) != 0