summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2019-06-26 20:12:40 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2019-06-26 20:12:40 -0400
commit10a88b6a716a5ed75fd924da93015593e9f25296 (patch)
treed5951192a3d8e6cc5e64ddc9ac6c5e6b5e45bbcf
parent255a5c1832ff26ef607c2bbada68294beb72a1e8 (diff)
Simplify ld_script for modern, use devkitARM libs
-rw-r--r--Makefile14
-rw-r--r--ld_script_modern.txt162
2 files changed, 173 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index b23b278be..a47c45135 100644
--- a/Makefile
+++ b/Makefile
@@ -39,18 +39,20 @@ CC1 := tools/agbcc/bin/agbcc$(EXE)
override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm
ROM := pokeemerald.gba
OBJ_DIR := build/emerald
+LIBPATH := -L ../../tools/agbcc/lib
else
CC1 := $(shell $(PREFIX)gcc --print-prog-name=cc1)
override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -quiet -fno-toplevel-reorder -Wno-aggressive-loop-optimizations -Wno-pointer-to-int-cast
ROM := pokeemerald_modern.gba
OBJ_DIR := build/modern
+LIBPATH := -L $(DEVKITARM)/lib/gcc/arm-none-eabi/*/thumb -L $(DEVKITARM)/arm-none-eabi/lib/thumb
endif
CPPFLAGS := -I tools/agbcc/include -I tools/agbcc -iquote include -Wno-trigraphs -DMODERN=$(MODERN)
LDFLAGS = -Map ../../$(MAP)
-LIB := -L ../../tools/agbcc/lib -lgcc -lc
+LIB := $(LIBPATH) -lgcc -lc
SHA1 := $(shell { command -v sha1sum || command -v shasum; } 2>/dev/null) -c
GFX := tools/gbagfx/gbagfx$(EXE)
@@ -204,8 +206,14 @@ $(OBJ_DIR)/sym_common.ld: sym_common.txt $(C_OBJS) $(wildcard common_syms/*.txt)
$(OBJ_DIR)/sym_ewram.ld: sym_ewram.txt
$(RAMSCRGEN) ewram_data $< ENGLISH > $@
-$(OBJ_DIR)/ld_script.ld: ld_script.txt $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_common.ld $(OBJ_DIR)/sym_ewram.ld
- cd $(OBJ_DIR) && sed "s#tools/#../../tools/#g" ../../ld_script.txt > ld_script.ld
+ifeq ($(MODERN),0)
+LD_SCRIPT := ld_script.txt
+else
+LD_SCRIPT := ld_script_modern.txt
+endif
+
+$(OBJ_DIR)/ld_script.ld: $(LD_SCRIPT) $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_common.ld $(OBJ_DIR)/sym_ewram.ld
+ cd $(OBJ_DIR) && sed "s#tools/#../../tools/#g" ../../$(LD_SCRIPT) > ld_script.ld
$(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS)
cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB)
diff --git a/ld_script_modern.txt b/ld_script_modern.txt
new file mode 100644
index 000000000..22884ae44
--- /dev/null
+++ b/ld_script_modern.txt
@@ -0,0 +1,162 @@
+ENTRY(Start)
+
+gNumMusicPlayers = 4;
+gMaxLines = 0;
+
+SECTIONS {
+ . = 0x2000000;
+
+ ewram (NOLOAD) :
+ ALIGN(4)
+ {
+ gHeap = .;
+
+ . = 0x1C000;
+
+ INCLUDE "sym_ewram.ld"
+
+ . = 0x40000;
+}
+
+ . = 0x3000000;
+
+ iwram (NOLOAD) :
+ ALIGN(4)
+ {
+ /* .bss starts at 0x3000000 */
+ INCLUDE "sym_bss.ld"
+
+ /* .bss.code starts at 0x3001AA8 */
+ src/m4a.o(.bss.code);
+
+ /* COMMON starts at 0x30022A8 */
+ INCLUDE "sym_common.ld"
+ *libc.a:sbrkr.o(COMMON);
+ end = .;
+ . = 0x8000;
+ }
+
+ . = 0x8000000;
+
+ .text :
+ ALIGN(4)
+ {
+ asm/crt0.o(.text);
+ src/*.o(.text);
+ asm/*.o(.text);
+ } =0
+
+ script_data :
+ ALIGN(4)
+ {
+ data/event_scripts.o(script_data);
+ data/battle_anim_scripts.o(script_data);
+ data/battle_scripts_1.o(script_data);
+ data/field_effect_scripts.o(script_data);
+ data/battle_scripts_2.o(script_data);
+ data/battle_ai_scripts.o(script_data);
+ data/contest_ai_scripts.o(script_data);
+ data/mystery_event_script_cmd_table.o(script_data);
+ } =0
+
+ lib_text :
+ ALIGN(4)
+ {
+ asm/libgcnmultiboot.o(.text);
+ asm/m4a_1.o(.text);
+ src/m4a.o(.text);
+ src/agb_flash.o(.text);
+ src/agb_flash_1m.o(.text);
+ src/agb_flash_mx.o(.text);
+ src/siirtc.o(.text);
+ src/librfu_stwi.o(.text);
+ src/librfu_intr.o(.text);
+ asm/librfu_intr.o(.text);
+ src/librfu_rfu.o(.text);
+ asm/librfu.o(.text);
+ asm/libagbsyscall.o(.text);
+ *libgcc.a:*.o(.text*);
+ *libc.a:*.o(.text*);
+ src/libisagbprn.o(.text);
+ } =0
+
+ .rodata :
+ ALIGN(4)
+ {
+ src/*.o(.rodata*);
+ data/*.o(.rodata*);
+ } =0
+
+ song_data :
+ ALIGN(4)
+ {
+ sound/songs/*.o(.rodata);
+ } =0
+
+ lib_rodata :
+ SUBALIGN(4)
+ {
+ src/m4a.o(.rodata);
+ src/agb_flash.o(.rodata);
+ src/agb_flash_1m.o(.rodata);
+ src/agb_flash_mx.o(.rodata);
+ src/agb_flash_le.o(.rodata);
+ src/siirtc.o(.rodata);
+ data/librfu_rodata.o(.rodata);
+ *libgcc.a:*.o(.rodata*);
+ *libc.a:*.o(.rodata*);
+ *libc.a:*.o(.data*);
+ src/libisagbprn.o(.rodata);
+ } =0
+
+ other_data :
+ ALIGN(4)
+ {
+ data/unknown_serial_data.o(.rodata);
+ data/multiboot_berry_glitch_fix.o(.rodata);
+ data/multiboot_pokemon_colosseum.o(.rodata);
+ } =0
+
+ anim_mon_front_pic_data :
+ ALIGN(4)
+ {
+ src/anim_mon_front_pics.o(.rodata);
+ } =0
+
+ gfx_data :
+ ALIGN(4)
+ {
+ src/graphics.o(.rodata);
+ } =0
+
+ /* DWARF debug sections.
+ Symbols in the DWARF debugging sections are relative to the beginning
+ of the section so we begin them at 0. */
+
+ /* DWARF 1 */
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+
+ /* GNU DWARF 1 extensions */
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+
+ /* DWARF 1.1 and DWARF 2 */
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+
+ /* DWARF 2 */
+ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+
+ /* Discard everything not specifically mentioned above. */
+ /DISCARD/ :
+ {
+ *(*);
+ }
+}