Reputation: 2387
I wrote this small C++ program and built it(Release)
#include<iostream>
int main(){
std::cout<<"Hello World";
return 0;
}
When I disassemble it, it has a lot of extra code(security cookie etc..). I believe Visual Studio is adding all those. How can I compile this program without any extra information, so that its easy to understand its disassembled code?
I know assembly is comparatively harder, but what I mean is getting a hello world asm code out of a hello world c++ program. Is this possible?
Upvotes: 3
Views: 2027
Reputation: 3391
To control visual studio code generation features, rigth click on your project in VS -> properties -> Configuration properties -> c/c++ -> code generation.
Don't forget to select the right build configuration (debug, release, etc...).
The security cookies can be removed by playing with the buffer security check (/GS by default)
Upvotes: 0
Reputation: 44316
you can generate assembly output in Project Properties -> Configuration Properties -> Output Files -> Assembler Output
This will let you see the assembly for the code you wrote.
Diassembling, you are going to get a bunch of other things that are linked in.
Upvotes: 3
Reputation: 994947
You're starting with a huge code base with <iostream>
. What you might want to do is avoid the use of a runtime library entirely. Try something like this:
#include <windows.h>
int main() {
HANDLE stdout = GetStdHandle(STD_OUTPUT_HANDLE);
WriteFile(stdout, "Hello world\n", 12, NULL, NULL);
return 0;
}
Compile that with assembly listing turned on, and that should give you some "raw" Win32 code to start with.
Upvotes: 4