This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Change i386 i386-pc8.s/i386-pc16.test to work with 8/16 bits values accordingly.
ClosedPublic

Authored by grimar on Jan 30 2017, 2:25 AM.

Details

Summary

It was requested by Rui to change these tests, because they fail after changing implementation of relocateOne to next:

void X86TargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,
                                uint64_t Val) const {
...
  switch (Type) {
  case R_386_8:
  case R_386_PC8:
    checkInt<8>(Loc, Val, Type);
    *Loc = Val;
    break;
  case R_386_16:
  case R_386_PC16:
    checkInt<16>(Loc, Val, Type);
    write16le(Loc, Val);
    break;
...
}

Though ABI says "The R_386_16, and R_386_8 relocations truncate the computed value to 16-bits and 8-bits respectively".
ld.bfd errors on such inputs, ld.gold accepts them.

And because of using word "truncate" it is not clear for me what behavior is correct. Seems LLD and gold just follows ABI and
bfd performs additional checks. I have no arguments for doing or not doing that change.

Diff Detail

Event Timeline

grimar created this revision.Jan 30 2017, 2:25 AM
This revision was automatically updated to reflect the committed changes.
ruiu edited edge metadata.Jan 31 2017, 12:38 PM

LGTM. Thank you for doing this.