Need help with DISP32/R_PCRLONG reloc howto problem

Aaron W. LaFramboise aaron98wiridge9@aaronwl.com
Fri Jul 2 11:17:00 GMT 2004


I'm trying to fix an apparent relation error at link time on i386 PE
COFF from a small testcase.

gas assembles a call instruction whose operand is a weak symbol within
the same section.  It generates the normal four byte address PC-relative
instruction, and fills in the address with the displacement to the
target symbol.  It also generates a R_PCRLONG reloc, since the symbol
may be overriden.  So far so good.

Now binutils ld links the object.  It applies the reloc, which has a
src_mask 0xffffff specified in the HOWTO.  This seems to cause the reloc
performer to read, from the section, the displacement previously set by
as.  It then bitwise and's it with src_mask, which is the identity.
Then it adds this to the reloc displacement that ld itself has
calculated, which ends up with a result of the displacement * 2, which
it writes back to the section.  This is, of course, not at all right.

If GAS just left the call displacement as zeroes, this wouldn't be a
problem.  Or, if src_mask in the howto were zero, this also wouldn't be
a problem.  However, I looked at ELF's R_386_PC32 on Linux, and it does
exactly the same thing with weak symbols, but it doesn't have this problem.

Can someone suggest how I might fix this?  I have no idea where to go
from here because I'm not really sure how this is supposed to work. :(

Aaron W. LaFramboise



More information about the Binutils mailing list