summaryrefslogtreecommitdiff
path: root/mk/bin2rel.mk
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2024-05-23 20:11:08 -0600
committerAlejandro Soto <alejandro@34project.org>2024-05-24 05:58:44 -0600
commit2008c2d4b4a7b4d1373d0b04db8ef775bb4b68ab (patch)
treef63fb62da7a87df894cb82dc1382a1bdb6f0eb15 /mk/bin2rel.mk
parent812f3d4e9baf2e5aed0d56302707399a8abc8697 (diff)
mk: add bin2rel hook
Diffstat (limited to 'mk/bin2rel.mk')
-rw-r--r--mk/bin2rel.mk19
1 files changed, 19 insertions, 0 deletions
diff --git a/mk/bin2rel.mk b/mk/bin2rel.mk
new file mode 100644
index 0000000..a627e54
--- /dev/null
+++ b/mk/bin2rel.mk
@@ -0,0 +1,19 @@
+bin2rel_src = $(call require_core_objs,$(1),bin2rel_src)
+bin2rel_obj = $(call require_core_objs,$(1),bin2rel_obj)
+
+define hooks/bin2rel
+ define obj_rules
+ $$(call bin2rel_obj,$(1)): $$(call bin2rel_src,$(1)) $$(obj_deps)
+ $$(call run,BIN2REL,$$@) \
+ cd $$(dir $$<) && \
+ $$(core_info/$(1)/cross)ld -r -b binary -o $$(src)/$$@.data $$(notdir $$<) && \
+ cd - && \
+ $$(core_info/$(1)/cross)objcopy \
+ --rename-section .data=.rodata,alloc,load,readonly,data,contents \
+ --set-section-alignment .data=16 \
+ $$@.data $$@ && \
+ rm -f $$@.data
+ endef
+
+ $$(eval $$(call add_obj_rules,$(1)))
+endef