os-workshop

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 33e6393b0ff66938522869fa11d9f32422ff65d6
parent 234d4735e49c2a246be293a4e29863926ba2085a
Author: Brian Swetland <swetland@frotz.net>
Date:   Sat, 14 May 2022 20:55:26 -0700

build: add the ability to bundle extra binary data into apps

- if MOD_EXT specifies a file, it will be included as-is,
  4-byte aligned, between __extra_start and __extra_end symbols
  in the rodata area

Diffstat:
Mdocs/build-system.md | 2++
Mhw/common.ram.ld | 4++++
Mmake/app.mk | 13+++++++++++++
3 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/docs/build-system.md b/docs/build-system.md @@ -16,6 +16,8 @@ Libraries must be named such that `libNAME/inc` is their include directory and t `MOD_LDSCRIPT`: alternate linker script +`MOD_EXT`: specify a binary file to include. It will be 4-byte-aligned and sandwiched between `__extra_start` and `__extra_end` symbols. + `MOD_QEMU_FB`: If defined, this when `make run.NAME` is invoked to run this module under Qemu, the framebuffer will be enabled. ## Application Build Outputs diff --git a/hw/common.ram.ld b/hw/common.ram.ld @@ -15,6 +15,10 @@ SECTIONS { __rodata_start = .; *(.rodata .rodata.* .gnu.linkonce.r.*) . = ALIGN(4); + __extra_start = .; + KEEP(*(.extra .extra.*)) + . = ALIGN(4); + __extra_end = .; __rodata_end = .; } > RAM diff --git a/make/app.mk b/make/app.mk @@ -12,6 +12,18 @@ ALL += $(MOD_ELF) $(MOD_LST) $(MOD_BIN) include make/rules.mk +ifneq ($(MOD_EXT),) +# if there is an extra data file, arrange for it to +# be added as an object file containing an .extra +# segment with the raw data. The linker script +# will stuff it in .rodata sandwiched between +# __extra_start and __extra_end symbols +$(BUILD)/$(MOD_NAME)/extra.o: $(MOD_EXT) + $(V)$(XOBJCOPY) -I binary -O elf32-littleriscv --rename-section .data=.extra $< $@ + +MOD_OBJ += $(BUILD)/$(MOD_NAME)/extra.o +endif + $(MOD_ELF): $(MOD_DIR)/build.opts $(patsubst %,$(BUILD)/lib%.a,$(MOD_LIB)) $(MOD_ELF): _OBJ := $(MOD_OBJ) @@ -41,5 +53,6 @@ MOD_NAME := MOD_INC := MOD_SRC := MOD_LIB := +MOD_EXT := MOD_LDSCRIPT := MOD_QEMU_FB :=