Puzzle:Is addend ok when handling relocations in linking mips32-elf

Amker.Cheng amker.cheng@gmail.com
Mon Mar 9 11:11:00 GMT 2009

Hi All:
  I'm studying mips-elf relocation process in gnu ld and puzzled about
following codes.

In mips-elf relocation function for ld which is
the addend is calculated some kind like:

STEP 1 :       addend = mips_elf_obtain_contents (howto, rel, input_bfd,
STEP 2 :       addend &= howto->src_mask;
STEP 3 :       addend <<= howto->rightshift;
STEP 4 :       mips_elf_calculate_relocation (output_bfd, input_bfd,
					     input_section, info, rel,
					     addend, howto, local_syms,
					     local_sections, &value,
					     &name, &require_jalx,

It seems that above code doesn't take howto->bitpos into consider.
For now most howto structs in elf32-mips.c set howto->bitpos to 0,
I searched source codes and found that R_MIPS_SHIFT5 and R_MIPS_SHIFT6
are not used currently.

here comes the problem, If i have a howto structure with nonzero bitpos,
I think addend will be wrong and should be right shift with howto->bitpos.

Right or I just missed something important?
Thanks and any tips will be appreciated.


More information about the Binutils mailing list