BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / EmbeddedPkg / Scripts / LauterbachT32 / EfiProcessTeImage.cmm
CommitLineData
98790d81 1;\r
2; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>\r
3; \r
4; This program and the accompanying materials \r
5; are licensed and made available under the terms and conditions of the BSD License \r
6; which accompanies this distribution. The full text of the license may be found at \r
7; http://opensource.org/licenses/bsd-license.php \r
8; \r
9; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11; \r
12\r
13 LOCAL &imgstart &strippedsize &debugdirentryrva &debugtype &debugrva &dwarfsig &elfbase &elfpath &pathoffset\r
14 ENTRY &imgstart\r
15 \r
16 &imgstart=&imgstart\r
17 print "TE image found at &imgstart"\r
18\r
19 ; determine pe header bytes removed to account for in rva references\r
20 &strippedsize=(Data.Long(a:&imgstart+0x4)&0xffff0000)>>16.\r
21 &strippedsize=&strippedsize-0x28\r
22\r
23 &debugdirentryrva=Data.Long(a:&imgstart+0x20)\r
24 if &debugdirentryrva==0\r
25 (\r
26 print "no debug dir for image at &imgstart"\r
27 enddo\r
28 )\r
29 &debugdirentryrva=&debugdirentryrva-&strippedsize\r
30\r
31 &debugtype=Data.Long(a:&imgstart+&debugdirentryrva+0xc)\r
32 if (&debugtype!=0xdf)&&(&debugtype!=0x02)\r
33 (\r
34 print "debug type is not dwarf for image at &imgstart, it's &debugtype"\r
35 enddo\r
36 )\r
37 \r
38 &debugrva=Data.Long(a:&imgstart+&debugdirentryrva+0x14)\r
39 &debugrva=&debugrva-&strippedsize;\r
40 &dwarfsig=Data.Long(a:&imgstart+&debugrva);\r
41 if &dwarfsig==0x66727764\r
42 (\r
43 &pathoffset=0xc\r
44 )\r
45 else\r
46 (\r
47 if &dwarfsig==0x3031424E\r
48 (\r
49 &pathoffset=0x10\r
50 )\r
51 else\r
52 (\r
53 print "debug signature not found for image at &imgstart, its &dwarfsig"\r
54 enddo\r
55 )\r
56 )\r
57\r
58 &elfpath=Data.String(c:&imgstart+&debugrva+&pathoffset)\r
59\r
60 ; elf base is baseofcode (we hope that for TE images it's not baseofdata)\r
61 &elfbase=&imgstart+Data.Long(a:&imgstart+0xc)-&strippedsize\r
62\r
63 print "found path &elfpath"\r
64 ; $fprintf 50, "load /ni /np /a %s &0x%x\n",elfpath,elfbase$;\r
65 ON ERROR GOSUB\r
66 return\r
67 data.load.elf &elfpath &elfbase /NOCODE /NOCLEAR\r
68 ON error\r
69\r
70enddo\r