简体   繁体   English

如何使用 OpenWatcom linker 使 DOS.exe 重定位表更小?

[英]How to make the DOS .exe relocation table smaller with OpenWatcom linker?

I've created the following DOS.exe file with OpenWatcom:我用 OpenWatcom 创建了以下 DOS.exe 文件:

$ xxd prog.exe
00000000: 4d5a 8200 0100 0100 0300 4000 ffff 0500  MZ........@.....
00000010: 0204 0000 0000 0000 2000 0000 0000 0000  ........ .......
00000020: 0100 0000 0000 0000 0000 0000 0000 0000  ................
00000030: b804 008e d8e8 0900 b44c cd21 d1e2 01d0  .........L.!....
00000040: c353 52ba 0200 b409 cd21 ba0c 00b4 09cd  .SR......!......
00000050: 21ba 0f00 b409 cd21 ba08 00b8 0700 e8db  !......!........
00000060: ff89 c3ba 0a00 b809 00e8 d0ff 01d8 5a5b  ..............Z[
00000070: c300 4865 6c6c 6f21 0d0a 2400 6162 0063  ..Hello!..$.ab.c
00000080: 6400                                     d.

Regions:地区:

  • 0x0...0x1c: DOS.exe header. 0x0...0x1c:DOS.exe header。
  • 0x1c...0x20: 4 bytes of padding. 0x1c...0x20:4 字节的填充。
  • 0x20...0x24: 4 bytes containing 1 relocation entry. 0x20...0x24:4 个字节,包含 1 个重定位条目。
  • 0x24...0x30: 12 bytes of padding. 0x24...0x30:12 字节的填充。
  • 0x30...: code (_TEXT) segment with 16-bit 8086 machine code. 0x30...:带有 16 位 8086 机器码的代码 (_TEXT) 段。
  • ... ...

How do I get rid of the 4 bytes of padding and the 12 bytes of padding, so that the code starts at offset 0x20?如何摆脱 4 字节的填充和 12 字节的填充,使代码从偏移量 0x20 开始? Is there a WLINK flag for this?这有 WLINK 标志吗? Should I use a different linker?我应该使用不同的 linker 吗? Should I post-process the generated.exe?我应该对生成的.exe 进行后处理吗?

I wasn't able to find a configuration option for this, so I ended up writing my own linker and using it instead of WLINK.我无法为此找到配置选项,因此我最终编写了自己的 linker并使用它而不是 WLINK。 This way the.exe header became only 24 (0x18) bytes, and I didn't need any relocations.这样,.exe header 就变成了 24 (0x18) 字节,我不需要任何重定位。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM