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 &strippedsize &debugdirentryrva &debugtype &debugrva &dwarfsig &elfbase &elfpath &pathoffset
17 print "TE image found at &imgstart"
19 ; determine pe header bytes removed to account for in rva references
20 &strippedsize=(Data.Long(a:&imgstart+0x4)&0xffff0000)>>16.
21 &strippedsize=&strippedsize-0x28
23 &debugdirentryrva=Data.Long(a:&imgstart+0x20)
24 if &debugdirentryrva==0
26 print "no debug dir for image at &imgstart"
29 &debugdirentryrva=&debugdirentryrva-&strippedsize
31 &debugtype=Data.Long(a:&imgstart+&debugdirentryrva+0xc)
32 if (&debugtype!=0xdf)&&(&debugtype!=0x02)
34 print "debug type is not dwarf for image at &imgstart, it's &debugtype"
38 &debugrva=Data.Long(a:&imgstart+&debugdirentryrva+0x14)
39 &debugrva=&debugrva-&strippedsize;
40 &dwarfsig=Data.Long(a:&imgstart+&debugrva);
41 if &dwarfsig==0x66727764
47 if &dwarfsig==0x3031424E
53 print "debug signature not found for image at &imgstart, its &dwarfsig"
58 &elfpath=Data.String(c:&imgstart+&debugrva+&pathoffset)
60 ; elf base is baseofcode (we hope that for TE images it's not baseofdata)
61 &elfbase=&imgstart+Data.Long(a:&imgstart+0xc)-&strippedsize
63 print "found path &elfpath"
64 ; $fprintf 50, "load /ni /np /a %s &0x%x\n",elfpath,elfbase$;
67 data.load.elf &elfpath &elfbase /NOCODE /NOCLEAR