This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Fix range check for HI20/LO12/RVC_LUI relocations
ClosedPublic

Authored by PkmX on Apr 8 2019, 11:08 AM.

Details

Summary

The code previously specified a 32-bit range for R_RISCV_HI20 and R_RISCV_LO12_[IS], however this is incorrect as the maximum offset on RV64 that can be formed from the immediate of lui and the displacement of an I-type or S-type instruction is -0x80000800 to 0x7ffff7ff. There is also the same issue with a c.lui and LO12 pair, whose actual addressable range should be -0x20800 to 0x1f7ff.

The tests will be included in the next patch that converts all RISC-V tests to use llvm-mc instead of yaml2obj, as assembler support has matured enough to write tests in them.

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

PkmX created this revision.Apr 8 2019, 11:08 AM
ruiu accepted this revision.Apr 8 2019, 9:55 PM

LGTM

This revision is now accepted and ready to land.Apr 8 2019, 9:55 PM
This revision was automatically updated to reflect the committed changes.