blob: 8cccc664cd0bef1506768cb23295a167bb22837b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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)
|