RISC-V: Support GOT_HI20/CALL_PLT relocation type in kernel module
authorZong Li <zong@andestech.com>
Thu, 15 Mar 2018 08:50:43 +0000 (16:50 +0800)
committerPalmer Dabbelt <palmer@sifive.com>
Tue, 3 Apr 2018 03:00:54 +0000 (20:00 -0700)
commitda975dd4818cf42a181910789c096eb6997ed663
treeeb538022010facb754f433de628a6b66bc954c4a
parentb8bde0ef12bd43f013d879973a1900930bfb95ee
RISC-V: Support GOT_HI20/CALL_PLT relocation type in kernel module

For CALL_PLT, emit the plt entry only when offset is more than 32-bit.

For PCREL_LO12, it uses the location of corresponding HI20 to
get the address of external symbol. It should check the HI20 type
is the PCREL_HI20 or GOT_HI20, because sometime the location will
have two or more relocation types.
For example:
0:   00000797                auipc   a5,0x0
                     0: R_RISCV_ALIGN        *ABS*
                     0: R_RISCV_GOT_HI20     SYMBOL
4:   0007b783                ld      a5,0(a5) # 0 <SYMBOL>
                     4: R_RISCV_PCREL_LO12_I .L0
                     4: R_RISCV_RELAX        *ABS*

Signed-off-by: Zong Li <zong@andestech.com>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
arch/riscv/kernel/module.c