2 ; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
4 ; This program and the accompanying materials
5 ; are licensed and made available under the terms and conditions of the BSD License
6 ; which accompanies this distribution. The full text of the license may be found at
7 ; http://opensource.org/licenses/bsd-license.php
9 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 LOCAL &imgstart &filehdrstart &debugdirentryrva &debugtype &debugrva &dwarfsig &baseofcode &baseofdata &elfbase &elfpath &pathoffset
17 print "PE32 image found at &imgstart"
19 ; offset from dos hdr to PE file hdr
20 &filehdrstart=&imgstart+Data.Long(c:&imgstart+0x3C)
22 ; offset to debug dir in PE hdrs
23 &debugdirentryrva=Data.Long(c:&filehdrstart+0xA8)
24 if &debugdirentryrva==0
26 print "no debug dir for image at &imgstart"
30 &debugtype=Data.Long(c:&imgstart+&debugdirentryrva+0xc)
31 if (&debugtype!=0xdf)&&(&debugtype!=0x02)
33 print "debug type is not dwarf for image at &imgstart, it's &debugtype"
37 &debugrva=Data.Long(c:&imgstart+&debugdirentryrva+0x14)
38 &dwarfsig=Data.Long(c:&imgstart+&debugrva)
40 if &dwarfsig==0x66727764
46 if &dwarfsig==0x3031424E
52 print "debug signature not found for image at &imgstart, its &dwarfsig"
57 &elfpath=Data.String(c:&imgstart+&debugrva+&pathoffset)
59 &baseofcode=&imgstart+Data.Long(c:&filehdrstart+0x28)
60 &baseofdata=&imgstart+Data.Long(c:&filehdrstart+0x2c)
62 if (&baseofcode<&baseofdata)&&(&baseofcode!=0)
71 print "found path &elfpath"
74 data.load.elf &elfpath &elfbase /NOCODE /NOCLEAR