muta...@gmail.com
2022-12-09 11:22:17 UTC
I have 32-bit Cygwin and I tried using a slightly
modified gcc 3.2.3 built with TARGET_64BIT
and binutils 2.22 targeting x86_64-unknown-pe
and was wondering whether a purely 32-bit
toolchain could create a 64-bit executable.
I didn't have high hopes, but I was surprised to
find that I seem to have a valid 64-bit executable.
I have been through most, but not all the bytes,
checking against the documentation, and it looks
correct to me.
I created a simple program that just did a "return 5".
My real intention is to make it an EFI bootloader,
but I have tried it as a normal Windows 64-bit
program, and Windows rejects it, saying that it
can't run on my Windows 10 64-bit system.
Can anyone see anything wrong with the below?
Here's the entire code:
000400 B8050000 00C3
C:\devel\test>type efistart.s
.file "efistart.c"
.text
.align 4
.globl _efimain
_efimain:
LFB1:
movl $5, %eax
ret
LFE1:
Thanks. Paul.
000000 4D5A9000 03000000 04000000 FFFF0000 MZ..............
000010 B8000000 00000000 40000000 00000000 ***@.......
000020 00000000 00000000 00000000 00000000 ................
000030 00000000 00000000 00000000 80000000 ................
000040 0E1FBA0E 00B409CD 21B8014C CD215468 ........!..L.!Th
000050 69732070 726F6772 616D2063 616E6E6F is program canno
000060 74206265 2072756E 20696E20 444F5320 t be run in DOS
000070 6D6F6465 2E0D0D0A 24000000 00000000 mode....$.......
000080 50450000 64860300 E0079363 00000000 PE..d......c....
000090 00000000 F0002E22 0B020216 00020000 ......."........
0000A0 00040000 00000000 00100000 00100000 ................
0000B0 00000010 00000000 00100000 00020000 ................
0000C0 04000000 00000000 05000200 00000000 ................
0000D0 00400000 00040000 F8360000 03000000 ***@.......6......
0000E0 00002000 00000000 00100000 00000000 .. .............
0000F0 00001000 00000000 00100000 00000000 ................
000100 00000000 10000000 00200000 47000000 ......... ..G...
000110 00300000 14000000 00000000 00000000 .0..............
000120 00000000 00000000 00000000 00000000 ................
000130 00000000 00000000 00000000 00000000 ................
000140 00000000 00000000 00000000 00000000 ................
000150 00000000 00000000 00000000 00000000 ................
000160 00000000 00000000 00000000 00000000 ................
000170 00000000 00000000 00000000 00000000 ................
000180 00000000 00000000 2E746578 74000000 .........text...
000190 30000000 00100000 00020000 00040000 0...............
0001A0 00000000 00000000 00000000 20005060 ............ .P`
0001B0 2E656461 74610000 47000000 00200000 .edata..G.... ..
0001C0 00020000 00060000 00000000 00000000 ................
0001D0 00000000 40003040 2E696461 74610000 ***@.0@.idata..
0001E0 14000000 00300000 00020000 00080000 .....0..........
0001F0 00000000 00000000 00000000 400030C0 ***@.0.
000200 00000000 00000000 00000000 00000000 ................
000210 00000000 00000000 00000000 00000000 ................
000220 00000000 00000000 00000000 00000000 ................
000230 00000000 00000000 00000000 00000000 ................
000240 00000000 00000000 00000000 00000000 ................
000250 00000000 00000000 00000000 00000000 ................
000260 00000000 00000000 00000000 00000000 ................
000270 00000000 00000000 00000000 00000000 ................
000280 00000000 00000000 00000000 00000000 ................
000290 00000000 00000000 00000000 00000000 ................
0002A0 00000000 00000000 00000000 00000000 ................
0002B0 00000000 00000000 00000000 00000000 ................
0002C0 00000000 00000000 00000000 00000000 ................
0002D0 00000000 00000000 00000000 00000000 ................
0002E0 00000000 00000000 00000000 00000000 ................
0002F0 00000000 00000000 00000000 00000000 ................
000300 00000000 00000000 00000000 00000000 ................
000310 00000000 00000000 00000000 00000000 ................
000320 00000000 00000000 00000000 00000000 ................
000330 00000000 00000000 00000000 00000000 ................
000340 00000000 00000000 00000000 00000000 ................
000350 00000000 00000000 00000000 00000000 ................
000360 00000000 00000000 00000000 00000000 ................
000370 00000000 00000000 00000000 00000000 ................
000380 00000000 00000000 00000000 00000000 ................
000390 00000000 00000000 00000000 00000000 ................
0003A0 00000000 00000000 00000000 00000000 ................
0003B0 00000000 00000000 00000000 00000000 ................
0003C0 00000000 00000000 00000000 00000000 ................
0003D0 00000000 00000000 00000000 00000000 ................
0003E0 00000000 00000000 00000000 00000000 ................
0003F0 00000000 00000000 00000000 00000000 ................
000400 B8050000 00C39090 90909090 90909090 ................
000410 FFFFFFFF FFFFFFFF 00000000 00000000 ................
000420 FFFFFFFF FFFFFFFF 00000000 00000000 ................
000430 00000000 00000000 00000000 00000000 ................
000440 00000000 00000000 00000000 00000000 ................
000450 00000000 00000000 00000000 00000000 ................
000460 00000000 00000000 00000000 00000000 ................
000470 00000000 00000000 00000000 00000000 ................
000480 00000000 00000000 00000000 00000000 ................
000490 00000000 00000000 00000000 00000000 ................
0004A0 00000000 00000000 00000000 00000000 ................
0004B0 00000000 00000000 00000000 00000000 ................
0004C0 00000000 00000000 00000000 00000000 ................
0004D0 00000000 00000000 00000000 00000000 ................
0004E0 00000000 00000000 00000000 00000000 ................
0004F0 00000000 00000000 00000000 00000000 ................
000500 00000000 00000000 00000000 00000000 ................
000510 00000000 00000000 00000000 00000000 ................
000520 00000000 00000000 00000000 00000000 ................
000530 00000000 00000000 00000000 00000000 ................
000540 00000000 00000000 00000000 00000000 ................
000550 00000000 00000000 00000000 00000000 ................
000560 00000000 00000000 00000000 00000000 ................
000570 00000000 00000000 00000000 00000000 ................
000580 00000000 00000000 00000000 00000000 ................
000590 00000000 00000000 00000000 00000000 ................
0005A0 00000000 00000000 00000000 00000000 ................
0005B0 00000000 00000000 00000000 00000000 ................
0005C0 00000000 00000000 00000000 00000000 ................
0005D0 00000000 00000000 00000000 00000000 ................
0005E0 00000000 00000000 00000000 00000000 ................
0005F0 00000000 00000000 00000000 00000000 ................
000600 00000000 E0079363 00000000 32200000 .......c....2 ..
000610 01000000 01000000 01000000 28200000 ............( ..
000620 2C200000 30200000 00100000 3E200000 , ..0 ......> ..
000630 00007064 70746573 742E6578 65005F65 ..pdptest.exe._e
000640 66696D61 696E0000 00000000 00000000 fimain..........
000650 00000000 00000000 00000000 00000000 ................
000660 00000000 00000000 00000000 00000000 ................
000670 00000000 00000000 00000000 00000000 ................
000680 00000000 00000000 00000000 00000000 ................
000690 00000000 00000000 00000000 00000000 ................
0006A0 00000000 00000000 00000000 00000000 ................
0006B0 00000000 00000000 00000000 00000000 ................
0006C0 00000000 00000000 00000000 00000000 ................
0006D0 00000000 00000000 00000000 00000000 ................
0006E0 00000000 00000000 00000000 00000000 ................
0006F0 00000000 00000000 00000000 00000000 ................
000700 00000000 00000000 00000000 00000000 ................
000710 00000000 00000000 00000000 00000000 ................
000720 00000000 00000000 00000000 00000000 ................
000730 00000000 00000000 00000000 00000000 ................
000740 00000000 00000000 00000000 00000000 ................
000750 00000000 00000000 00000000 00000000 ................
000760 00000000 00000000 00000000 00000000 ................
000770 00000000 00000000 00000000 00000000 ................
000780 00000000 00000000 00000000 00000000 ................
000790 00000000 00000000 00000000 00000000 ................
0007A0 00000000 00000000 00000000 00000000 ................
0007B0 00000000 00000000 00000000 00000000 ................
0007C0 00000000 00000000 00000000 00000000 ................
0007D0 00000000 00000000 00000000 00000000 ................
0007E0 00000000 00000000 00000000 00000000 ................
0007F0 00000000 00000000 00000000 00000000 ................
000800 00000000 00000000 00000000 00000000 ................
000810 00000000 00000000 00000000 00000000 ................
000820 00000000 00000000 00000000 00000000 ................
000830 00000000 00000000 00000000 00000000 ................
000840 00000000 00000000 00000000 00000000 ................
000850 00000000 00000000 00000000 00000000 ................
000860 00000000 00000000 00000000 00000000 ................
000870 00000000 00000000 00000000 00000000 ................
000880 00000000 00000000 00000000 00000000 ................
000890 00000000 00000000 00000000 00000000 ................
0008A0 00000000 00000000 00000000 00000000 ................
0008B0 00000000 00000000 00000000 00000000 ................
0008C0 00000000 00000000 00000000 00000000 ................
0008D0 00000000 00000000 00000000 00000000 ................
0008E0 00000000 00000000 00000000 00000000 ................
0008F0 00000000 00000000 00000000 00000000 ................
000900 00000000 00000000 00000000 00000000 ................
000910 00000000 00000000 00000000 00000000 ................
000920 00000000 00000000 00000000 00000000 ................
000930 00000000 00000000 00000000 00000000 ................
000940 00000000 00000000 00000000 00000000 ................
000950 00000000 00000000 00000000 00000000 ................
000960 00000000 00000000 00000000 00000000 ................
000970 00000000 00000000 00000000 00000000 ................
000980 00000000 00000000 00000000 00000000 ................
000990 00000000 00000000 00000000 00000000 ................
0009A0 00000000 00000000 00000000 00000000 ................
0009B0 00000000 00000000 00000000 00000000 ................
0009C0 00000000 00000000 00000000 00000000 ................
0009D0 00000000 00000000 00000000 00000000 ................
0009E0 00000000 00000000 00000000 00000000 ................
0009F0 00000000 00000000 00000000 00000000 ................
modified gcc 3.2.3 built with TARGET_64BIT
and binutils 2.22 targeting x86_64-unknown-pe
and was wondering whether a purely 32-bit
toolchain could create a 64-bit executable.
I didn't have high hopes, but I was surprised to
find that I seem to have a valid 64-bit executable.
I have been through most, but not all the bytes,
checking against the documentation, and it looks
correct to me.
I created a simple program that just did a "return 5".
My real intention is to make it an EFI bootloader,
but I have tried it as a normal Windows 64-bit
program, and Windows rejects it, saying that it
can't run on my Windows 10 64-bit system.
Can anyone see anything wrong with the below?
Here's the entire code:
000400 B8050000 00C3
C:\devel\test>type efistart.s
.file "efistart.c"
.text
.align 4
.globl _efimain
_efimain:
LFB1:
movl $5, %eax
ret
LFE1:
Thanks. Paul.
000000 4D5A9000 03000000 04000000 FFFF0000 MZ..............
000010 B8000000 00000000 40000000 00000000 ***@.......
000020 00000000 00000000 00000000 00000000 ................
000030 00000000 00000000 00000000 80000000 ................
000040 0E1FBA0E 00B409CD 21B8014C CD215468 ........!..L.!Th
000050 69732070 726F6772 616D2063 616E6E6F is program canno
000060 74206265 2072756E 20696E20 444F5320 t be run in DOS
000070 6D6F6465 2E0D0D0A 24000000 00000000 mode....$.......
000080 50450000 64860300 E0079363 00000000 PE..d......c....
000090 00000000 F0002E22 0B020216 00020000 ......."........
0000A0 00040000 00000000 00100000 00100000 ................
0000B0 00000010 00000000 00100000 00020000 ................
0000C0 04000000 00000000 05000200 00000000 ................
0000D0 00400000 00040000 F8360000 03000000 ***@.......6......
0000E0 00002000 00000000 00100000 00000000 .. .............
0000F0 00001000 00000000 00100000 00000000 ................
000100 00000000 10000000 00200000 47000000 ......... ..G...
000110 00300000 14000000 00000000 00000000 .0..............
000120 00000000 00000000 00000000 00000000 ................
000130 00000000 00000000 00000000 00000000 ................
000140 00000000 00000000 00000000 00000000 ................
000150 00000000 00000000 00000000 00000000 ................
000160 00000000 00000000 00000000 00000000 ................
000170 00000000 00000000 00000000 00000000 ................
000180 00000000 00000000 2E746578 74000000 .........text...
000190 30000000 00100000 00020000 00040000 0...............
0001A0 00000000 00000000 00000000 20005060 ............ .P`
0001B0 2E656461 74610000 47000000 00200000 .edata..G.... ..
0001C0 00020000 00060000 00000000 00000000 ................
0001D0 00000000 40003040 2E696461 74610000 ***@.0@.idata..
0001E0 14000000 00300000 00020000 00080000 .....0..........
0001F0 00000000 00000000 00000000 400030C0 ***@.0.
000200 00000000 00000000 00000000 00000000 ................
000210 00000000 00000000 00000000 00000000 ................
000220 00000000 00000000 00000000 00000000 ................
000230 00000000 00000000 00000000 00000000 ................
000240 00000000 00000000 00000000 00000000 ................
000250 00000000 00000000 00000000 00000000 ................
000260 00000000 00000000 00000000 00000000 ................
000270 00000000 00000000 00000000 00000000 ................
000280 00000000 00000000 00000000 00000000 ................
000290 00000000 00000000 00000000 00000000 ................
0002A0 00000000 00000000 00000000 00000000 ................
0002B0 00000000 00000000 00000000 00000000 ................
0002C0 00000000 00000000 00000000 00000000 ................
0002D0 00000000 00000000 00000000 00000000 ................
0002E0 00000000 00000000 00000000 00000000 ................
0002F0 00000000 00000000 00000000 00000000 ................
000300 00000000 00000000 00000000 00000000 ................
000310 00000000 00000000 00000000 00000000 ................
000320 00000000 00000000 00000000 00000000 ................
000330 00000000 00000000 00000000 00000000 ................
000340 00000000 00000000 00000000 00000000 ................
000350 00000000 00000000 00000000 00000000 ................
000360 00000000 00000000 00000000 00000000 ................
000370 00000000 00000000 00000000 00000000 ................
000380 00000000 00000000 00000000 00000000 ................
000390 00000000 00000000 00000000 00000000 ................
0003A0 00000000 00000000 00000000 00000000 ................
0003B0 00000000 00000000 00000000 00000000 ................
0003C0 00000000 00000000 00000000 00000000 ................
0003D0 00000000 00000000 00000000 00000000 ................
0003E0 00000000 00000000 00000000 00000000 ................
0003F0 00000000 00000000 00000000 00000000 ................
000400 B8050000 00C39090 90909090 90909090 ................
000410 FFFFFFFF FFFFFFFF 00000000 00000000 ................
000420 FFFFFFFF FFFFFFFF 00000000 00000000 ................
000430 00000000 00000000 00000000 00000000 ................
000440 00000000 00000000 00000000 00000000 ................
000450 00000000 00000000 00000000 00000000 ................
000460 00000000 00000000 00000000 00000000 ................
000470 00000000 00000000 00000000 00000000 ................
000480 00000000 00000000 00000000 00000000 ................
000490 00000000 00000000 00000000 00000000 ................
0004A0 00000000 00000000 00000000 00000000 ................
0004B0 00000000 00000000 00000000 00000000 ................
0004C0 00000000 00000000 00000000 00000000 ................
0004D0 00000000 00000000 00000000 00000000 ................
0004E0 00000000 00000000 00000000 00000000 ................
0004F0 00000000 00000000 00000000 00000000 ................
000500 00000000 00000000 00000000 00000000 ................
000510 00000000 00000000 00000000 00000000 ................
000520 00000000 00000000 00000000 00000000 ................
000530 00000000 00000000 00000000 00000000 ................
000540 00000000 00000000 00000000 00000000 ................
000550 00000000 00000000 00000000 00000000 ................
000560 00000000 00000000 00000000 00000000 ................
000570 00000000 00000000 00000000 00000000 ................
000580 00000000 00000000 00000000 00000000 ................
000590 00000000 00000000 00000000 00000000 ................
0005A0 00000000 00000000 00000000 00000000 ................
0005B0 00000000 00000000 00000000 00000000 ................
0005C0 00000000 00000000 00000000 00000000 ................
0005D0 00000000 00000000 00000000 00000000 ................
0005E0 00000000 00000000 00000000 00000000 ................
0005F0 00000000 00000000 00000000 00000000 ................
000600 00000000 E0079363 00000000 32200000 .......c....2 ..
000610 01000000 01000000 01000000 28200000 ............( ..
000620 2C200000 30200000 00100000 3E200000 , ..0 ......> ..
000630 00007064 70746573 742E6578 65005F65 ..pdptest.exe._e
000640 66696D61 696E0000 00000000 00000000 fimain..........
000650 00000000 00000000 00000000 00000000 ................
000660 00000000 00000000 00000000 00000000 ................
000670 00000000 00000000 00000000 00000000 ................
000680 00000000 00000000 00000000 00000000 ................
000690 00000000 00000000 00000000 00000000 ................
0006A0 00000000 00000000 00000000 00000000 ................
0006B0 00000000 00000000 00000000 00000000 ................
0006C0 00000000 00000000 00000000 00000000 ................
0006D0 00000000 00000000 00000000 00000000 ................
0006E0 00000000 00000000 00000000 00000000 ................
0006F0 00000000 00000000 00000000 00000000 ................
000700 00000000 00000000 00000000 00000000 ................
000710 00000000 00000000 00000000 00000000 ................
000720 00000000 00000000 00000000 00000000 ................
000730 00000000 00000000 00000000 00000000 ................
000740 00000000 00000000 00000000 00000000 ................
000750 00000000 00000000 00000000 00000000 ................
000760 00000000 00000000 00000000 00000000 ................
000770 00000000 00000000 00000000 00000000 ................
000780 00000000 00000000 00000000 00000000 ................
000790 00000000 00000000 00000000 00000000 ................
0007A0 00000000 00000000 00000000 00000000 ................
0007B0 00000000 00000000 00000000 00000000 ................
0007C0 00000000 00000000 00000000 00000000 ................
0007D0 00000000 00000000 00000000 00000000 ................
0007E0 00000000 00000000 00000000 00000000 ................
0007F0 00000000 00000000 00000000 00000000 ................
000800 00000000 00000000 00000000 00000000 ................
000810 00000000 00000000 00000000 00000000 ................
000820 00000000 00000000 00000000 00000000 ................
000830 00000000 00000000 00000000 00000000 ................
000840 00000000 00000000 00000000 00000000 ................
000850 00000000 00000000 00000000 00000000 ................
000860 00000000 00000000 00000000 00000000 ................
000870 00000000 00000000 00000000 00000000 ................
000880 00000000 00000000 00000000 00000000 ................
000890 00000000 00000000 00000000 00000000 ................
0008A0 00000000 00000000 00000000 00000000 ................
0008B0 00000000 00000000 00000000 00000000 ................
0008C0 00000000 00000000 00000000 00000000 ................
0008D0 00000000 00000000 00000000 00000000 ................
0008E0 00000000 00000000 00000000 00000000 ................
0008F0 00000000 00000000 00000000 00000000 ................
000900 00000000 00000000 00000000 00000000 ................
000910 00000000 00000000 00000000 00000000 ................
000920 00000000 00000000 00000000 00000000 ................
000930 00000000 00000000 00000000 00000000 ................
000940 00000000 00000000 00000000 00000000 ................
000950 00000000 00000000 00000000 00000000 ................
000960 00000000 00000000 00000000 00000000 ................
000970 00000000 00000000 00000000 00000000 ................
000980 00000000 00000000 00000000 00000000 ................
000990 00000000 00000000 00000000 00000000 ................
0009A0 00000000 00000000 00000000 00000000 ................
0009B0 00000000 00000000 00000000 00000000 ................
0009C0 00000000 00000000 00000000 00000000 ................
0009D0 00000000 00000000 00000000 00000000 ................
0009E0 00000000 00000000 00000000 00000000 ................
0009F0 00000000 00000000 00000000 00000000 ................