1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

riscv_common: explicitly mark handle_trap as used

The handle_trap function is used internally by the trap_entry
implementation from the same file. However, the trap_entry
implementation calls handle_trap from inline assembly. This makes it
difficult for the compiler to infer that the handle_trap function is
used at all. This causes issues when LTO is enabled.

Without this patch compiling any RISC-V RIOT code with `LTO=1` causes
the following linker error:

	/home/soeren/src/RIOT/cpu/riscv_common/irq_arch.c:134: undefined reference to `handle_trap'
	/tmp/hello-world.elf.Nngidp.ltrans0.ltrans.o:cpu/riscv_common/irq_arch.c:134:(.text.trap_entry+0x34):
	  relocation truncated to fit: R_RISCV_GPREL_I against undefined symbol `handle_trap'

This commit fixes LTO support for RISC-V.

While at it, also mark the function as static as it is only used by the
trap_entry function from the same compilation unit.
This commit is contained in:
Sören Tempel 2021-05-05 15:03:12 +02:00
parent 77864c660d
commit 628c199f51

View File

@ -70,7 +70,7 @@ void riscv_irq_init(void)
/**
* @brief Global trap and interrupt handler
*/
void handle_trap(uint32_t mcause)
static void __attribute((used)) handle_trap(uint32_t mcause)
{
/* Tell RIOT to set sched_context_switch_request instead of
* calling thread_yield(). */