Size optimization by removing garbage characters from iin C ++ strings

I have two versions of the Hello World program:

#include <iostream>
int main() {
    std::cout<<"Hello World";
}

and

#include <iostream>
int main() {
    std::cout<<"Hello World and a very long message";
}

I would expect a different size of the resulting binaries for them if strict size optimization were performed. However, when I compile g++ -Os -o test test.cpp -Wl,--strip-all(c GCC 5.4.0), I get equal file sizes (6336 on my system, Ubuntu). This means that there is some garbage space for a buffer with a minimum size (although in this example I expect the lines to be const char[]).

My question is: what is the nature of this buffer and how to remove garbage characters from the generated binary?

+4
source share
1 answer

This is where the alignment happens.

(4K). . :

ELF GNU ?

ELF

( ), , , .

+5

Source: https://habr.com/ru/post/1672046/


All Articles