diff options
author | Jim Wilson <jimw@sifive.com> | 2019-08-01 16:40:15 -0700 |
---|---|---|
committer | Jim Wilson <jimw@sifive.com> | 2019-08-01 16:40:15 -0700 |
commit | 0f52d45acd6c54aa47082778ffcbafddd423a5b4 (patch) | |
tree | 17c5756dd4bd6a5f6a84f7124d221be02abc0a1c /bfd/elfnn-riscv.c | |
parent | 0eba165a74cdb039a5e6ed86e0396d80f68ca22c (diff) | |
download | fsf-binutils-gdb-0f52d45acd6c54aa47082778ffcbafddd423a5b4.zip fsf-binutils-gdb-0f52d45acd6c54aa47082778ffcbafddd423a5b4.tar.gz fsf-binutils-gdb-0f52d45acd6c54aa47082778ffcbafddd423a5b4.tar.bz2 |
RISC-V: Fix lui relax failure with relro.
bfd/ChangeLog
Ilia Diachkov <ilia.diachkov@optimitech.com>
* elfnn-riscv.c (_bfd_riscv_relax_lui): Set lui relax safety area to
two pages in relro presence.
Diffstat (limited to 'bfd/elfnn-riscv.c')
-rw-r--r-- | bfd/elfnn-riscv.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index 003b4f8..706dcb9 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -3562,11 +3562,16 @@ _bfd_riscv_relax_lui (bfd *abfd, } /* Can we relax LUI to C.LUI? Alignment might move the section forward; - account for this assuming page alignment at worst. */ + account for this assuming page alignment at worst. In the presence of + RELRO segment the linker aligns it by one page size, therefore sections + after the segment can be moved more than one page. */ + if (use_rvc && ELFNN_R_TYPE (rel->r_info) == R_RISCV_HI20 && VALID_RVC_LUI_IMM (RISCV_CONST_HIGH_PART (symval)) - && VALID_RVC_LUI_IMM (RISCV_CONST_HIGH_PART (symval + ELF_MAXPAGESIZE))) + && VALID_RVC_LUI_IMM (RISCV_CONST_HIGH_PART (symval) + + (link_info->relro ? 2 * ELF_MAXPAGESIZE + : ELF_MAXPAGESIZE))) { /* Replace LUI with C.LUI if legal (i.e., rd != x0 and rd != x2/sp). */ bfd_vma lui = bfd_get_32 (abfd, contents + rel->r_offset); |