1 symbol table
2 Code
Each variable is labeled to prevent the view from being mixed.
int _1_cpp_i_ = 1;const int _2_cpp_c_i_ = 1;static int _2_cpp_s_i_ = 1;void _4_cpp_v_func_i_i_ (int, int) { return;} int _5_cpp_i_func_i_i_ (int, int) { return 1;} extern "C" {int _6_c_i_ = 1;const int _7_c_c_i_ = 1;static int _8_c_s_i_ = 1;void _9_c_v_func_i_i_ (int, int) { return;} int _0_c_i_func_i_i_ (int, int) { return 1;}}
Then compile and view, and note the use of g++ here.
Then look at the paragraph in table 4 below, which is the paragraph:
Casually Baidu: The meaning of rodata is equally obvious, RO represents read only, that is, read-only data (const).
Additional complements:
- Constants are not necessarily placed in the rodata, and some immediate numbers are encoded directly in the instruction, stored in the code snippet (. Text).
- For string constants, the compiler automatically removes duplicate strings, guaranteeing that a string has only one copy in an executable file (EXE/SO).
- Rodata is shared across multiple processes, which can improve space utilization.
But this is just the compiler said this paragraph can not be modified, in fact, the actual force of the content of this paragraph can not be changed is the operating system in the allocation page, the page added to the properties.
If you are compiling with GCC:
Using GCC and compiling the results with g++, it can be seen that GCC compiles with the same identifier-decorating rules as g++.
The role of extern "C" is now changed to modify the identifier in the form of GCC (since the GCC identifier modification rules have now changed)
3 in Comprehensive
Static and const-decorated global variables, which are only visible in this file by default. (Note is usually cc file because. h file is included in, not visible)
4 from the ELF symbol table angle analysis
Each item in the symbol table represents the information for a symbol. Recorded in structure
struct elf32_sym{ elf32_word st_name; /* symbol name, which is the following table in the string table */ elf32_addr st_value; /* symbol corresponds to only, may be an address, specifically with the regal * * elf32_word st_size; /* Symbol size */ unsigned char st_info; /* Sign Binding information */ unsigned char st_other; /* Other, currently 0, not used */ elf32_section st_shndx; /* The segment where the symbol is located */};
Readelf-s is just a summary of the information presented.
In this paper, St_info and ST_SHNDX are concerned.
The former indicates whether the logo is visible outside the document, and the latter refers to the segment where the identifier is located, and indirectly indicates whether it can be modified.
Note that the symbol table is the convention between the compiler and the connector. When the connector is connected to a symbol, if the st_info field of the symbol is found to be visible in the file, then the connector error indicates that the identifier could not be found (but in fact he found it.)
5 Supplement
A const-defined global variable cannot be accessed by another file and must be added extern to be connected. (Note that the. h file is not in the cc file.) the. h file will be expanded)
C + + symbol table and Static\const modifier variables