aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVincent Chen <vincent.chen@sifive.com>2021-03-17 09:16:38 +0800
committerAnup Patel <anup@brainfault.org>2021-03-19 15:00:50 +0530
commit0f20e8adcf42d31bc478d6700b625d00a68cb30e (patch)
treee2968cd11e015d47ce8062c0a9b4aa0e00dbc3d0 /include
parent22d8ee9758128070aa838f7c8c46f9e50d6aaf5a (diff)
firmware: Support position independent execution
Enable OpenSBI to support position independent execution. Because the position independent code will cause an additional GOT reference when accessing the global variables, it will reduce performance a bit. Therefore, the position independent execution is disabled by default. Users can through specifying "FW_PIC=y" on the make command to enable this feature. In theory, after enabling position-independent execution, the OpenSBI can run at arbitrary address with appropriate alignment. Therefore, the original relocation mechanism will be skipped. In other words, OpenSBI will directly run at the load address without any code movement. Signed-off-by: Vincent Chen <vincent.chen@sifive.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'include')
-rw-r--r--include/sbi/riscv_elf.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/sbi/riscv_elf.h b/include/sbi/riscv_elf.h
new file mode 100644
index 0000000..3b62c38
--- /dev/null
+++ b/include/sbi/riscv_elf.h
@@ -0,0 +1,14 @@
+#ifndef __RISCV_ELF_H__
+#define __RISCV_ELF_H__
+
+#include <sbi/riscv_asm.h>
+
+#define R_RISCV_32 1
+#define R_RISCV_64 2
+#define R_RISCV_RELATIVE 3
+
+#define RELOC_TYPE __REG_SEL(R_RISCV_64, R_RISCV_32)
+#define SYM_INDEX __REG_SEL(0x20, 0x8)
+#define SYM_SIZE __REG_SEL(0x18,0x10)
+
+#endif