[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/29803] New: Relax failed between different output section
From: |
lifang_xia at linux dot alibaba.com |
Subject: |
[Bug ld/29803] New: Relax failed between different output section |
Date: |
Fri, 18 Nov 2022 03:38:17 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=29803
Bug ID: 29803
Summary: Relax failed between different output section
Product: binutils
Version: 2.40 (HEAD)
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: lifang_xia at linux dot alibaba.com
Target Milestone: ---
Hi all,
I have met a problem in risc-v relaxation. But I think it would be generic bug,
not only in risc-v.
Here is a case for riscv:
```
section .text.main
.global main
main:
call foo
call foo
call foo
call foo
call foo
call foo
call foo
.size main, . - main
.section .text.foo
.global foo
foo:
.option norvc
.rept 504
nop
.endr
call bar
.option rvc
ret
.size foo, . - foo
.section .bar.text
.global bar
bar:
ret
.size bar, . - bar
```
build with as:
```
./gas/as-new -o 1.o 1.s -march=rv32gc -mabi=ilp32d -mrelax
```
link file:
```
MEMORY
{
RAM1 : ORIGIN = 0x0, LENGTH = 0x1000
RAM2 : ORIGIN = 0x1000, LENGTH = 0x400
}
SECTIONS
{
.text :
{
*(.text)
*(.text.*)
} > RAM1
.bar.text :
{
*(.bar.text)
} > RAM2
}
```
link command:
```
./ld/ld-new -o 1 1.o -T1.ld -m elf32lriscv
```
It will get an error:
(.text.foo+0x7e0): relocation truncated to fit: R_RISCV_RVC_JUMP against symbol
`bar' defined in .bar.text section in 1.o
Because of the .foo.text's output_offset(base address) doest not update after
the relaxtion in main in time. (ldlang.c -> lang_size_sections_1 -> case
lang_input_section_enum)
```
case lang_input_section_enum:
{
asection *i;
i = s->input_section.section;
if (relax)
{
bool again;
if (!bfd_relax_section (i->owner, i, &link_info, &again))
einfo (_("%F%P: can't relax section: %E\n"));
if (again)
*relax = true;
}
dot = size_input_section (prev, output_section_statement,
fill, &removed, dot);
}
break;
```
the size_input_section only update the size of current input section. But it
doest not update the next input section's offset(base address).
How about add lang_size_sections_1 after bfd_relax_section?
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/29803] New: Relax failed between different output section,
lifang_xia at linux dot alibaba.com <=