mirror of
https://github.com/zeldaret/mm.git
synced 2024-11-22 20:39:49 +00:00
Remove include_data_with_rodata spec hack by incremental link of z_game_over (#1691)
This commit is contained in:
parent
34dcfbccc6
commit
5c6310306f
11
Makefile
11
Makefile
@ -556,6 +556,15 @@ $(BUILD_DIR)/src/overlays/%_reloc.o: $(BUILD_DIR)/$(SPEC)
|
||||
$(FADO) $$(tools/buildtools/reloc_prereq $< $(*F)) -n $(*F) -o $(@:.o=.s) -M $(@:.o=.d)
|
||||
$(AS) $(ASFLAGS) $(ENDIAN) $(IINC) $(@:.o=.s) -o $@
|
||||
|
||||
# Incremental link z_game_over data into rodata
|
||||
$(BUILD_DIR)/src/code/z_game_over.o: src/code/z_game_over.c
|
||||
$(CC_CHECK_COMP) $(CC_CHECK_FLAGS) $(IINC) $(CC_CHECK_WARNINGS) $(C_DEFINES) $(MIPS_BUILTIN_DEFS) -o $(@:.o=.tmp) $<
|
||||
$(CC) -c $(CFLAGS) $(IINC) $(WARNINGS) $(C_DEFINES) $(MIPS_VERSION) $(ENDIAN) $(OPTFLAGS) -o $(@:.o=.tmp) $<
|
||||
$(LD) -r -T linker_scripts/data_with_rodata.ld $(@:.o=.tmp) -o $@
|
||||
@$(RM) $(@:.o=.tmp)
|
||||
$(OBJDUMP_CMD)
|
||||
$(RM_MDEBUG)
|
||||
|
||||
$(SHIFTJIS_O_FILES): $(BUILD_DIR)/src/%.o: src/%.c
|
||||
$(SHIFTJIS_CONV) -o $(@:.o=.enc.c) $<
|
||||
$(CC_CHECK_COMP) $(CC_CHECK_FLAGS) $(IINC) $(CC_CHECK_WARNINGS) $(C_DEFINES) $(MIPS_BUILTIN_DEFS) -o $@ $(@:.o=.enc.c)
|
||||
@ -731,7 +740,7 @@ $(BUILD_DIR)/src/audio/tables/sequence_table.o: CFLAGS += -I include/tables
|
||||
$(BUILD_DIR)/src/audio/tables/%.o: src/audio/tables/%.c
|
||||
$(CC_CHECK_COMP) $(CC_CHECK_FLAGS) $(IINC) $(CC_CHECK_WARNINGS) $(C_DEFINES) $(MIPS_BUILTIN_DEFS) -o $(@:.o=.tmp) $<
|
||||
$(CC) -c $(CFLAGS) $(IINC) $(WARNINGS) $(C_DEFINES) $(MIPS_VERSION) $(ENDIAN) $(OPTFLAGS) -o $(@:.o=.tmp) $<
|
||||
$(LD) -r -T linker_scripts/audio_table_rodata.ld $(@:.o=.tmp) -o $@
|
||||
$(LD) -r -T linker_scripts/data_with_rodata.ld $(@:.o=.tmp) -o $@
|
||||
@$(RM) $(@:.o=.tmp)
|
||||
$(RM_MDEBUG)
|
||||
|
||||
|
@ -1,17 +0,0 @@
|
||||
OUTPUT_ARCH (mips)
|
||||
|
||||
/* Audio Table Linker Script, maps data into rodata */
|
||||
|
||||
SECTIONS {
|
||||
|
||||
.rodata :
|
||||
{
|
||||
*(.data*)
|
||||
*(.rodata*)
|
||||
}
|
||||
|
||||
/DISCARD/ :
|
||||
{
|
||||
*(*);
|
||||
}
|
||||
}
|
22
linker_scripts/data_with_rodata.ld
Normal file
22
linker_scripts/data_with_rodata.ld
Normal file
@ -0,0 +1,22 @@
|
||||
OUTPUT_ARCH (mips)
|
||||
|
||||
/* Maps data into rodata, used for audio tables and z_game_over */
|
||||
|
||||
SECTIONS {
|
||||
.rodata :
|
||||
{
|
||||
*(.data)
|
||||
*(.rodata)
|
||||
*(.rodata.str*)
|
||||
*(.rodata.cst*)
|
||||
}
|
||||
|
||||
/DISCARD/ :
|
||||
{
|
||||
/* GNU ld assumes that the linker script always combines .gptab.data and
|
||||
* .gptab.sdata into .gptab.sdata, and likewise for .gptab.bss and .gptab.sbss.
|
||||
* To avoid dealing with this, we just discard all .gptab sections.
|
||||
*/
|
||||
*(.gptab.*)
|
||||
}
|
||||
}
|
2
spec
2
spec
@ -773,7 +773,7 @@ beginseg
|
||||
include "$(BUILD_DIR)/src/audio/session_config.o"
|
||||
include "$(BUILD_DIR)/src/code/jpegutils.o"
|
||||
include "$(BUILD_DIR)/src/code/jpegdecoder.o"
|
||||
include_data_with_rodata "$(BUILD_DIR)/src/code/z_game_over.o"
|
||||
include "$(BUILD_DIR)/src/code/z_game_over.o"
|
||||
include "$(BUILD_DIR)/src/code/z_construct.o"
|
||||
include "$(BUILD_DIR)/src/audio/tables/soundfont_table.o"
|
||||
include "$(BUILD_DIR)/assets/audio/sequence_font_table.o"
|
||||
|
@ -85,11 +85,10 @@ static void write_ld_script(FILE* fout) {
|
||||
fprintf(fout, " _%sSegmentDataStart = .;\n", seg->name);
|
||||
|
||||
for (j = 0; j < seg->includesCount; j++) {
|
||||
if (!seg->includes[j].dataWithRodata)
|
||||
fprintf(fout,
|
||||
" %s (.data)\n"
|
||||
" . = ALIGN(0x10);\n",
|
||||
seg->includes[j].fpath);
|
||||
fprintf(fout,
|
||||
" %s (.data)\n"
|
||||
" . = ALIGN(0x10);\n",
|
||||
seg->includes[j].fpath);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -109,12 +108,6 @@ static void write_ld_script(FILE* fout) {
|
||||
fprintf(fout, " _%sSegmentRoDataStart = .;\n", seg->name);
|
||||
|
||||
for (j = 0; j < seg->includesCount; j++) {
|
||||
if (seg->includes[j].dataWithRodata)
|
||||
fprintf(fout,
|
||||
" %s (.data)\n"
|
||||
" . = ALIGN(0x10);\n",
|
||||
seg->includes[j].fpath);
|
||||
|
||||
fprintf(fout,
|
||||
" %s (.rodata)\n"
|
||||
" . = ALIGN(0x10);\n",
|
||||
|
@ -124,7 +124,6 @@ static const char* const stmtNames[] = {
|
||||
[STMT_entry] = "entry",
|
||||
[STMT_flags] = "flags",
|
||||
[STMT_include] = "include",
|
||||
[STMT_include_data_with_rodata] = "include_data_with_rodata",
|
||||
[STMT_name] = "name",
|
||||
[STMT_number] = "number",
|
||||
[STMT_romalign] = "romalign",
|
||||
@ -147,7 +146,7 @@ STMTId get_stmt_id_by_stmt_name(const char* stmtName, int lineNum) {
|
||||
|
||||
bool parse_segment_statement(struct Segment* currSeg, STMTId stmt, char* args, int lineNum) {
|
||||
// ensure no duplicates (except for 'include' or 'pad_text')
|
||||
if (stmt != STMT_include && stmt != STMT_include_data_with_rodata && stmt != STMT_pad_text &&
|
||||
if (stmt != STMT_include && stmt != STMT_pad_text &&
|
||||
(currSeg->fields & (1 << stmt)))
|
||||
util_fatal_error("line %i: duplicate '%s' statement", lineNum, stmtNames[stmt]);
|
||||
|
||||
@ -208,7 +207,6 @@ bool parse_segment_statement(struct Segment* currSeg, STMTId stmt, char* args, i
|
||||
break;
|
||||
|
||||
case STMT_include:
|
||||
case STMT_include_data_with_rodata:
|
||||
currSeg->includesCount++;
|
||||
currSeg->includes = realloc(currSeg->includes, currSeg->includesCount * sizeof(*currSeg->includes));
|
||||
|
||||
@ -216,7 +214,6 @@ bool parse_segment_statement(struct Segment* currSeg, STMTId stmt, char* args, i
|
||||
util_fatal_error("line %i: invalid filename", lineNum);
|
||||
|
||||
currSeg->includes[currSeg->includesCount - 1].linkerPadding = 0;
|
||||
currSeg->includes[currSeg->includesCount - 1].dataWithRodata = (stmt == STMT_include_data_with_rodata);
|
||||
break;
|
||||
case STMT_increment:
|
||||
if (!parse_number(args, &currSeg->increment))
|
||||
|
@ -14,7 +14,6 @@ typedef enum {
|
||||
STMT_entry,
|
||||
STMT_flags,
|
||||
STMT_include,
|
||||
STMT_include_data_with_rodata,
|
||||
STMT_name,
|
||||
STMT_number,
|
||||
STMT_romalign,
|
||||
@ -34,7 +33,6 @@ enum {
|
||||
struct Include {
|
||||
char* fpath;
|
||||
int linkerPadding;
|
||||
uint8_t dataWithRodata;
|
||||
};
|
||||
|
||||
typedef struct Segment {
|
||||
|
Loading…
Reference in New Issue
Block a user