Remove hardcoded gap
This commit is contained in:
@@ -244,10 +244,10 @@ $(OBJ_DIR)/ld_script.ld: ld_script.txt $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_comm
|
||||
|
||||
$(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS)
|
||||
cd $(OBJ_DIR) && ../../$(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(LIB)
|
||||
$(FIX) $@ -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION) --silent
|
||||
|
||||
$(ROM): $(ELF)
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
$(FIX) $@ -p -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION) --silent
|
||||
$(OBJCOPY) -O binary --gap-fill 0xFF --pad-to 0x9000000 $< $@
|
||||
|
||||
berry_fix/berry_fix.gba:
|
||||
@$(MAKE) -C berry_fix
|
||||
|
||||
BIN
Binary file not shown.
+1
-7
@@ -541,13 +541,7 @@ SECTIONS {
|
||||
data/multiboot_pokemon_colosseum.o(.rodata);
|
||||
} =0
|
||||
|
||||
gap1 :
|
||||
{
|
||||
gap1_start = ABSOLUTE(.);
|
||||
BYTE(0xFF)
|
||||
. = 0x8D00000 - gap1_start;
|
||||
} =0xFF
|
||||
|
||||
. = 0x08D00000;
|
||||
gfx_data :
|
||||
ALIGN(4)
|
||||
{
|
||||
|
||||
+3147
File diff suppressed because it is too large
Load Diff
+40
-12
@@ -33,6 +33,7 @@
|
||||
|
||||
History
|
||||
-------
|
||||
v1.07 - added support for ELF input, (PikalaxALT)
|
||||
v1.06 - added output silencing, (Diegoisawesome)
|
||||
v1.05 - added debug offset argument, (Diegoisawesome)
|
||||
v1.04 - converted to plain C, (WinterMute)
|
||||
@@ -48,8 +49,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include "elf.h"
|
||||
|
||||
#define VER "1.06"
|
||||
#define VER "1.07"
|
||||
#define ARGV argv[arg]
|
||||
#define VALUE (ARGV+2)
|
||||
#define NUMBER strtoul(VALUE, NULL, 0)
|
||||
@@ -137,6 +139,7 @@ int main(int argc, char *argv[])
|
||||
char *argfile = 0;
|
||||
FILE *infile;
|
||||
int silent = 0;
|
||||
int schedule_pad = 0;
|
||||
|
||||
int size,bit;
|
||||
|
||||
@@ -171,12 +174,30 @@ int main(int argc, char *argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t sh_offset = 0;
|
||||
|
||||
// read file
|
||||
infile = fopen(argfile, "r+b");
|
||||
if (!infile) { fprintf(stderr, "Error opening input file!\n"); return -1; }
|
||||
fseek(infile, 0, SEEK_SET);
|
||||
fseek(infile, sh_offset, SEEK_SET);
|
||||
fread(&header, sizeof(header), 1, infile);
|
||||
|
||||
// elf check
|
||||
Elf32_Shdr secHeader;
|
||||
if (memcmp(&header, ELFMAG, 4) == 0) {
|
||||
Elf32_Ehdr *elfHeader = (Elf32_Ehdr *)&header;
|
||||
fseek(infile, elfHeader->e_shoff, SEEK_SET);
|
||||
int i;
|
||||
for (i = 0; i < elfHeader->e_shnum; i++) {
|
||||
fread(&secHeader, sizeof(Elf32_Shdr), 1, infile);
|
||||
if (secHeader.sh_type == SHT_PROGBITS && secHeader.sh_addr == elfHeader->e_entry) break;
|
||||
}
|
||||
if (i == elfHeader->e_shnum) { fprintf(stderr, "Error finding entry point!\n"); return 1; }
|
||||
fseek(infile, secHeader.sh_offset, SEEK_SET);
|
||||
sh_offset = secHeader.sh_offset;
|
||||
fread(&header, sizeof(header), 1, infile);
|
||||
}
|
||||
|
||||
// fix some data
|
||||
memcpy(header.logo, good_header.logo, sizeof(header.logo));
|
||||
memcpy(&header.fixed, &good_header.fixed, sizeof(header.fixed));
|
||||
@@ -191,15 +212,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
case 'p': // pad
|
||||
{
|
||||
fseek(infile, 0, SEEK_END);
|
||||
size = ftell(infile);
|
||||
for (bit=31; bit>=0; bit--) if (size & (1<<bit)) break;
|
||||
if (size != (1<<bit))
|
||||
{
|
||||
int todo = (1<<(bit+1)) - size;
|
||||
while (todo--) fputc(0xFF, infile);
|
||||
}
|
||||
fseek(infile, 0, SEEK_SET);
|
||||
schedule_pad = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -279,7 +292,22 @@ int main(int argc, char *argv[])
|
||||
header.complement = HeaderComplement();
|
||||
//header.checksum = checksum_without_header + HeaderChecksum();
|
||||
|
||||
fseek(infile, 0, SEEK_SET);
|
||||
if (schedule_pad) {
|
||||
if (sh_offset != 0) {
|
||||
fprintf(stderr, "Warning: Cannot safely pad an ELF\n");
|
||||
} else {
|
||||
fseek(infile, 0, SEEK_END);
|
||||
size = ftell(infile);
|
||||
for (bit=31; bit>=0; bit--) if (size & (1<<bit)) break;
|
||||
if (size != (1<<bit))
|
||||
{
|
||||
int todo = (1<<(bit+1)) - size;
|
||||
while (todo--) fputc(0xFF, infile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fseek(infile, sh_offset, SEEK_SET);
|
||||
fwrite(&header, sizeof(header), 1, infile);
|
||||
fclose(infile);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user