c9a028cc18
This tool is a scriptable (lua) tool to patch binaries, it supports: - raw binary - ELF - SB(v1/v2) It also contains some basic routines to parse and generate useful arm/thumb code like jump or register load/store. This is very useful to take a firmware and patch an interrupt vector or some code to jump to an extra payload added to the binary. Examples are provided for several STMP based target which the payload is expected to be hwstub, and also for the Sansa View. A typical patcher usually requires three elements: - the lua patcher itself - the payload (hwstub for example) - (optional) a small stub either to jump properly to the payload or determine under which circumstance to do the jump (hold a key for example) Change-Id: I6d36020a3bc9e636615ac8221b7591ade5f251e3
25 lines
611 B
Diff
25 lines
611 B
Diff
PREFIX?=arm-elf-eabi-
|
|
AS=$(PREFIX)gcc
|
|
ASFLAGS=-nostdlib -ffreestanding -mcpu=arm926ej-s
|
|
OC=$(PREFIX)objcopy
|
|
TARGETS=fuzeplus zenxfi2 zenxfi3 zen nwz zenxfistyle
|
|
OPT_fuzeplus=-DSANSA_FUZEPLUS
|
|
OPT_zenxfi2=-DCREATIVE_ZENXFI2
|
|
OPT_zenxfi3=-DCREATIVE_ZENXFI3
|
|
OPT_zen=-DCREATIVE_ZEN
|
|
OPT_nwz=-DSONY_NWZ
|
|
OPT_zenxfistyle=-DCREATIVE_ZENXFISTYLE
|
|
|
|
BOOTBINS=$(patsubst %, patch_%.bin, $(TARGETS))
|
|
BOOTELF=$(patsubst %, patch_%.elf, $(TARGETS))
|
|
|
|
all: $(BOOTBINS)
|
|
|
|
patch_%.bin: patch_%.elf
|
|
$(OC) -O binary $^ $@
|
|
|
|
patch_%.elf: patch.S
|
|
$(AS) $(ASFLAGS) $(OPT_$(@:patch_%.elf=%)) -o $@ $<
|
|
|
|
clean:
|
|
rm -rf $(BOOTBINS) $(BOOTELF)
|