Why are there text names in the EXE file?

I have compiled a C ++ program to have an EXE in release mode. When I open the EXE file in the editor, I see pieces of text blocks, which are basically the names of the low-level functions used in the program.

It is always said that a computer only understands binary machine code. Then, what is the purpose of existence for this human-readable text inside the program executable? Why does a computer need function names to run a program?

enter image description here

IDE: Visual Studio 2015 RC
Platform: Windows 8.1 x64

Compiler command line options:

/GS /GL /W3 /Gy /Zc:wchar_t /Zi /Gm- /Ox /Ob2 /sdl
/Fd"x64\Release\vc140.pdb" /Zc:inline /fp:precise /D "_MBCS"
/errorReport:prompt /GT /WX- /Zc:forScope /Gd /Oy /Oi /MD
/Fa"x64\Release\" /EHsc /nologo /Fo"x64\Release\" /Ot
/Fp"x64\Release\<ProjectName>.pch"

      

Linker command line options:

/OUT:"<SolutionPath>\x64\Release\<ProjectName>.exe"
/MANIFEST /LTCG /NXCOMPAT
/PDB:"<SolutionPath>\x64\Release\<ProjectName>.pdb"
/DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib"
"comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib"
"uuid.lib" "odbc32.lib" "odbccp32.lib"
/MACHINE:X64 /OPT:REF /PGD:"<SolutionPath>\x64\Release\<ProjectName>.pgd"
/MANIFESTUAC:"level='asInvoker' uiAccess='false'"
/ManifestFile:"x64\Release\<ProjectName>.exe.intermediate.manifest"
/OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1

      


EDIT:

I made a change to rcgldr's answer . I changed my project setting by changing the command line switch \MD

to \MT

. The size of the executable file has changed from 56 kb to 436 kb. I assume this is because the required libraries are not linked at runtime, but they are stored in the EXE file from the beginning. But there are still blocks of text in the EXE file as shown in the screenshot below. The function names from the Standard Template Library (STL) have completely disappeared, but there are many Win32 API function names. What could be the reason now?

enter image description here

+3


source to share


2 answers


These are the names to access from the .DLL. Try building a static library instead and those names should disappear, but the .EXE will get bigger. To do this, to create a release, right-click on the source file name in the project and change the run-time library from "Multithreaded DLL" (/ MD) to "Multithreaded (/ MT)". The main change here is the / MD compiler command line option, which changes to / MT.



However, as commented by Peter Torr below, you still stick with some dll modules like kernel32.dll.

+2


source


Executables built on windows use the Portable Executable format: https://msdn.microsoft.com/en-us/library/ms809762.aspx



To communicate with functions in a DLL, EXEs are created with import and export tables that contain the addresses of the functions that are used at runtime. If you are using the SDK (or VC ++?) "Dumpbin" utility with / exports or / import, you can see the functions being imported or exported from the module. The DLL layout can change as new versions are released, so the import and export tables are the way the caller can get the address of a function in another dynamically linked module.

+1


source







All Articles