diff options
author | Nelson Chu <nelson@rivosinc.com> | 2023-05-12 17:15:58 +0800 |
---|---|---|
committer | Nelson Chu <nelson@rivosinc.com> | 2024-12-06 11:36:53 +0800 |
commit | 6f8e75592ceb1e667fb50e466734caf6d11203ac (patch) | |
tree | 08bfd6edf76068c2fe4002f04cffc283ec0e76d4 /ld | |
parent | 9d09e3919293185225638a7f29e4028b30f9e317 (diff) | |
download | gdb-6f8e75592ceb1e667fb50e466734caf6d11203ac.zip gdb-6f8e75592ceb1e667fb50e466734caf6d11203ac.tar.gz gdb-6f8e75592ceb1e667fb50e466734caf6d11203ac.tar.bz2 |
RISC-V: PR27566, consider ELF_MAXPAGESIZE/COMMONPAGESIZE for gp relaxations.
For default linker script, if a symbol's value outsides the bounds of the
defined section, then it may cross the data segment alignment, so we should
reserve more size about MAXPAGESIZE and COMMONPAGESIZE when doing gp
relaxations. Otherwise we may meet the truncated errors since the data
segment alignment might move the section forward.
bfd/
PR 27566
* elfnn-riscv.c (_bfd_riscv_relax_lui): Consider MAXPAGESIZE and
COMMONPAGESIZE if the symbol's value outsides the bounds of the
defined section.
(_bfd_riscv_relax_pc): Likewise.
ld/
PR 27566
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
* testsuite/ld-riscv-elf/relax-data-segment-align*: New testcase
for pr27566. Without this patch, the rv32 binutils will meet
truncated errors for this testcase.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-riscv-elf/relax-data-segment-align.d | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-riscv-elf/relax-data-segment-align.s | 16 |
3 files changed, 25 insertions, 0 deletions
diff --git a/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp b/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp index 7b1b2aa..5270add 100644 --- a/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp +++ b/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp @@ -167,6 +167,7 @@ if [istarget "riscv*-*-*"] { run_dump_test "attr-merge-stack-align-failed" run_dump_test "attr-phdr" run_dump_test "relax-max-align-gp" + run_dump_test "relax-data-segment-align" run_dump_test "uleb128" run_dump_test "pr31179" run_dump_test "pr31179-r" diff --git a/ld/testsuite/ld-riscv-elf/relax-data-segment-align.d b/ld/testsuite/ld-riscv-elf/relax-data-segment-align.d new file mode 100644 index 0000000..22aeb4c --- /dev/null +++ b/ld/testsuite/ld-riscv-elf/relax-data-segment-align.d @@ -0,0 +1,8 @@ +#source: relax-data-segment-align.s +#ld: +#objdump: -d + +#failif +#... +.*gp.* +#... diff --git a/ld/testsuite/ld-riscv-elf/relax-data-segment-align.s b/ld/testsuite/ld-riscv-elf/relax-data-segment-align.s new file mode 100644 index 0000000..9871892 --- /dev/null +++ b/ld/testsuite/ld-riscv-elf/relax-data-segment-align.s @@ -0,0 +1,16 @@ + .text + .globl _start +_start: + .rept 6000 + lla a0, symbol + .endr + + .section .rodata + .set symbol, . + 4598 + .fill 100, 4, 1 + + .data + .align 3 + .rept 860 + .long 0x1000 + .endr |