BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / EmbeddedPkg / Scripts / LauterbachT32 / EfiProcessTeImage.cmm
1 ;
2 ; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>
3 ;
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
8 ;
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.
11 ;
12
13 LOCAL &imgstart &strippedsize &debugdirentryrva &debugtype &debugrva &dwarfsig &elfbase &elfpath &pathoffset
14 ENTRY &imgstart
15
16 &imgstart=&imgstart
17 print "TE image found at &imgstart"
18
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
22
23 &debugdirentryrva=Data.Long(a:&imgstart+0x20)
24 if &debugdirentryrva==0
25 (
26 print "no debug dir for image at &imgstart"
27 enddo
28 )
29 &debugdirentryrva=&debugdirentryrva-&strippedsize
30
31 &debugtype=Data.Long(a:&imgstart+&debugdirentryrva+0xc)
32 if (&debugtype!=0xdf)&&(&debugtype!=0x02)
33 (
34 print "debug type is not dwarf for image at &imgstart, it's &debugtype"
35 enddo
36 )
37
38 &debugrva=Data.Long(a:&imgstart+&debugdirentryrva+0x14)
39 &debugrva=&debugrva-&strippedsize;
40 &dwarfsig=Data.Long(a:&imgstart+&debugrva);
41 if &dwarfsig==0x66727764
42 (
43 &pathoffset=0xc
44 )
45 else
46 (
47 if &dwarfsig==0x3031424E
48 (
49 &pathoffset=0x10
50 )
51 else
52 (
53 print "debug signature not found for image at &imgstart, its &dwarfsig"
54 enddo
55 )
56 )
57
58 &elfpath=Data.String(c:&imgstart+&debugrva+&pathoffset)
59
60 ; elf base is baseofcode (we hope that for TE images it's not baseofdata)
61 &elfbase=&imgstart+Data.Long(a:&imgstart+0xc)-&strippedsize
62
63 print "found path &elfpath"
64 ; $fprintf 50, "load /ni /np /a %s &0x%x\n",elfpath,elfbase$;
65 ON ERROR GOSUB
66 return
67 data.load.elf &elfpath &elfbase /NOCODE /NOCLEAR
68 ON error
69
70 enddo