aboutsummaryrefslogtreecommitdiffhomepage
path: root/targets/nintendoswitch.ld
blob: b8e9f5d94bbce83ad791b3c944920a6fe4ac6732 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
PHDRS
{
  text    PT_LOAD FLAGS(5) /* Read | Execute */;
  rodata  PT_LOAD FLAGS(4) /* Read */;
  data    PT_LOAD FLAGS(6) /* Read | Write */;
  bss     PT_LOAD FLAGS(6) /* Read | Write */;
  dynamic PT_DYNAMIC;
}

SECTIONS
{
  /* Code and file header */
  . = 0;

  .text : ALIGN(0x1000) {
    HIDDEN(__text_start = .);
    KEEP(*(.text.jmp))

    . = 0x80;
    KEEP(*(.text.start))

    *(.text .text.*)
    *(.plt .plt.*)

    HIDDEN(__text_end = .);
    HIDDEN(__text_size = . - __text_start);
  }

  /* Read-only sections */
  . = ALIGN(0x1000);

  HIDDEN(__rodata_start = .);
  .rodata : { *(.rodata .rodata.*) }  :rodata

  .mod0 : {
    KEEP(crt0.nso.o(.data.mod0))
    KEEP(crt0.nro.o(.data.mod0))
    KEEP(crt0.lib.nro.o(.data.mod0))
  }

  .dynsym            : { *(.dynsym) } :rodata
  .dynstr            : { *(.dynstr) } :rodata
  .rela.dyn          : { *(.rela.*) } :rodata

  HIDDEN(__rodata_end = .);
  HIDDEN(__rodata_size = . - __rodata_start);

  /* Read-write sections */
  . = ALIGN(0x1000);

  .data : {
    HIDDEN(__data_start = .);

    *(.data .data.*)
    *(.got .got.*)
    *(.got.plt .got.plt.*)

    HIDDEN(__data_end = .);
    HIDDEN(__data_size = . - __data_start);
  } :data

  .dynamic : {
    HIDDEN(__dynamic_start = .);
    *(.dynamic)
  }

  /* BSS section */
  . = ALIGN(0x1000);
  .bss : {
    HIDDEN(__bss_start = .);

    *(.bss .bss.*)
    *(COMMON)
    . = ALIGN(8);

    HIDDEN(__bss_end = .);
    HIDDEN(__bss_size = . - __bss_start);
  } : bss

  /DISCARD/ :
  {
    *(.eh_frame) /* This is probably unnecessary and bloats the binary. */
    *(.eh_frame_hdr)
  }
}