bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/27566] [RISC-V] relocation truncated to fit: R_RISCV_GPREL_I aga


From: cvs-commit at gcc dot gnu.org
Subject: [Bug ld/27566] [RISC-V] relocation truncated to fit: R_RISCV_GPREL_I against aymbol
Date: Mon, 31 May 2021 03:29:42 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=27566

--- Comment #7 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot 
gnu.org> ---
The master branch has been updated by Nelson Chu <nelsonc1225@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ef9d25656226c46406293a70a81e564640973662

commit ef9d25656226c46406293a70a81e564640973662
Author: Nelson Chu <nelson.chu@sifive.com>
Date:   Wed May 12 08:26:33 2021 -0700

    RISC-V: PR27566, Do not relax when data segment phase is
exp_seg_relro_adjust.

    2021-05-31  Nelson Chu  <nelson.chu@sifive.com>
                Lifang Xia  <lifang_xia@c-sky.com>

    The data segment phase exp_seg_relro_adjust means we are still adjusting
the
    relro segments, so we will get the symbol values which havn't consider the
    relro.  It is dangerous and we shouldn't do the relaxations at this stage.
    Otherwise, we may get the truncated fails when the relax range crossing the
    data segment.

    One of the solution is that, we use a pointer to monitor the data segment
    phase while relaxing, to know whether the relro has been handled or not.
    Once we check the phase is exp_seg_relro_adjust, we should skip this round
    of relaxations, since the incorrect symbol values will affect the
correctness
    of relaxations.  I think we probably need to record more information about
    data segment or alignments in the future, to make sure it is safe to doing
    relaxations.

    For the two new testcases, relro-relax-lui and relro-relax-pcrel, we get
    the following truncated errors when using toolchains, which enable relro:

    (.text+0x0): relocation truncated to fit: R_RISCV_GPREL_I against symbol
`SymbolRodata' defined in .rodata section in test1.o

    After applying this patch, the truncated errors should be resolved.
    However, only linux toolchains support -z relro, so we only test these
    two testcases when supporting shared library.

    bfd/
        PR 27566
        * elfnn-riscv.c (struct riscv_elf_link_hash_table): New integer pointer
        to monitor the data segment phase.
        (bfd_elfNN_riscv_set_data_segment_info): New function called by
        after_allocation, to set the data_segment_phase from expld.dataseg.
        (_bfd_riscv_relax_section): Don't relax when data_segment_phase is
        exp_seg_relro_adjust (0x4).
        * elfxx-riscv.h (bfd_elf32_riscv_set_data_segment_info): New extern.
        (bfd_elf64_riscv_set_data_segment_info): Likewise.
    ld/
        PR 27566
        * emultempl/riscvelf.em (after_allocation): Call
        riscv_set_data_segment_info to set data segment phase before relaxing.
        * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
        * testsuite/ld-riscv-elf/relro-relax-lui.d: New testcase.
        * testsuite/ld-riscv-elf/relro-relax-lui.s: Likewise.
        * testsuite/ld-riscv-elf/relro-relax-pcrel.d: Likewise.
        * testsuite/ld-riscv-elf/relro-relax-pcrel.s: Likewise.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]