https://sourceware.org/bugzilla/show_bug.cgi?id=31220
Bug ID: 31220 Summary: [RISC-V] Fix relaxation of calls to addresses above 0xFFFF800 Product: binutils Version: 2.42 (HEAD) Status: UNCONFIRMED Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: davidegrayson at gmail dot com Target Milestone: --- Created attachment 15288 --> https://sourceware.org/bugzilla/attachment.cgi?id=15288&action=edit Patch that fixes the bug I want to put a ROM in the top 2 KiB of the address space on a 32-bit RISC-V system, since calls to that region can be implemented with a single JAL instruction. However, I noticed that the GNU linker was failing to implement that relaxation. The small attached patch fixes the problem. In case anyone wants to reproduce the issue, use this linker script and assembly file: ---- MEMORY { ROM : ORIGIN = 0x10000000, LENGTH = 64K } SECTIONS { .text : { *(.text) } >ROM } abs_func1 = 0x7FC; abs_func2 = 0xFFFFF800; ----- .text .global start start: call abs_func1 call2: call abs_func2 ----- Then run these commands: riscv64-unknown-elf-as -march=rv32i -mabi=ilp32 test.s -o test.o riscv64-unknown-elf-ld --relax -m elf32lriscv -T test.ld test.o -o test.elf riscv64-unknown-elf-objdump -d test.elf Observe that the second call is implemented with an "AUIPC" and "JALR" instruction instead of a single "JALR" instruction, like the first one. Please let me know if you want any more info or changes. Thanks! -- You are receiving this mail because: You are on the CC list for the bug.