[sw] Turn off Linker Relaxation in IRQ Vectors
This ensures the linker cannot change the size of these vectors if it
thinks the instructions can be replaced with shorter sequences.
Signed-off-by: Sam Elliott <selliott@lowrisc.org>
diff --git a/sw/device/boot_rom/irq_vector.S b/sw/device/boot_rom/irq_vector.S
index 1899ae4..861f29c 100644
--- a/sw/device/boot_rom/irq_vector.S
+++ b/sw/device/boot_rom/irq_vector.S
@@ -17,6 +17,10 @@
// be exactly word wide in the interrupt vector.
.option norvc
+ // Disable RISC-V linker relaxation, as it can compress instructions at
+ // link-time, which we also really don't want.
+ .option norelax
+
// Exception handler.
.org 0x00
j exception_handler
diff --git a/sw/device/exts/common/ibex_interrupt_vectors.S b/sw/device/exts/common/ibex_interrupt_vectors.S
index 8061737..0890e2b 100644
--- a/sw/device/exts/common/ibex_interrupt_vectors.S
+++ b/sw/device/exts/common/ibex_interrupt_vectors.S
@@ -7,16 +7,23 @@
* This file contains Ibex-specific interrupt vectors.
*/
- // NOTE: The "ax" flag below is necessary to ensure that this section
- // is allocated space in ROM by the linker.
- .section .vectors, "ax"
-
// These functions are declared in `sw/device/lib/handler.h`.
.extern handler_exception
.extern handler_irq_software
.extern handler_irq_timer
.extern handler_irq_external
+ // NOTE: The "ax" flag below is necessary to ensure that this section
+ // is allocated space in ROM by the linker.
+ .section .vectors, "ax"
+ .option push
+ // Switch off compressed instructions so we know each instruction below is
+ // exactly 4 bytes (one entry).
+ .option norvc
+ // Switch off linker relaxation so that the linker does not reduce the size of
+ // any entries.
+ .option norelax
+
/**
* `crt_interrupt_vector` is the CRT-loaded interrupt vector for Ibex.
*
@@ -38,11 +45,6 @@
crt_interrupt_vector:
.global crt_interrupt_vector
- // Switch off compressed instructions so we know each instruction below is
- // exactly 4 bytes (one entry).
- .option push
- .option norvc
-
// exception Handler and user software interrupt
j handler_exception
// supervisor software interrupt
@@ -84,8 +86,7 @@
// vendor interrupts: on Ibex interrupt id 31 is for non-maskable interrupts
unimp
- // Re-enable compressed instructions
- .option pop
-
// Set size so vector can be disassembled
.size crt_interrupt_vector, .-crt_interrupt_vector
+
+ .option pop