--- /dev/null
+;\r
+; Copyright (c) 2011, Hewlett-Packard Company. All rights reserved.<BR>\r
+; \r
+; This program and the accompanying materials \r
+; are licensed and made available under the terms and conditions of the BSD License \r
+; which accompanies this distribution. The full text of the license may be found at \r
+; http://opensource.org/licenses/bsd-license.php \r
+; \r
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+; \r
+\r
+ LOCAL &imgstart &filehdrstart &debugdirentryrva &debugtype &debugrva &dwarfsig &baseofcode &baseofdata &elfbase &elfpath &pathoffset\r
+ ENTRY &imgstart\r
+\r
+ &imgstart=&imgstart\r
+ print "PE32 image found at &imgstart"\r
+\r
+ ; offset from dos hdr to PE file hdr\r
+ &filehdrstart=&imgstart+Data.Long(c:&imgstart+0x3C)\r
+\r
+ ; offset to debug dir in PE hdrs\r
+ &debugdirentryrva=Data.Long(c:&filehdrstart+0xA8)\r
+ if &debugdirentryrva==0\r
+ (\r
+ print "no debug dir for image at &imgstart"\r
+ enddo\r
+ )\r
+ \r
+ &debugtype=Data.Long(c:&imgstart+&debugdirentryrva+0xc)\r
+ if (&debugtype!=0xdf)&&(&debugtype!=0x02)\r
+ (\r
+ print "debug type is not dwarf for image at &imgstart, it's &debugtype"\r
+ enddo\r
+ )\r
+ \r
+ &debugrva=Data.Long(c:&imgstart+&debugdirentryrva+0x14)\r
+ &dwarfsig=Data.Long(c:&imgstart+&debugrva)\r
+ \r
+ if &dwarfsig==0x66727764\r
+ (\r
+ &pathoffset=0xc\r
+ )\r
+ else\r
+ (\r
+ if &dwarfsig==0x3031424E\r
+ (\r
+ &pathoffset=0x10\r
+ )\r
+ else\r
+ (\r
+ print "debug signature not found for image at &imgstart, its &dwarfsig"\r
+ enddo\r
+ )\r
+ )\r
+\r
+ &elfpath=Data.String(c:&imgstart+&debugrva+&pathoffset)\r
+\r
+ &baseofcode=&imgstart+Data.Long(c:&filehdrstart+0x28)\r
+ &baseofdata=&imgstart+Data.Long(c:&filehdrstart+0x2c)\r
+ \r
+ if (&baseofcode<&baseofdata)&&(&baseofcode!=0)\r
+ (\r
+ &elfbase=&baseofcode;\r
+ )\r
+ else\r
+ (\r
+ &elfbase=&baseofdata;\r
+ )\r
+\r
+ print "found path &elfpath"\r
+ ON ERROR GOSUB\r
+ return\r
+ data.load.elf &elfpath &elfbase /NOCODE /NOCLEAR\r
+ ON error\r
+\r
+enddo\r