2023-05-30 18:08:52 +02:00
|
|
|
/*
|
|
|
|
* ps1-bare-metal - (C) 2023 spicyjpeg
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
|
|
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
|
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
|
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
|
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
ENTRY(_start)
|
|
|
|
|
|
|
|
MEMORY {
|
|
|
|
KERNEL_RAM (rwx) : ORIGIN = 0x80000000, LENGTH = 0x010000
|
|
|
|
APP_RAM (rwx) : ORIGIN = 0x80010000, LENGTH = 0x7f0000
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTIONS {
|
|
|
|
/* Code sections */
|
|
|
|
|
|
|
|
.text : {
|
2023-12-31 20:42:59 +01:00
|
|
|
_textStart = .;
|
|
|
|
|
2023-05-30 18:08:52 +02:00
|
|
|
*(.text .text.* .gnu.linkonce.t.*)
|
|
|
|
*(.plt .MIPS.stubs)
|
|
|
|
} > APP_RAM
|
|
|
|
|
|
|
|
.rodata : {
|
|
|
|
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
2023-12-31 20:42:59 +01:00
|
|
|
|
|
|
|
_textEnd = .;
|
2023-05-30 18:08:52 +02:00
|
|
|
} > APP_RAM
|
|
|
|
|
|
|
|
/* Global constructor/destructor arrays */
|
|
|
|
|
|
|
|
.preinit_array : {
|
2023-12-31 20:42:59 +01:00
|
|
|
. = ALIGN((. != 0) ? 4 : 1);
|
|
|
|
_preinitArrayStart = .;
|
|
|
|
|
2023-05-30 18:08:52 +02:00
|
|
|
KEEP(*(.preinit_array))
|
|
|
|
|
2023-12-31 20:42:59 +01:00
|
|
|
_preinitArrayEnd = .;
|
|
|
|
} > APP_RAM
|
2023-05-30 18:08:52 +02:00
|
|
|
|
|
|
|
.init_array : {
|
2023-12-31 20:42:59 +01:00
|
|
|
. = ALIGN((. != 0) ? 4 : 1);
|
|
|
|
_initArrayStart = .;
|
|
|
|
|
2023-05-30 18:08:52 +02:00
|
|
|
KEEP(*(SORT(.init_array.*) SORT(.ctors.*)))
|
|
|
|
KEEP(*(.init_array .ctors))
|
|
|
|
|
2023-12-31 20:42:59 +01:00
|
|
|
_initArrayEnd = .;
|
|
|
|
} > APP_RAM
|
2023-05-30 18:08:52 +02:00
|
|
|
|
|
|
|
.fini_array : {
|
2023-12-31 20:42:59 +01:00
|
|
|
. = ALIGN((. != 0) ? 4 : 1);
|
|
|
|
_finiArrayStart = .;
|
|
|
|
|
2023-05-30 18:08:52 +02:00
|
|
|
KEEP(*(.fini_array .dtors))
|
|
|
|
KEEP(*(SORT(.fini_array.*) SORT(.dtors.*)))
|
|
|
|
|
2023-12-31 20:42:59 +01:00
|
|
|
_finiArrayEnd = .;
|
|
|
|
} > APP_RAM
|
2023-05-30 18:08:52 +02:00
|
|
|
|
|
|
|
/* Data sections */
|
|
|
|
|
|
|
|
.data : {
|
|
|
|
*(.data .data.* .gnu.linkonce.d.*)
|
|
|
|
} > APP_RAM
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set _gp (copied to $gp) to point to the beginning of .sdata plus 0x8000,
|
|
|
|
* so anything within .sdata and .sbss can be accessed using the $gp
|
|
|
|
* register as base plus a signed 16-bit immediate.
|
|
|
|
*/
|
|
|
|
.sdata : {
|
2023-12-31 20:42:59 +01:00
|
|
|
_gp = ALIGN(16) + 0x7ff0;
|
|
|
|
|
2023-05-30 18:08:52 +02:00
|
|
|
*(.sdata .sdata.* .gnu.linkonce.s.*)
|
|
|
|
} > APP_RAM
|
|
|
|
|
|
|
|
.sbss (NOLOAD) : {
|
2023-12-31 20:42:59 +01:00
|
|
|
. = ALIGN((. != 0) ? 4 : 1);
|
|
|
|
_bssStart = .;
|
|
|
|
|
2023-05-30 18:08:52 +02:00
|
|
|
*(.sbss .sbss.* .gnu.linkonce.sb.*)
|
|
|
|
*(.scommon)
|
|
|
|
} > APP_RAM
|
|
|
|
|
|
|
|
.bss (NOLOAD) : {
|
|
|
|
*(.bss .bss.* .gnu.linkonce.b.*)
|
|
|
|
*(COMMON)
|
|
|
|
|
2023-12-31 20:42:59 +01:00
|
|
|
. = ALIGN((. != 0) ? 4 : 1);
|
|
|
|
_bssEnd = .;
|
|
|
|
} > APP_RAM
|
2023-05-30 18:08:52 +02:00
|
|
|
|
|
|
|
/* Dummy sections */
|
|
|
|
|
|
|
|
.dummy (NOLOAD) : {
|
|
|
|
KEEP(*(.dummy))
|
|
|
|
} > APP_RAM
|
|
|
|
|
|
|
|
/DISCARD/ : {
|
|
|
|
*(.gnu.lto_*)
|
|
|
|
}
|
|
|
|
}
|