BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / EmbeddedPkg / Scripts / LauterbachT32 / EfiProcessPeImage.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 &filehdrstart &debugdirentryrva &debugtype &debugrva &dwarfsig &baseofcode &baseofdata &elfbase &elfpath &pathoffset\r
14 ENTRY &imgstart\r
15\r
16 &imgstart=&imgstart\r
17 print "PE32 image found at &imgstart"\r
18\r
19 ; offset from dos hdr to PE file hdr\r
20 &filehdrstart=&imgstart+Data.Long(c:&imgstart+0x3C)\r
21\r
22 ; offset to debug dir in PE hdrs\r
23 &debugdirentryrva=Data.Long(c:&filehdrstart+0xA8)\r
24 if &debugdirentryrva==0\r
25 (\r
26 print "no debug dir for image at &imgstart"\r
27 enddo\r
28 )\r
29 \r
30 &debugtype=Data.Long(c:&imgstart+&debugdirentryrva+0xc)\r
31 if (&debugtype!=0xdf)&&(&debugtype!=0x02)\r
32 (\r
33 print "debug type is not dwarf for image at &imgstart, it's &debugtype"\r
34 enddo\r
35 )\r
36 \r
37 &debugrva=Data.Long(c:&imgstart+&debugdirentryrva+0x14)\r
38 &dwarfsig=Data.Long(c:&imgstart+&debugrva)\r
39 \r
40 if &dwarfsig==0x66727764\r
41 (\r
42 &pathoffset=0xc\r
43 )\r
44 else\r
45 (\r
46 if &dwarfsig==0x3031424E\r
47 (\r
48 &pathoffset=0x10\r
49 )\r
50 else\r
51 (\r
52 print "debug signature not found for image at &imgstart, its &dwarfsig"\r
53 enddo\r
54 )\r
55 )\r
56\r
57 &elfpath=Data.String(c:&imgstart+&debugrva+&pathoffset)\r
58\r
59 &baseofcode=&imgstart+Data.Long(c:&filehdrstart+0x28)\r
60 &baseofdata=&imgstart+Data.Long(c:&filehdrstart+0x2c)\r
61 \r
62 if (&baseofcode<&baseofdata)&&(&baseofcode!=0)\r
63 (\r
64 &elfbase=&baseofcode;\r
65 )\r
66 else\r
67 (\r
68 &elfbase=&baseofdata;\r
69 )\r
70\r
71 print "found path &elfpath"\r
72 ON ERROR GOSUB\r
73 return\r
74 data.load.elf &elfpath &elfbase /NOCODE /NOCLEAR\r
75 ON error\r
76\r
77enddo\r