]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - bfd/elfnn-riscv.c
RISC-V: Add R_RISCV_DELETE, which marks bytes for deletion
authorPalmer Dabbelt <palmer@dabbelt.com>
Fri, 19 May 2017 01:08:25 +0000 (18:08 -0700)
committerPalmer Dabbelt <palmer@dabbelt.com>
Thu, 19 Oct 2017 16:19:32 +0000 (09:19 -0700)
commitff6f4d9b2d6c25ac144bab869df6e3d6123a6f8f
tree59e6a3f173dd8987b985d830a745f06e6b881f9d
parent95e42ad4425f0ab0ebfb90035a891be576f9fca4
RISC-V: Add R_RISCV_DELETE, which marks bytes for deletion

We currently delete bytes by shifting an entire BFD backwards to
overwrite the bytes we no longer need.  The result is that relaxing a
BFD is quadratic time.

This patch adds an additional relocation that specifies a byte range
that will be deleted from the final object file, and adds a relaxation
pass (between the existing passes that delete bytes and the alignment
pass) that actually deletes the bytes.  Note that deletion is still
quadratic time, and nothing uses R_RISCV_DELETE yet.

I've been meaning to go convert all the other relaxations to use
R_RISCV_DELETE and then make it faster, but this patch has been sitting
around for months so it looks like that won't happen for a bit.  The
PCREL->GPREL relaxation that comes next uses this, and since we've been
using these two patches out of tree since I wrote them months ago I
figure it's better to just get them in now.  I (or someone else :)) can
convert all the relocations later...

R_RISCV_DELETE will never be emitted into ELF objects, so therefor isn't
exposed to the rest of binutils.  As such, we're not considering this as
part of the ABI.

bfd/ChangeLog

2017-10-19  Palmer Dabbelt  <palmer@dabbelt.com>

        * elfnn-riscv (R_RISCV_DELETE): New define.
        (_bfd_riscv_relax_delete): New function.
        (perform_relocation): Handle R_RISCV_DELETE.
        (_bfd_riscv_relax_section): Likewise.

ld/ChangeLog

2017-10-19  Palmer Dabbelt  <palmer@dabbelt.com>

        * emultempl/riscvelf.em (riscv_elf_before_allocation): Add a
        third relaxation pass.
bfd/ChangeLog
bfd/elfnn-riscv.c
ld/ChangeLog
ld/emultempl/riscvelf.em