只是好奇。显然,这对于实际编程而言不是一个很好的解决方案,但我想在Bless(十六进制编辑器)中创建一个可执行文件。
我的体系结构是x86。我可以制作一个非常简单的程序?你好,世界?无限循环?与此问题类似,但在Linux中。
如我的评论中所述,您实际上将为可执行文件编写自己的elf-header,以消除不需要的部分。仍然需要几个部分。Muppetlabs- TinyPrograms上的文档在解释此过程方面做得很出色。为了好玩,这里有几个例子:
等效于/ bin / true(45个字节):
00000000 7F 45 4C 46 01 00 00 00 00 00 00 00 00 00 49 25 |.ELF..........I%| 00000010 02 00 03 00 1A 00 49 25 1A 00 49 25 04 00 00 00 |......I%..I%....| 00000020 5B 5F F2 AE 40 22 5F FB CD 80 20 00 01 |[_..@"_... ..| 0000002d
您经典的“ Hello World!” (160个位元组):
00000000 7f 45 4c 46 01 01 01 03 00 00 00 00 00 00 00 00 |.ELF............| 00000010 02 00 03 00 01 00 00 00 74 80 04 08 34 00 00 00 |........t...4...| 00000020 00 00 00 00 00 00 00 00 34 00 20 00 02 00 28 00 |........4. ...(.| 00000030 00 00 00 00 01 00 00 00 74 00 00 00 74 80 04 08 |........t...t...| 00000040 74 80 04 08 1f 00 00 00 1f 00 00 00 05 00 00 00 |t...............| 00000050 00 10 00 00 01 00 00 00 93 00 00 00 93 90 04 08 |................| 00000060 93 90 04 08 0d 00 00 00 0d 00 00 00 06 00 00 00 |................| 00000070 00 10 00 00 b8 04 00 00 00 bb 01 00 00 00 b9 93 |................| 00000080 90 04 08 ba 0d 00 00 00 cd 80 b8 01 00 00 00 31 |...............1| 00000090 db cd 80 48 65 6c 6c 6f 20 77 6f 72 6c 64 21 0a |...Hello world!.| 000000a0
不要忘记使它们可执行…