Skip to content

CmmToAsm: fix errornous trailing zero byte when emitting CmmFileEmbed

Cheng Shao requested to merge TerrorJack/ghc:cmm-incbin-no-trailing-zero into master

CmmToAsm: fix errornous trailing zero byte when emitting CmmFileEmbed

The X86 NCG emits an extra trailing zero after each CmmFileEmbed. This is wrong:

  • When we lower a large blob to CmmFileEmbed, the temporary file contains the exact same bytes in the original StgTopStringLit. It may contain any byte pattern, and has absolutely no guarantee to be a NUL-terminated C string.
  • No other NCG backend emits it.

This hasn't caused runtime issues before, mainly because large blobs tend to be their own CmmData sections, so they don't screw up the offsets of other CmmStatics that follow. Still, it should be corrected to remove a potential source of coufusion and incoherency between all NCG backends.

Merge request reports