gcc on windows generating garbage? windows vs linux

前端 未结 2 606
自闭症患者
自闭症患者 2021-01-23 09:31

I\'m trying to find out why in windows has so much more instructions for the same program than linux. So I just used int a=0xbeef; and printf(\"test\\n\");

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-23 10:07

    You seem to be compiling with old 3.x series gcc, you'd better upgrade. Newer versions don't invoke alloca. I suspect the particular version of alloca might use register convention so the mov 0x10,%eax is probably setting up the argument for that call.

    __main is a startup function defined in crtbegin.o that executes global constructors and registers a function using atexit that will run the global destructors.

    Also note that main gets special treatment, like the stack alignment code and the above-mentioned initialization. It may be a good idea to instead compare a "plain" function if you are just interested in code generation issues.

提交回复
热议问题