bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/24678] RISC-V pcrel relocs and abs global pointer variable


From: wilson at gcc dot gnu.org
Subject: [Bug ld/24678] RISC-V pcrel relocs and abs global pointer variable
Date: Fri, 14 Jun 2019 01:08:26 +0000

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

--- Comment #1 from Jim Wilson <wilson at gcc dot gnu.org> ---
The section for linker script defined variables is set in set_sym_sections, via
update_definedness, which uses section_for_dot.

Since we are computing the __global_pointer$ value near the end of the linker
script, after the last output section, and after an expression that sets dot,
it must be assigned to the next output section but there is no next output
section so it gets the default abs section.

Also, rel_from_abs needs to be set, which is only set if it explicitly uses
dot.

Moving the expression a little earlier in the linker script, and rewriting to
explicitly mention dot seems to work.  Completely untested patch that works for
a simple testcase, putting __global_pointer$ in the .bss section.

The change probably should have a comment to explain the details.

diff --git a/ld/emulparams/elf32lriscv-defs.sh
b/ld/emulparams/elf32lriscv-defs.sh
index 5ac3b6023d..dd1183bb53 100644
--- a/ld/emulparams/elf32lriscv-defs.sh
+++ b/ld/emulparams/elf32lriscv-defs.sh
@@ -43,6 +43,6 @@
INITIAL_READONLY_SECTIONS="${RELOCATING+${CREATE_SHLIB-${INITIAL_READONLY_SECTIO
 # the program as possible.  But we can't allow gp to cover any of rodata, as
 # the address of variables in rodata may change during relaxation, so we start
 # from data in that case.
-OTHER_END_SYMBOLS="${CREATE_SHLIB-__BSS_END__ = .;
+OTHER_BSS_END_SYMBOLS="${CREATE_SHLIB-__BSS_END__ = .;
     __global_pointer$ = MIN(__SDATA_BEGIN__ + 0x800,
-                           MAX(__DATA_BEGIN__ + 0x800, __BSS_END__ -
0x800));}"
+                           MAX(__DATA_BEGIN__ + 0x800, . - 0x800));}"

-- 
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]