[RISCV] Fix range check for HI20/LO12/RVC_LUI relocations
authorChih-Mao Chen <pkmx.tw@gmail.com>
Tue, 9 Apr 2019 11:39:23 +0000 (11:39 +0000)
committerChih-Mao Chen <pkmx.tw@gmail.com>
Tue, 9 Apr 2019 11:39:23 +0000 (11:39 +0000)
commit949570ce39da590c59fecb4cd24501351aaa64fb
tree158f41131501001a75f888943bdbd9f33ea9592c
parent965c5812f43809826772a31b613ba56894e47627
[RISCV] Fix range check for HI20/LO12/RVC_LUI relocations

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.

Differential Revision: https://reviews.llvm.org/D60414

llvm-svn: 357995
lld/ELF/Arch/RISCV.cpp