[mips] Support 64-bit relative relocations
authorSimon Atanasyan <simon@atanasyan.com>
Fri, 24 Apr 2020 12:41:13 +0000 (15:41 +0300)
committerSimon Atanasyan <simon@atanasyan.com>
Tue, 2 Jun 2020 08:44:11 +0000 (11:44 +0300)
commitb00f0d4238cb34a54073cc5ab7e2060d58f69e3f
treee8a6000948471a6b1205b7e8f56456290b91adea
parent44f989e7809633f13bd0420cc1d79660ad982173
[mips] Support 64-bit relative relocations

MIPS 64-bit ABI does not provide special PC-relative relocation like
R_MIPS_PC32 in 32-bit case. But we can use a "chain of relocation"
defined by N64 ABIs. In that case one relocation record might contain up
to three relocations which applied sequentially. Width of a final relocation
mask applied to the result of relocation depends on the last relocation
in the chain. In case of 64-bit PC-relative relocation we need the following
chain: `R_MIPS_PC32 | R_MIPS_64`. The first relocation calculates an
offset, but does not truncate the result. The second relocation just
apply calculated result as a 64-bit value.

The 64-bit PC-relative relocation might be useful in generation of
`.eh_frame` sections to escape passing `-Wl,-z,notext` flags to linker.

Differential Revision: https://reviews.llvm.org/D80390
lld/test/ELF/mips-pc64.s [new file with mode: 0644]
llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
llvm/test/MC/Mips/relocation-n64.s
llvm/test/MC/Mips/unsupported-relocation.s