summaryrefslogtreecommitdiff
path: root/firmware/objects.mk
diff options
context:
space:
mode:
authorVincent Chen <vincent.chen@sifive.com>2021-03-17 04:16:38 +0300
committerAnup Patel <anup@brainfault.org>2021-03-19 12:30:50 +0300
commit0f20e8adcf42d31bc478d6700b625d00a68cb30e (patch)
treee2968cd11e015d47ce8062c0a9b4aa0e00dbc3d0 /firmware/objects.mk
parent22d8ee9758128070aa838f7c8c46f9e50d6aaf5a (diff)
downloadopensbi-0f20e8adcf42d31bc478d6700b625d00a68cb30e.tar.xz
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 'firmware/objects.mk')
-rw-r--r--firmware/objects.mk7
1 files changed, 7 insertions, 0 deletions
diff --git a/firmware/objects.mk b/firmware/objects.mk
index b2ace75..c1f632e 100644
--- a/firmware/objects.mk
+++ b/firmware/objects.mk
@@ -13,6 +13,13 @@ firmware-cflags-y +=
firmware-asflags-y +=
firmware-ldflags-y +=
+ifeq ($(FW_PIC),y)
+firmware-genflags-y += -DFW_PIC
+firmware-asflags-y += -fpic
+firmware-cflags-y += -fPIE -pie
+firmware-ldflags-y += -Wl,--no-dynamic-linker
+endif
+
ifdef FW_TEXT_START
firmware-genflags-y += -DFW_TEXT_START=$(FW_TEXT_START)
endif