This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Need help with DISP32/R_PCRLONG reloc howto problem


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]