mirror of
https://github.com/radareorg/r2flutter.git
synced 2026-11-07 06:26:00 -10:00
r2 flag names are unique, so flagging a second function with a repeated Dart name (e.g. Native._anon_closure) moved the flag away from the first one, and current r2's af then named it after the Mach-O sym.func.* flag. Suffix repeats with their address, use the same names for afs, and rename analyzed functions after the af pass. Also skip var recovery, call-following and jump tables in the signature af pass (AuthPass -AAA 47s -> 29s) and raise R2R_TIMEOUT to 60s.
135 lines
4.5 KiB
Makefile
135 lines
4.5 KiB
Makefile
CC ?= gcc
|
|
R2_CFLAGS ?= $(shell r2 -H R2_CFLAGS)
|
|
R2_LDFLAGS ?= $(shell r2 -H R2_LDFLAGS)
|
|
R2_LIBS ?= $(shell r2 -H R2_LIBS)
|
|
CFLAGS ?= -Wall -Wextra -O2 -fPIC
|
|
CFLAGS += -Iinclude -Iinclude/r2flutter
|
|
CFLAGS += $(R2_CFLAGS)
|
|
LDFLAGS += $(R2_LDFLAGS)
|
|
LDLIBS += $(R2_LIBS)
|
|
DEPFLAGS = -MMD -MP
|
|
R2R_JOBS ?= 1
|
|
R2R_TIMEOUT ?= 60
|
|
R2_LIBR_PLUGINS=$(shell r2 -H R2_LIBR_PLUGINS 2> /dev/null)
|
|
R2_LIBEXT=$(shell r2 -H R2_LIBEXT 2> /dev/null)
|
|
-include config.mk
|
|
PREFIX?=/usr/local
|
|
|
|
# Directories
|
|
SRC_DIR = src/lib
|
|
BUILD_DIR = build
|
|
BIN_DIR = bin
|
|
|
|
# Source files
|
|
LIB_SRC = $(SRC_DIR)/dart_app.c $(SRC_DIR)/dart_dumper.c $(SRC_DIR)/dart_pool_snapshot.c $(SRC_DIR)/dart_pool_discovery.c $(SRC_DIR)/dart_pool_names.c $(SRC_DIR)/dart_pool_strings.c $(SRC_DIR)/dart_pool_data_image.c $(SRC_DIR)/dart_pool_it.c $(SRC_DIR)/dart_pool_xrefs.c $(SRC_DIR)/dart_object.c $(SRC_DIR)/dart_sbom.c $(SRC_DIR)/dart_pool_clusters.c $(SRC_DIR)/dart_pool_classes.c $(SRC_DIR)/dart_pool_model.c $(SRC_DIR)/dart_pool_parse.c $(SRC_DIR)/dart_pool_modern.c $(SRC_DIR)/dart_version.c $(SRC_DIR)/dart_cid.c $(SRC_DIR)/dart_obf.c
|
|
MAIN_SRC = src/tool/main.c
|
|
ANALYSIS_SRC = src/r2/flutter_analysis.c
|
|
|
|
# Object files
|
|
LIB_OBJ = $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(LIB_SRC))
|
|
MAIN_OBJ = $(BUILD_DIR)/main.o
|
|
ANALYSIS_OBJ = $(BUILD_DIR)/flutter_analysis.o
|
|
DEP_FILES = $(LIB_OBJ:.o=.d) $(MAIN_OBJ:.o=.d) $(ANALYSIS_OBJ:.o=.d)
|
|
|
|
# Artifacts
|
|
BIN_FILE = $(BIN_DIR)/r2flutter
|
|
STATIC_LIB = $(BUILD_DIR)/libr2flutter.a
|
|
INC_VER = include/r2flutter/r2flutter_version.h
|
|
|
|
all: $(BIN_FILE) $(INC_VER)
|
|
|
|
# Regenerate C files from offsets.json (the single source of truth)
|
|
gen:
|
|
python3 scripts/update-dart-version --generate
|
|
|
|
$(INC_VER):
|
|
./configure
|
|
|
|
$(STATIC_LIB): $(LIB_OBJ)
|
|
ar rcs $@ $^
|
|
|
|
$(BIN_FILE): $(STATIC_LIB) $(MAIN_OBJ) $(ANALYSIS_OBJ) | $(shell mkdir -p $(BIN_DIR))
|
|
$(CC) $(CFLAGS) -o $@ $(MAIN_OBJ) $(ANALYSIS_OBJ) -L$(BUILD_DIR) -lr2flutter $(LDFLAGS) $(LDLIBS) -Wl,-rpath,$(PREFIX)/lib -g
|
|
|
|
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
|
|
@mkdir -p $(dir $@)
|
|
$(CC) $(CFLAGS) $(DEPFLAGS) -g -c $< -o $@
|
|
|
|
$(MAIN_OBJ): $(MAIN_SRC)
|
|
@mkdir -p $(dir $@)
|
|
$(CC) $(CFLAGS) $(DEPFLAGS) -g -c $< -o $@
|
|
|
|
$(ANALYSIS_OBJ): $(ANALYSIS_SRC) src/r2/flutter_analysis.h
|
|
@mkdir -p $(dir $@)
|
|
$(CC) $(CFLAGS) $(DEPFLAGS) -g -c $< -o $@
|
|
|
|
r2 plugin:
|
|
$(MAKE) $(STATIC_LIB)
|
|
$(MAKE) -C src/r2
|
|
$(MAKE) -C src/r2 user-install
|
|
|
|
user-install user-uninstall:
|
|
$(MAKE) $(STATIC_LIB)
|
|
$(MAKE) -C src/r2
|
|
$(MAKE) -C src/r2 $@
|
|
|
|
# Binary package for r2pm -bi: bin/ and plugins/ for this r2 version and platform
|
|
# r2 <= 6.2.2 lacks r2pm -H R2PM_TRIPLET, fallback to the host asm.* defaults
|
|
PKG_TRIPLET := $(or $(shell r2pm -H R2PM_TRIPLET 2> /dev/null),$(shell r2 -N -qc '?e `e asm.os`-`e asm.arch`-`e asm.bits`' -- 2> /dev/null))
|
|
BINDIST_ZIP = r2flutter-$(shell r2 -qv)-$(PKG_TRIPLET).zip
|
|
BINDIST_DIR = $(BUILD_DIR)/bindist
|
|
BINDIST_FILES = $(BINDIST_DIR)/bin/r2flutter $(BINDIST_DIR)/plugins/core_flutter.$(R2_LIBEXT)
|
|
STRIP ?= strip
|
|
|
|
bindist: $(BIN_FILE)
|
|
$(MAKE) $(STATIC_LIB)
|
|
$(MAKE) -C src/r2
|
|
rm -rf $(BINDIST_DIR) $(BINDIST_ZIP)
|
|
mkdir -p $(BINDIST_DIR)/bin $(BINDIST_DIR)/plugins
|
|
cp -f $(BIN_FILE) $(BINDIST_DIR)/bin/
|
|
cp -f src/r2/core_flutter.$(R2_LIBEXT) $(BINDIST_DIR)/plugins/
|
|
cp -f dist/README.md $(BINDIST_DIR)/
|
|
ifeq ($(R2_LIBEXT),dylib)
|
|
$(STRIP) -x $(BINDIST_FILES)
|
|
codesign -f -s - $(BINDIST_FILES)
|
|
else
|
|
$(STRIP) --strip-unneeded $(BINDIST_FILES)
|
|
endif
|
|
cd $(BINDIST_DIR) && zip -r $(CURDIR)/$(BINDIST_ZIP) README.md bin plugins
|
|
|
|
install: uninstall
|
|
mkdir -p "$(DESTDIR)$(PREFIX)/bin"
|
|
cp -f bin/r2flutter "$(DESTDIR)$(PREFIX)/bin/r2flutter"
|
|
mkdir -p "$(DESTDIR)$(R2_LIBR_PLUGINS)"
|
|
cp -f src/r2/core_flutter.$(R2_LIBEXT) "$(DESTDIR)$(R2_LIBR_PLUGINS)"/core_flutter.$(R2_LIBEXT)
|
|
|
|
symstall: uninstall
|
|
mkdir -p "$(DESTDIR)$(PREFIX)/bin"
|
|
ln -fs $(shell pwd)/bin/r2flutter "$(DESTDIR)$(PREFIX)/bin/r2flutter"
|
|
mkdir -p "$(DESTDIR)$(R2_LIBR_PLUGINS)"
|
|
ln -fs $(shell pwd)/src/r2/core_flutter.$(R2_LIBEXT) "$(DESTDIR)$(R2_LIBR_PLUGINS)"/core_flutter.$(R2_LIBEXT)
|
|
|
|
uninstall:
|
|
rm -f "$(DESTDIR)$(PREFIX)/bin/r2flutter"
|
|
rm -f $(DESTDIR)$(R2_LIBR_PLUGINS)/core_flutter.$(R2_LIBEXT)
|
|
|
|
fmt indent format:
|
|
clang-format-radare2 $(shell find src include -name '*.[ch]')
|
|
|
|
clean:
|
|
rm -rf $(BUILD_DIR) $(BIN_DIR)/r2flutter
|
|
$(MAKE) -C src/r2 clean
|
|
|
|
test-r2r: $(BIN_FILE)
|
|
$(MAKE) -C src/r2
|
|
r2r -u -j$(R2R_JOBS) -t $(R2R_TIMEOUT) test/db
|
|
|
|
test: $(BIN_FILE)
|
|
@$(MAKE) -C src/r2
|
|
@echo "Running custom testsuite"
|
|
@python3 scripts/run_tests.py
|
|
|
|
.PHONY: all clean test test-r2r r2 plugin user-install user-uninstall fmt indent format bindist
|
|
|
|
-include $(DEP_FILES)
|