diff options
Diffstat (limited to 'debug/risc-v-gsp-rm-vm/sdk/Makefile')
| -rw-r--r-- | debug/risc-v-gsp-rm-vm/sdk/Makefile | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/debug/risc-v-gsp-rm-vm/sdk/Makefile b/debug/risc-v-gsp-rm-vm/sdk/Makefile new file mode 100644 index 0000000..8cccc66 --- /dev/null +++ b/debug/risc-v-gsp-rm-vm/sdk/Makefile @@ -0,0 +1,32 @@ +# green-eye injected-service SDK: builds a position-independent RV64 blob. +# +# The service ELF is linked at address 0 and loaded by the injector at a +# runtime address; all code is PC-relative (medany + PIC, no globals), so no +# dynamic relocations are required. Verify with: llvm-readelf-18 -r build/*.elf + +CC := clang +LLD ?= $(shell command -v ld.lld 2>/dev/null || echo /usr/lib/llvm-18/bin/ld.lld) +BUILD := build +TARGET := $(BUILD)/injected_demo.elf + +CFLAGS := --target=riscv64-unknown-elf -march=rv64imac -mabi=lp64 \ + -mcmodel=medany -mno-relax -fPIC -ffreestanding -nostdlib \ + -fno-builtin -fno-stack-protector -fno-asynchronous-unwind-tables \ + -O2 -Wall -Wextra -I. + +.PHONY: all clean relocs + +all: $(TARGET) + +$(TARGET): injected_demo.c greeneye_service.h + @mkdir -p $(BUILD) + $(CC) $(CFLAGS) -c injected_demo.c -o $(BUILD)/injected_demo.o + $(LLD) -m elf64lriscv --no-relax -e ge_demo_service_dispatch \ + -o $@ $(BUILD)/injected_demo.o + @echo "built $@" + +relocs: $(TARGET) + @llvm-readelf-18 -r $(TARGET) 2>/dev/null || readelf -r $(TARGET) + +clean: + rm -rf $(BUILD) |
