简体   繁体   中英

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

I've created the following DOS.exe file with OpenWatcom:

$ 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.
  • 0x1c...0x20: 4 bytes of padding.
  • 0x20...0x24: 4 bytes containing 1 relocation entry.
  • 0x24...0x30: 12 bytes of padding.
  • 0x30...: code (_TEXT) segment with 16-bit 8086 machine code.
  • ...

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? Is there a WLINK flag for this? Should I use a different linker? Should I post-process the generated.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. This way the.exe header became only 24 (0x18) bytes, and I didn't need any relocations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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