Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "meta" section to ucodes #615

Open
wants to merge 1 commit into
base: preview
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/rsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ typedef struct {
void *code_end; ///< Pointer past the end of the code segment
uint8_t *data; ///< Pointer to the data segment
void *data_end; ///< Pointer past the end of the data segment
uint8_t *meta; ///< Pointer to the meta segment
void *meta_end; ///< Pointer past the end of the meta segment

const char *name; ///< Name of the ucode
uint32_t start_pc; ///< Initial RSP PC
Expand Down Expand Up @@ -344,13 +346,17 @@ typedef struct {
#define DEFINE_RSP_UCODE(ucode_name, ...) \
extern uint8_t ucode_name ## _text_start[]; \
extern uint8_t ucode_name ## _data_start[]; \
extern uint8_t ucode_name ## _meta_start[]; \
extern uint8_t ucode_name ## _text_end[0]; \
extern uint8_t ucode_name ## _data_end[0]; \
extern uint8_t ucode_name ## _meta_end[0]; \
rsp_ucode_t ucode_name = (rsp_ucode_t){ \
.code = ucode_name ## _text_start, \
.code_end = ucode_name ## _text_end, \
.data = ucode_name ## _data_start, \
.data_end = ucode_name ## _data_end, \
.meta = ucode_name ## _meta_start, \
.meta_end = ucode_name ## _meta_end, \
.name = #ucode_name, .start_pc = 0, \
.crash_handler = 0, .assert_handler = 0, \
__VA_ARGS__ \
Expand Down
13 changes: 11 additions & 2 deletions n64.mk
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,15 @@ $(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.S
SYMPREFIX="$(subst .,_,$(subst /,_,$(basename $@)))"; \
TEXTSECTION="$(basename $@).text"; \
DATASECTION="$(basename $@).data"; \
METASECTION="$(basename $@).meta"; \
BINARY="$(basename $@).elf"; \
echo " [RSP] $<"; \
$(N64_CC) $(RSPASFLAGS) -L$(N64_LIBDIR) -nostartfiles -Wl,-Trsp.ld -Wl,--gc-sections -Wl,-Map=$(BUILD_DIR)/$(notdir $(basename $@)).map -o $@ $<; \
mv "$@" $$BINARY; \
$(N64_OBJCOPY) -O binary -j .text $$BINARY $$TEXTSECTION.bin; \
$(N64_OBJCOPY) -O binary -j .data $$BINARY $$DATASECTION.bin; \
$(N64_OBJCOPY) -O binary -j .meta $$BINARY $$METASECTION.bin --set-section-flags .meta=alloc,load; \
[ -s $$METASECTION.bin ] || printf '\0' > $$METASECTION.bin; \
$(N64_OBJCOPY) -I binary -O elf32-bigmips -B mips4300 \
--redefine-sym _binary_$${SYMPREFIX}_text_bin_start=$${FILENAME}_text_start \
--redefine-sym _binary_$${SYMPREFIX}_text_bin_end=$${FILENAME}_text_end \
Expand All @@ -155,9 +158,15 @@ $(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.S
--redefine-sym _binary_$${SYMPREFIX}_data_bin_size=$${FILENAME}_data_size \
--set-section-alignment .data=16 \
--rename-section .text=.data $$DATASECTION.bin $$DATASECTION.o; \
$(N64_OBJCOPY) -I binary -O elf32-bigmips -B mips4300 \
--redefine-sym _binary_$${SYMPREFIX}_meta_bin_start=$${FILENAME}_meta_start \
--redefine-sym _binary_$${SYMPREFIX}_meta_bin_end=$${FILENAME}_meta_end \
--redefine-sym _binary_$${SYMPREFIX}_meta_bin_size=$${FILENAME}_meta_size \
--set-section-alignment .data=16 \
--rename-section .text=.data $$METASECTION.bin $$METASECTION.o; \
$(N64_SIZE) -G $$BINARY; \
$(N64_LD) -relocatable $$TEXTSECTION.o $$DATASECTION.o -o $@; \
rm $$TEXTSECTION.bin $$DATASECTION.bin $$TEXTSECTION.o $$DATASECTION.o; \
$(N64_LD) -relocatable $$TEXTSECTION.o $$DATASECTION.o $$METASECTION.o -o $@; \
rm $$TEXTSECTION.bin $$DATASECTION.bin $$METASECTION.bin $$TEXTSECTION.o $$DATASECTION.o $$METASECTION.o; \
else \
echo " [AS] $<"; \
$(CC) -c $(ASFLAGS) -o $@ $<; \
Expand Down
5 changes: 5 additions & 0 deletions rsp.ld
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,10 @@ SECTIONS
}
} > ram_data AT > rom_dmem

.meta : {
KEEP(*(.meta))
*(.meta.*)
}

/DISCARD/ : { *(.MIPS.abiflags) }
}