summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2019-07-28 19:53:46 -0700
committerH. Peter Anvin <hpa@zytor.com>2019-07-28 19:57:09 -0700
commit953a01b311db06ed06cd4ab57be7f3e9278669ab (patch)
tree477628620887b5d33f0d8bff9d28ffab3e339c6c
parenta68f6ef07a7b331be048615c8029f6ebd8cc358a (diff)
downloadsamples-953a01b311db06ed06cd4ab57be7f3e9278669ab.tar.gz
samples-953a01b311db06ed06cd4ab57be7f3e9278669ab.tar.xz
samples-953a01b311db06ed06cd4ab57be7f3e9278669ab.zip
Makefile: build rel32.bin and convert it to a C file
-rw-r--r--elf2exe/.gitignore1
-rw-r--r--elf2exe/Makefile16
-rw-r--r--elf2exe/rel32.c7
3 files changed, 21 insertions, 3 deletions
diff --git a/elf2exe/.gitignore b/elf2exe/.gitignore
index 253a0a0..7640e99 100644
--- a/elf2exe/.gitignore
+++ b/elf2exe/.gitignore
@@ -1 +1,2 @@
elf2exe
+*.binh
diff --git a/elf2exe/Makefile b/elf2exe/Makefile
index 19f8594..abb75c2 100644
--- a/elf2exe/Makefile
+++ b/elf2exe/Makefile
@@ -1,9 +1,9 @@
MAKEFLAGS += -r -R
+.SECONDARY:
# For Windows
# O = obj
# X = .exe
-# S = asm
# A = lib
O = o
X =
@@ -17,7 +17,11 @@ LDFLAGS =
ALL = elf2exe$(X)
OBJS = elf2exe.$(O) file.$(O)
-HDRS = elf2exe.h leint.h elf32.h elfcommon.h
+HDRS = elf2exe.h leint.h elf32.h elfcommon.h rel32.binh
+
+NASM = nasm
+BIN2H = hexdump -v -e '/1 "0x%02x,\n"'
+
all: $(ALL)
@@ -33,8 +37,14 @@ elf2exe$(X): $(OBJS)
%.$(I): %.c $(HDRS)
$(CC) $(CFLAGS) -E -o $@ $<
+%.bin: %.asm
+ $(NASM) -f bin -o $@ -l $*.lst $<
+
+%.binh: %.bin
+ $(BIN2H) $< > $@
+
clean:
- rm -f *.$(O) *.$(S) *.$(A) *.$(I) $(ALL)
+ rm -f *.$(O) *.$(S) *.$(A) *.$(I) *.lst *.bin *.binh $(ALL)
spotless: clean
rm -f *~ *.bak
diff --git a/elf2exe/rel32.c b/elf2exe/rel32.c
new file mode 100644
index 0000000..3173b3f
--- /dev/null
+++ b/elf2exe/rel32.c
@@ -0,0 +1,7 @@
+#include "elf2exe.h"
+
+const uint8_t rel32_code[] = {
+#include "rel32.binh"
+};
+
+const size_t rel32_size = sizeof rel32_code;