diff --git a/sm64.ld b/sm64.ld index 382c8422..49696019 100755 --- a/sm64.ld +++ b/sm64.ld @@ -1,8 +1,8 @@ OUTPUT_ARCH (mips) -/* include/segments.h defines SEG_POOL_START, SEG_POOL_END, SEG_BUFFERS, - * SEG_GODDARD, SEG_MAIN, SEG_ENGINE, SEG_FRAMEBUFFERS */ +#define LINKER /* Removes externs from preprocessed script */ #include "segments.h" +#undef LINKER #define BEGIN_SEG(name, addr) \ _##name##SegmentStart = ADDR(.name); \ @@ -79,7 +79,31 @@ SECTIONS BEGIN_NOLOAD(zbuffer) { BUILD_DIR/src/buffers/zbuffer.o(.bss*); } + END_NOLOAD(zbuffer) + . = _zbufferSegmentNoloadEnd; + BEGIN_NOLOAD(buffers) + { + BUILD_DIR/src/buffers/buffers.o(.bss*); + BUILD_DIR/src/audio/globals_start.o(.bss*); + BUILD_DIR/src/audio/synthesis.o(.bss*); + BUILD_DIR/src/audio/heap.o(.bss*); + BUILD_DIR/src/audio/load.o(.bss*); + BUILD_DIR/src/audio/data.o(.bss*); + BUILD_DIR/src/audio*.o(.bss*); + +#ifdef VERSION_EU + . = ALIGN(0x200); +#else + . = ALIGN(0x1000); +#endif + BUILD_DIR/src/buffers/gfx_output_buffer.o(.bss*); + } + END_NOLOAD(buffers) + + /*ASSERT((. <= SEG_MAIN), "Error: buffers segment extended into main")*/ + + . = _buffersSegmentNoloadEnd; /* lib/src/__osDevMgrMain.c and lib/src/osCreateViManager.c contain infinite * loops compiled without -g, which cause the return statements and the .o * files themselves to be aligned to 32-byte boundaries. But the linker @@ -87,7 +111,7 @@ SECTIONS * only to 16 bytes, in some cases misaligning them. We force the same to * happen using the SUBALIGN directive. This is harmless; the alignment is * just an optimization. */ - BEGIN_SEG(main, SEG_MAIN) SUBALIGN(16) + BEGIN_SEG(main, .) SUBALIGN(16) { BUILD_DIR/asm/entry.o(.text); BUILD_DIR/src/game/crash_screen.o(.text); @@ -648,9 +672,11 @@ SECTIONS _mainSegmentNoloadSizeLo = SIZEOF (.main.noload) & 0xffff; _mainSegmentNoloadSizeHi = SIZEOF (.main.noload) >> 16; - ASSERT((. <= SEG_ENGINE), "Error: main segment extended into engine.") + /*ASSERT((. <= SEG_ENGINE), "Error: main segment extended into engine.")*/ - BEGIN_SEG(engine, SEG_ENGINE) + . = _mainSegmentNoloadEnd; + + BEGIN_SEG(engine, .) { BUILD_DIR/src/engine/math_util.o(.text); BUILD_DIR/src/engine/graph_node.o(.text); @@ -706,18 +732,23 @@ SECTIONS BUILD_DIR/src/game/object_helpers.o(.bss*); #endif BUILD_DIR/src/engine*.o(.bss*); + . = ALIGN(0x100); } END_NOLOAD(engine) - ASSERT((. <= SEG_FRAMEBUFFERS), "Error: engine segment extended into framebuffers.") + /*ASSERT((. <= SEG_FRAMEBUFFERS), "Error: engine segment extended into framebuffers.")*/ - . = SEG_FRAMEBUFFERS; + . = _engineSegmentNoloadEnd; BEGIN_NOLOAD(framebuffers) { BUILD_DIR/src/buffers/framebuffers.o(.bss*); + . = ALIGN(0x100); } END_NOLOAD(framebuffers) + __mainPoolStart = .; + __mainPoolSize = RAM_END - .; + __expansionRamStart = 0x80400000; ASSERT((. <= __expansionRamStart), "Error: RDRAM expanded into Expansion RAM, despite Expansion RAM not being defined.") @@ -854,29 +885,8 @@ SECTIONS } END_NOLOAD(goddard) - ASSERT((. <= SEG_POOL_END), "Error: extended past pool end.") + ASSERT((. <= (SEG_POOL_START + POOL_SIZE)), "Error: extended past pool end.") - . = SEG_BUFFERS; - BEGIN_NOLOAD(buffers) - { - BUILD_DIR/src/buffers/buffers.o(.bss*); - BUILD_DIR/src/audio/globals_start.o(.bss*); - BUILD_DIR/src/audio/synthesis.o(.bss*); - BUILD_DIR/src/audio/heap.o(.bss*); - BUILD_DIR/src/audio/load.o(.bss*); - BUILD_DIR/src/audio/data.o(.bss*); - BUILD_DIR/src/audio*.o(.bss*); - -#ifdef VERSION_EU - . = ALIGN(0x200); -#else - . = ALIGN(0x1000); -#endif - BUILD_DIR/src/buffers/gfx_output_buffer.o(.bss*); - } - END_NOLOAD(buffers) - - ASSERT((. <= SEG_MAIN), "Error: buffers segment extended into main") /* 0x268020 0x268020-0 [0] */ BEGIN_SEG(intro, 0x14000000)