blob: d7a617afd22b18d09f66ddc2a839a0691cc81ab1 (
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
//
// Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
// which accompanies this distribution. The full text of the license may be found at
// http://opensource.org/licenses/bsd-license.php
//
// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
ENTRY &ram_start &ram_size
;If system is running then stop the execution so we can load symbols.
break
;Reset all windows
WINPAGE.RESET
;Create AREA to display the symbols we are loading.
AREA.Reset
AREA.Create SYMBOL 300. 100.
AREA.View SYMBOL
AREA.Select SYMBOL
SYS.Option BE OFF
;Added based on suggestion from Lauterbach support.
MMU.TABLEWALK ON
MMU.ON
;Load symbols.
GOSUB load_symbols &ram_start &ram_size
;Open some windows and enable semihosting.
TOOLBAR ON
STATUSBAR ON
WINPAGE.RESET
WINCLEAR
WINPOS 0.0 17.0 72. 13. 0. 0. W000
SYStem
WINPOS 0.0 0.0 110. 55. 13. 1. W001
WINTABS 10. 10. 25. 62.
Data.List
WINPAGE.SELECT P000
//Enable semihosting
System.Option.BigEndian OFF
tronchip.set swi on // ARM9/10/11 variant
// configure and open semihosting channel
winpos 50% 50% 50% 50%
term.heapinfo 0 0x20000 0x30000 0x20000
term.method armswi
term.mode string
term.gate
WINPOS 115.0 0. 70. 35. 0. 1. W002
Var.Local %HEX
WINPOS 115.10 45. 48. 9. 0. 0. W003
Register
END
find_system_table:
ENTRY &mem_start &mem_size
&mem_ptr=&mem_start+&mem_size
RPT
(
&mem_ptr=&mem_ptr-0x400000 // 4 MB
&word1=Data.LONG(D:&mem_ptr)
&word2=Data.LONG(D:&mem_ptr+0x04)
IF &word1==0x20494249
(
IF &word2==0x54535953
(
&result=Data.LONG(D:&mem_ptr+0x08)
RETURN &result
)
)
)
WHILE &mem_ptr>&mem_start
&result=0
RETURN &result
compare_guid:
ENTRY &guid
IF Data.LONG(D:&guid)==0x49152E77
(
IF Data.LONG(D:&guid+0x04)==0x47641ADA
(
IF Data.LONG(D:&guid+0x08)==0xFE7AA2B7
(
IF Data.LONG(D:&guid+0x0C)==0x8B5ED9FE
(
RETURN 0
)
)
)
)
RETURN 1
find_debug_info_table_header:
ENTRY &system_table
&config_table_entries=Data.LONG(D:&system_table+0x40)
&config_table_pointer=Data.LONG(D:&system_table+0x44)
RPT &config_table_entries
(
GOSUB compare_guid &config_table_pointer
ENTRY &result
IF &result==0
(
&result=Data.LONG(D:&config_table_pointer+0x10)
RETURN &result
)
&config_table_pointer=&config_table_pointer+0x14
)
RETURN 0;
valid_pe_header:
ENTRY &header
IF Data.BYTE(D:&header+0x00)==0x4D
(
IF Data.BYTE(D:&header+0x01)==0x5A
(
IF Data.BYTE(D:&header+0x80)==0x50
(
IF Data.BYTE(D:&header+0x81)==0x45
(
RETURN 1
)
)
)
)
RETURN 0
get_file_string:
ENTRY &stringOffset
local &string
&more_string=data.string(d:&stringOffset)
if (string.len("&more_string")>=128.)
(
&string="&string"+"&more_string"
&stringOffset=&stringOffset+string.len("&more_string")
//Get remaining file string
GOSUB get_file_string &stringOffset
ENTRY &more_string
&string="&string"+"&more_string"
)
else
(
&string="&string"+"&more_string"
&more_string=""
)
RETURN &string
load_symbol_file:
ENTRY &header &load_address
GOSUB valid_pe_header &header
ENTRY &result
IF &result==1
(
&debugOffset=Data.LONG(D:&header+0x0128)
&stringOffset=&header+&debugOffset+0x002C
GOSUB get_file_string &stringOffset
ENTRY &filestring
PRINT "&filestring 0x" &load_address
TDIAG Data.load.elf &filestring &load_address /nocode /noclear
)
RETURN
pe_headersize:
ENTRY &header;
RETURN Data.LONG(D:&header+0x00AC)
load_symbols:
ENTRY &mem_start &mem_size
GOSUB find_system_table &mem_start &mem_size
ENTRY &system_table
GOSUB find_debug_info_table_header &system_table
ENTRY &debug_info_table_header
&debug_info_table=Data.LONG(D:&debug_info_table_header+0x08)
&debug_info_table_size=Data.LONG(D:&debug_info_table_header+0x04)
&index=0
RPT &debug_info_table_size
(
&debug_image_info=Data.LONG(D:&debug_info_table+&index)
IF &debug_image_info==0
RETURN
&loaded_image_protocol=Data.LONG(D:&debug_image_info+0x04);
&image_base=Data.LONG(D:&loaded_image_protocol+0x20);
GOSUB pe_headersize &image_base
ENTRY &header_size
&image_load_address=&image_base+&header_size
GOSUB load_symbol_file &image_base &image_load_address
&index=&index+0x4
)
RETURN
|