]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - bfd/ChangeLog
RISC-V: Support PCREL_* relocations agaist weak undefined symbols
authorPalmer Dabbelt <palmer@dabbelt.com>
Wed, 16 Aug 2017 17:41:56 +0000 (10:41 -0700)
committerPalmer Dabbelt <palmer@dabbelt.com>
Thu, 7 Sep 2017 16:42:15 +0000 (09:42 -0700)
commitb1308d2c3749cc454f00b70768ee33724d919527
treecf051908c28994feb29b449bee2786c84eff14bd
parente50142270b699c4960e56824a0300865589dc292
RISC-V: Support PCREL_* relocations agaist weak undefined symbols

I recently modified our Linux port's base address such the absolute
address 0 is no longer addressable as a 32-bit PC-relative offset.
Since Linux links a weak undefined symbol in an intermediate binary, it
needs to be able to reference absolute address 0.

This patch changes R_RISCV_PCREL_* relocations to absolute relocations
while resolving them in order to allow these symbols to be referenced in
PC-relative programs linked at high addresses.  Note that this doesn't
apply to PIC, which also uses PC-relative relocations, just to
position-dependent objects, which we use to allow programs to be linked
at high addresses.

In case some of our embedded users are using R_RISCV_PCREL_* as a hacked
up method of getting position-independent binaries (which can work if
you have very simple programs), we only convert the relocations when the
PC-relative version would overflow.

bfd/ChangeLog:

2017-09-07  Palmer Dabbelt  <palmer@dabbelt.com>

        * elfnn-riscv.c (riscv_zero_pcrel_hi_reloc): New function.
        (riscv_record_pcrel_hi_reloc): Add absolute argument.
        (riscv_elf_relocate_section): Call riscv_zero_pcrel_hi_reloc for
        R_RISCV_PCREL_HI20 relocs, and pass the result to
        riscv_record_pcrel_hi_reloc.
bfd/ChangeLog
bfd/elfnn-riscv.c