Page MenuHomePhabricator

[RISCV] Don't evaluatePCRelLo if a relocation will be forced (e.g. due to linker relaxation)
ClosedPublic

Authored by asb on Mar 22 2019, 3:27 AM.

Details

Summary

A pcrel_lo will point to the associated pcrel_hi fixup which in turn points to the real target. RISCVMCExpr::evaluatePCRelLo will work around this indirection in order to allow the fixup to be evaluate properly. However, if relocations are forced (e.g. due to linker relaxation is enabled) then its evaluation is undesired and will result in a relocation with the wrong target.

This patch modifies evaluatePCRelLo so it will not try to evaluate if the fixup will be forced as a relocation. A new helper method is added to RISCVAsmBackend to query this.

Diff Detail

Repository
rL LLVM

Event Timeline

asb created this revision.Mar 22 2019, 3:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 22 2019, 3:27 AM

Could you add a case in option-relax.s after .option norelax to indicate the relocation type for local symbol will leave once the relaxation has been enabled?

Thanks for fixing this issue, Alex. Looking forward to seeing this merged!

asb updated this revision to Diff 192899.Mar 29 2019, 1:34 PM

Thanks for the review @shiva0217 - how is this?

shiva0217 accepted this revision.Mar 31 2019, 7:18 PM

Thanks for the update, LGTM.

This revision is now accepted and ready to land.Mar 31 2019, 7:18 PM
This revision was automatically updated to reflect the committed changes.