aboutsummaryrefslogtreecommitdiff
path: root/ld/scripttempl/pru.sc
blob: 88fe06cb63b442376278ff1a0725e077c5f0d1d1 (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
cat <<EOF
OUTPUT_FORMAT("${OUTPUT_FORMAT}","${OUTPUT_FORMAT}","${OUTPUT_FORMAT}")
OUTPUT_ARCH(${ARCH})

MEMORY
{
  imem   (x)   : ORIGIN = $TEXT_ORIGIN, LENGTH = $TEXT_LENGTH
  dmem   (rw!x) : ORIGIN = $DATA_ORIGIN, LENGTH = $DATA_LENGTH
}

__HEAP_SIZE = DEFINED(__HEAP_SIZE) ? __HEAP_SIZE : 32;
__STACK_SIZE = DEFINED(__STACK_SIZE) ? __STACK_SIZE : 512;

${RELOCATING+ PROVIDE (_stack_top = ORIGIN(dmem) + LENGTH(dmem)) ; }

${RELOCATING+ENTRY (_start)}

SECTIONS
{
  /* Read-only sections, merged into text segment: */
  ${TEXT_DYNAMIC+${DYNAMIC}}
  .hash        ${RELOCATING-0} : { *(.hash)		}
  .dynsym      ${RELOCATING-0} : { *(.dynsym)		}
  .dynstr      ${RELOCATING-0} : { *(.dynstr)		}
  .gnu.version ${RELOCATING-0} : { *(.gnu.version)	}
  .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d)	}
  .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r)	}

  .rel.init    ${RELOCATING-0} : { *(.rel.init)		}
  .rela.init   ${RELOCATING-0} : { *(.rela.init)	}
  .rel.text    ${RELOCATING-0} :
    {
      *(.rel.text)
      ${RELOCATING+*(.rel.text.*)}
      ${RELOCATING+*(.rel.gnu.linkonce.t*)}
    }
  .rela.text   ${RELOCATING-0} :
    {
      *(.rela.text)
      ${RELOCATING+*(.rela.text.*)}
      ${RELOCATING+*(.rela.gnu.linkonce.t*)}
    }
  .rel.fini    ${RELOCATING-0} : { *(.rel.fini)		}
  .rela.fini   ${RELOCATING-0} : { *(.rela.fini)	}
  .rel.rodata  ${RELOCATING-0} :
    {
      *(.rel.rodata)
      ${RELOCATING+*(.rel.rodata.*)}
      ${RELOCATING+*(.rel.gnu.linkonce.r*)}
    }
  .rela.rodata ${RELOCATING-0} :
    {
      *(.rela.rodata)
      ${RELOCATING+*(.rela.rodata.*)}
      ${RELOCATING+*(.rela.gnu.linkonce.r*)}
    }
  .rel.data    ${RELOCATING-0} :
    {
      *(.rel.data)
      ${RELOCATING+*(.rel.data.*)}
      ${RELOCATING+*(.rel.gnu.linkonce.d*)}
    }
  .rela.data   ${RELOCATING-0} :
    {
      *(.rela.data)
      ${RELOCATING+*(.rela.data.*)}
      ${RELOCATING+*(.rela.gnu.linkonce.d*)}
    }
  .rel.ctors   ${RELOCATING-0} : { *(.rel.ctors)	}
  .rela.ctors  ${RELOCATING-0} : { *(.rela.ctors)	}
  .rel.dtors   ${RELOCATING-0} : { *(.rel.dtors)	}
  .rela.dtors  ${RELOCATING-0} : { *(.rela.dtors)	}
  .rel.got     ${RELOCATING-0} : { *(.rel.got)		}
  .rela.got    ${RELOCATING-0} : { *(.rela.got)		}
  .rel.bss     ${RELOCATING-0} : { *(.rel.bss)		}
  .rela.bss    ${RELOCATING-0} : { *(.rela.bss)		}
  .rel.plt     ${RELOCATING-0} : { *(.rel.plt)		}
  .rela.plt    ${RELOCATING-0} : { *(.rela.plt)		}

  /* Internal text space.  */
  .text ${RELOCATING-0} :
  {
    ${RELOCATING+ _text_start = . ; }

    ${RELOCATING+. = ALIGN(4);}

    ${RELOCATING+*(.init0)  /* Start here after reset.  */}
    ${RELOCATING+KEEP (*(.init0))}

    ${RELOCATING+. = ALIGN(4);}
    *(.text)
    ${RELOCATING+. = ALIGN(4);}
    ${RELOCATING+*(.text.*)}
    ${RELOCATING+. = ALIGN(4);}
    ${RELOCATING+*(.gnu.linkonce.t*)}
    ${RELOCATING+. = ALIGN(4);}

    ${RELOCATING+ _text_end = . ; }
  } ${RELOCATING+ > imem}

  .data        ${RELOCATING-0} :
  {
    /* Optional variable that user is prepared to have NULL address.  */
    ${RELOCATING+ *(.data.atzero*)}

    /* CRT is prepared for constructor/destructor table to have
       a "valid" NULL address.  */
    ${CONSTRUCTING+ _ctors_start = . ; }
    ${CONSTRUCTING+ KEEP (*(SORT_BY_INIT_PRIORITY(.ctors.*)))}
    ${CONSTRUCTING+ KEEP (*(.ctors))}
    ${CONSTRUCTING+ _ctors_end = . ; }
    ${CONSTRUCTING+ _dtors_start = . ; }
    ${CONSTRUCTING+ KEEP (*(SORT_BY_INIT_PRIORITY(.dtors.*)))}
    ${CONSTRUCTING+ KEEP (*(.dtors))}
    ${CONSTRUCTING+ _dtors_end = . ; }

    /* DATA memory starts at address 0.  So to avoid placing a valid static
       variable at the invalid NULL address, we introduce the .data.atzero
       section.  If CRT can make some use of it - great.  Otherwise skip a
       word.  In all cases .data/.bss sections must start at non-zero.  */
    . += (. == 0 ? 4 : 0);

    ${RELOCATING+ PROVIDE (_data_start = .) ; }
    *(.data)
    ${RELOCATING+ *(.data*)}
    ${RELOCATING+ *(.rodata)  /* We need to include .rodata here if gcc is used.  */}
    ${RELOCATING+ *(.rodata.*) /* with -fdata-sections.  */}
    ${RELOCATING+*(.gnu.linkonce.d*)}
    ${RELOCATING+*(.gnu.linkonce.r*)}
    ${RELOCATING+. = ALIGN(4);}
    ${RELOCATING+ PROVIDE (_data_end = .) ; }
  } ${RELOCATING+ > dmem }

  .resource_table ${RELOCATING-0} :
  {
    *(.resource_table)
    KEEP (*(.resource_table))
  }  > dmem

  .bss ${RELOCATING-0} :
  {
    ${RELOCATING+ PROVIDE (_bss_start = .) ; }
    *(.bss)
    ${RELOCATING+ *(.bss.*)}
    ${RELOCATING+*(.gnu.linkonce.b*)}
    *(COMMON)
    ${RELOCATING+ PROVIDE (_bss_end = .) ; }
  } ${RELOCATING+ > dmem}

  /* Global data not cleared after reset.  */
  .noinit ${RELOCATING-0}:
  {
    ${RELOCATING+ PROVIDE (_noinit_start = .) ; }
    *(.noinit)
    ${RELOCATING+ PROVIDE (_noinit_end = .) ; }
    ${RELOCATING+ PROVIDE (_heap_start = .) ; }
    ${RELOCATING+ . += __HEAP_SIZE ; }
    /* Stack is not here really.  It will be put at the end of DMEM.
       But we take into account its size here, in order to allow
       for MEMORY overflow checking during link time.  */
    ${RELOCATING+ . += __STACK_SIZE ; }
  } ${RELOCATING+ > dmem}

  /* Stabs debugging sections.  */
  .stab 0 : { *(.stab) }
  .stabstr 0 : { *(.stabstr) }
  .stab.excl 0 : { *(.stab.excl) }
  .stab.exclstr 0 : { *(.stab.exclstr) }
  .stab.index 0 : { *(.stab.index) }
  .stab.indexstr 0 : { *(.stab.indexstr) }
  .comment 0 : { *(.comment) }
  .note.gnu.build-id : { *(.note.gnu.build-id) }
EOF

. $srcdir/scripttempl/DWARF.sc

cat <<EOF
}
EOF