[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: |
address@hidden |
Subject: |
[Bug ld/27566] [RISC-V] relocation truncated to fit: R_RISCV_GPREL_I against aymbol |
Date: |
Mon, 15 Mar 2021 14:51:39 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=27566
--- Comment #3 from lifang_xia@c-sky.com ---
Hi Nelson,
I agree with you, the previous patch is not a best choice.
I have do some debug today.
I add a print here:
===========================================
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 364d67b..e774cff 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -4247,14 +4247,23 @@ _bfd_riscv_relax_lui (bfd *abfd,
max_alignment = (bfd_vma) 1 <<
sym_sec->output_section->alignment_power;
}
+ printf ("gp: %lx, sym val: %lx\n", gp, symval);
/* Is the reference in range of x0 or gp?
Valid gp range conservatively because of alignment issue. */
if (undefined_weak
|| (VALID_ITYPE_IMM (symval)
|| (symval >= gp
==============================================
And I got a result:
-----------------------------------------------
xialf@magics:build-linux$ ./ld/ld-new -o a a.o -e main -z norelro
gp: 11d90, sym val: 11c10
gp: 11d90, sym val: 11c10
xialf@magics:build-linux$ readelf -s a |grep global
5: 0000000000011d90 0 NOTYPE GLOBAL DEFAULT ABS __global_pointer$
-----------------------------------------------
>From this, GP is not changed, that means DATA_SEGMENT_ALIGN has been finished
while relaxing.Therefore we can just consider about COMMON_PAGESIZE, not
MAX_PAGESIZE+COMMON_PAGESIZE.
=====================================================
For -z relro
xialf@magics:build-linux$ ./ld/ld-new -o a a.o -e main -z relro
gp: 12800, sym val: 11c10
gp: 12800, sym val: 11c10
gp: 11d90, sym val: 11c10
gp: 11d90, sym val: 11c10
xialf@magics:build-linux$ readelf -s a |grep global
5: 0000000000012800 0 NOTYPE GLOBAL DEFAULT ABS __global_pointer$
=======================================================
DATA_SEGMENT_RELRO_END has been aligned to 0x12000, and gp is 0x12800.
=======================================================
common-page-size=0x4000
xialf@magics:build-linux$ ./ld/ld-new -o a a.o -e main -z
common-page-size=0x4000 -z relro
gp: 14800, sym val: 11c10
gp: 14800, sym val: 11c10
gp: 11d90, sym val: 11c10
gp: 11d90, sym val: 11c10
xialf@magics:build-linux$ readelf -s a |grep global
5: 0000000000014800 0 NOTYPE GLOBAL DEFAULT ABS __global_pointer$
========================================================
DATA_SEGMENT_RELRO_END has been aligned to 0x14000, gp is 0x14800.
It is not check the imm with (MAX_PAGESIZE + COMMON_PAGE_SIZE) or
(COMMON_PAGESIZE); It need to align to COMMON_PAGE_SIZE.
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/27566] New: [RISC-V] relocation truncated to fit: R_RISCV_GPREL_I against aymbol, address@hidden, 2021/03/11
- [Bug ld/27566] [RISC-V] relocation truncated to fit: R_RISCV_GPREL_I against aymbol, nelsonc1225 at sourceware dot org, 2021/03/12
- [Bug ld/27566] [RISC-V] relocation truncated to fit: R_RISCV_GPREL_I against aymbol, nelsonc1225 at sourceware dot org, 2021/03/12
- [Bug ld/27566] [RISC-V] relocation truncated to fit: R_RISCV_GPREL_I against aymbol,
address@hidden <=
- [Bug ld/27566] [RISC-V] relocation truncated to fit: R_RISCV_GPREL_I against aymbol, address@hidden, 2021/03/15
- [Bug ld/27566] [RISC-V] relocation truncated to fit: R_RISCV_GPREL_I against aymbol, wilson at gcc dot gnu.org, 2021/03/17
- [Bug ld/27566] [RISC-V] relocation truncated to fit: R_RISCV_GPREL_I against aymbol, nelsonc1225 at sourceware dot org, 2021/03/26