This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Properly check that R_X86_64_PC32 and R_X86_64_32 relocations are disallowed in DSO.
ClosedPublic

Authored by grimar on Jun 9 2016, 7:55 AM.

Details

Summary

getDynRel() contains the next code:

uint32_t X86_64TargetInfo::getDynRel(uint32_t Type) const {
  if (Config->Shared && (Type == R_X86_64_PC32 || Type == R_X86_64_32))
    error(getRelName(Type) + " cannot be a dynamic relocation");
  return Type;
}

where error was never thown/catched previously when running testcases because adjustExpr() method
consumed that error check. adjustExpr() errors out if dynamic relocations happens against the readonly segment.

I think initially we wanted to check that these two relocations are not present when linking DSO because of
possible overflow in runtime. Patch moves them to writable segment in testcases to allow
error check above to trigger.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar updated this revision to Diff 60178.Jun 9 2016, 7:55 AM
grimar retitled this revision from to [ELF] - Properly check that R_X86_64_PC32 and R_X86_64_32 relocations are disallowed in DSO..
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar.
rafael accepted this revision.Jun 9 2016, 1:23 PM
rafael edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Jun 9 2016, 1:23 PM
This revision was automatically updated to reflect the committed changes.