File tree Expand file tree Collapse file tree 4 files changed +63
-29
lines changed Expand file tree Collapse file tree 4 files changed +63
-29
lines changed Original file line number Diff line number Diff line change @@ -373,8 +373,8 @@ endif
373
373
@$(MD5SUM) test.hex
374
374
$(TINYGO) build -size short -o test.hex -target=pca10040 -opt=1 examples/blinky1
375
375
@$(MD5SUM) test.hex
376
- $(TINYGO) build -o test.elf -target=nintendoswitch examples/serial
377
- @$(MD5SUM) test.elf
376
+ $(TINYGO) build -o test.nro -target=nintendoswitch examples/serial
377
+ @$(MD5SUM) test.nro
378
378
379
379
wasmtest :
380
380
$(GO ) test ./tests/wasm
Original file line number Diff line number Diff line change @@ -243,7 +243,7 @@ func (c *Config) Debug() bool {
243
243
// extension and the configured binary format in the target JSON file.
244
244
func (c * Config ) BinaryFormat (ext string ) string {
245
245
switch ext {
246
- case ".bin" , ".gba" :
246
+ case ".bin" , ".gba" , ".nro" :
247
247
// The simplest format possible: dump everything in a raw binary file.
248
248
if c .Target .BinaryFormat != "" {
249
249
return c .Target .BinaryFormat
Original file line number Diff line number Diff line change 1
- OUTPUT_FORMAT (elf64-littleaarch64)
2
- OUTPUT_ARCH(aarch64)
3
- ENTRY(_start)
4
-
5
- PHDRS
6
- {
7
- text PT_LOAD FLAGS (5 );
8
- rodata PT_LOAD FLAGS (4 );
9
- data PT_LOAD FLAGS (6 );
10
- bss PT_LOAD FLAGS (6 );
11
- dynamic PT_DYNAMIC;
12
- }
13
-
14
1
SECTIONS
15
2
{
16
3
. = 0 ;
17
4
18
- .text : ALIGN (0x1000 ) {
5
+ /* Code and file header */
6
+
7
+ .text : {
19
8
HIDDEN (__text_start = .);
20
9
KEEP (*(.text .jmp ))
21
10
22
11
. = 0x80 ;
23
12
24
13
*(.text .text .*)
14
+
15
+ . = ALIGN (0x1000 );
16
+ HIDDEN (__text_end = .);
17
+ HIDDEN (__text_size = . - __text_start);
25
18
}
26
19
27
20
/* Read-only sections */
28
21
29
- . = ALIGN (0x1000 );
22
+ .rodata : {
23
+ HIDDEN (__rodata_start = .);
24
+
25
+ *(.rodata .rodata .*)
26
+
27
+ *(.got )
30
28
31
- .rodata : { *(.rodata .rodata .*) } :rodata
32
- .mod0 : {
33
29
KEEP (crt0.nso .o (.data .mod0 ))
34
30
KEEP (crt0.nro .o (.data .mod0 ))
35
31
KEEP (crt0.lib .nro .o (.data .mod0 ))
32
+ KEEP (*(.data .mod0 ))
33
+
34
+ HIDDEN (__dynamic_start = .);
35
+ *(.dynamic )
36
+
37
+ . = ALIGN (0x1000 );
38
+ HIDDEN (__rodata_end = .);
39
+ HIDDEN (__rodata_size = . - __rodata_start);
36
40
}
37
41
38
42
/* Read-write sections */
39
- . = ALIGN (0x1000 );
40
43
41
44
.data : {
45
+ HIDDEN (__data_start = .);
46
+
42
47
*(.data .data .*)
43
- } :data
44
48
45
- .dynamic : {
46
- HIDDEN (__dynamic_start = .);
47
- *(.dynamic )
49
+ HIDDEN (__data_end = .);
50
+ HIDDEN (__data_size = . - __data_start);
48
51
}
49
52
50
53
/* BSS section */
51
54
52
- . = ALIGN (0x1000 );
53
-
54
55
.bss : {
55
56
HIDDEN (__bss_start = .);
57
+
56
58
*(.bss .bss .*)
57
59
*(COMMON)
58
- . = ALIGN ( 8 );
60
+
59
61
HIDDEN (__bss_end = .);
60
- } :bss
62
+ HIDDEN (__bss_size = . - __bss_start);
63
+ }
64
+
65
+ /DISCARD/ :
66
+ {
67
+ *(.eh_frame ) /* This is probably unnecessary and bloats the binary. */
68
+ }
61
69
}
Original file line number Diff line number Diff line change
1
+ // For more information on the .nro file form at , see:
2
+ // https://switchbrew.org/wiki/NRO
3
+
1
4
. section .text. jmp , "x"
2
5
. global _start
3
6
_start:
4
7
b start
5
8
. word _mod_header - _start
9
+ . word 0
10
+ . word 0
11
+
12
+ .ascii "NRO0" // magic
13
+ . word 0 // version (always 0 )
14
+ . word __bss_start - _start // total NRO file size
15
+ . word 0 // flags (unused)
16
+
17
+ // segment headers
18
+ . word __text_start
19
+ . word __text_size
20
+ . word __rodata_start
21
+ . word __rodata_size
22
+ . word __data_start
23
+ . word __data_size
24
+ . word __bss_size
25
+ . word 0
26
+
27
+ // ModuleId ( not supported)
28
+ . = 0x50 ; // skip 32 bytes
29
+
30
+ . word 0 // DSO Module Offset (unused)
31
+ . word 0 // reserved (unused)
6
32
7
33
. section .data.mod0
8
34
. word 0 , 8
You can’t perform that action at this time.
0 commit comments