tinygo/targets/nintendoswitch.ld
Ayke van Laethem 9e599bac49 nintendoswitch: support outputting .nro files directly
By modifying the linker script a bit and adding the NRO0 header directly
in the assembly, it's possible to craft an ELF file that can be
converted straight to a binary (using objcopy or similar) that is a NRO
file. This avoids custom code for NRO files or an extra build step.

With another change, .nro files are recognized by TinyGo so that this
will create a ready-to-run NRO file:

    tinygo build -o test.nro -target=nintendoswitch examples/serial
2020-09-12 18:37:58 +02:00

69 строки
1,1 КиБ
Text

SECTIONS
{
. = 0;
/* Code and file header */
.text : {
HIDDEN(__text_start = .);
KEEP(*(.text.jmp))
. = 0x80;
*(.text .text.*)
. = ALIGN(0x1000);
HIDDEN(__text_end = .);
HIDDEN(__text_size = . - __text_start);
}
/* Read-only sections */
.rodata : {
HIDDEN(__rodata_start = .);
*(.rodata .rodata.*)
*(.got)
KEEP(crt0.nso.o(.data.mod0))
KEEP(crt0.nro.o(.data.mod0))
KEEP(crt0.lib.nro.o(.data.mod0))
KEEP(*(.data.mod0))
HIDDEN(__dynamic_start = .);
*(.dynamic)
. = ALIGN(0x1000);
HIDDEN(__rodata_end = .);
HIDDEN(__rodata_size = . - __rodata_start);
}
/* Read-write sections */
.data : {
HIDDEN(__data_start = .);
*(.data .data.*)
HIDDEN(__data_end = .);
HIDDEN(__data_size = . - __data_start);
}
/* BSS section */
.bss : {
HIDDEN(__bss_start = .);
*(.bss .bss.*)
*(COMMON)
HIDDEN(__bss_end = .);
HIDDEN(__bss_size = . - __bss_start);
}
/DISCARD/ :
{
*(.eh_frame) /* This is probably unnecessary and bloats the binary. */
}
}