Is there a reason why not erase characters from the executable?

A few years ago I asked a question about how to reduce the size of executable files. Using the MinGW compiler, delimiters (the -s ) helped reduce 50% + of the size.

Why stripping is not a default - is there a good reason why you should NOT strip characters in some scenarios? I would like to understand this more deeply: today I just vaguely know that symbols are associated with linking a library. Are they necessary in the executable file and do they affect the speed of execution?

+7
c ++ c compilation mingw
source share
3 answers

I canโ€™t imagine that they affect the speed of execution in any noticeable way, although theoretically you could have a small number of misses in the image of the process.

You want to save the characters in the file when you debug it so that you can see what function you are in, check the values โ€‹โ€‹of the variables, etc.

But the characters make the file bigger: potentially, much bigger. Thus, you do not want binary characters to be placed on a small embedded device. (I'm talking about a real built-in device, not the 21st century Raspberry Pi with 9,000 GB of disk space!)

I generally collect all release builds and do not collect any debug builds. This makes client dump databases a little less useful, but you can always keep a copy of an unbuilt release build and debug your kernel against this.

I heard about one company that had a policy of never removing characters, even in release builds, so that they could load the kernel directly into the debugger. This seems like a bit of an abstraction leak to me, but whatever. Their call.

Of course, if you really want this, you can analyze the assembly yourself without them. But this is crazy ...

+5
source share

There is no good reason to erase characters. For example, by deleting characters, you eliminate the possibility of collecting a process stack - an extremely convenient function.

EDIT. A few people here seem to be confused about the difference between debugging symbols and "common" symbols. The former are produced only when the -g option (or similar) is provided to the compiler and is usually used only in debug builds (although they can also be used with optimized builds). Regular characters are things like function names, and are created by compilers so that object files can be linked or .so files loaded. There are several extremely useful non-invasive tools that you can use for executable executables without debugging, which depend on unaccepted characters.

+3
source share

MinGW is the abbreviation for "Minimalist GNU for Windows"; as such, the compiler set is GCC ... a compilation of GNU compilers. Naturally, this set of compilers will comply with the GNU Coding standards, which require that each assembly be a "debug assembly" ... i.e. it should include both debugging symbols and those that are necessary for linking (This is logical, since the "debug build" is an order of magnitude more useful to the application developer than the so-called "release build"). In addition, the assembly system, which distinguishes between the "debug assembly" and the "release assembly" modes, is more complex - possibly significantly more - than the one that concerns only the "debug assembly".

In the GNU build model, there is no need for a "release build". A "reset" is not created during assembly; it is created during installation โ€” usually as a โ€œstep-by-stepโ€ installation from which the release package is created. The GNU toolchain includes both the strip command and the install command, which can "debug" the build on the fly when creating a phased installation for packaging as a release (or in place if you wish), so thereโ€™s really no need clutter up the build system with "release" features; just create an up-front "debug build" and then split it after the event to convert it to an effective "release build" when you need it.

Since your MinGW toolchain is primarily a GNU toolchain, it fully supports this GNU build model.

+3
source share

All Articles