a problem with cl.exe and ml.exe

前端 未结 1 1415
伪装坚强ぢ
伪装坚强ぢ 2020-12-11 07:31

I used cl command to compile a cpp file:

cl test.cpp  //the generated  test.exe can work well

then I used another way:

cl /         


        
相关标签:
1条回答
  • 2020-12-11 07:55

    The compiler produces an invalid assembly listing when exception handling code is produced. There's a bug open on Microsoft Connect: http://connect.microsoft.com/VisualStudio/feedback/details/556051/cl-facs-generates-bad-masm-for-c-exception-handlers

    In a response to the bug, there's a half-hearted "we will consider fixing this" along with a disclaimer that "listing files generated by the C/C++ compiler are for informational purposes".

    It looks like you might be able to have a "scriptable" fix for this particular problem:

    • cut the ENDP statement that follows a text$x ENDS statement,
    • paste it just before the previous _TEXT ENDS statement

    At least that looks to be the pattern in the asm file generated by your simple program - I don't know if that pattern would hold generally.

    Unfortunately, after applying this fix, several new problems crop up with instructions using fs overrides and a couple undefined symbols. Who knows what else you'd run into once you tried this with a more complex program?

    0 讨论(0)
提交回复
热议问题