# risc-v-gsp-rm-debugger 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)