Why is the time to add debugging needs to be compiled -g option. readelf command.

 -g to operating system's native format (stabs, COFF, XCOFF, or the DWARF). generate debugging information. able to use the GDB debugging information.

       On most systems use stabs format, `-g 'option to start the extra debugging information that only GDB was used; the GDB debugging information better, but there is likely to make other debuggers crash or refuse to read the program if. are you sure you want to control whether to generate additional information, using `-gstabs + ',` -gstabs', `-gx - ',' coff + ',` -gxcoff', `-gdwarf + ', or` -gdwarf'.

       Different and most C compilers, GNU CC allows the use of `-g 'and` -O' option in conjunction with optimized code occasionally make some amazing results: some variables are declared non-existent; the flow of control is not direct go. unexpected places; some statements because the results are constant or have been identified but not implemented; some statements elsewhere execution because they were moved out of the cycle.

       However, it proved to debug optimized output is possible using optimizer program may contain errors are reasonable.

You can learn more about gcc -g option by querying the manual input command (man gcc)

readelf General for viewing ELF file format information.

Syntax: readelf (Option) (parameters: file), and in addition -v -H, other options must be assigned a parameter.

-a is equivalent to specifying - header - Program header - Festival - sign - relocation - dynamic, - notes and - version information.

1) Options -h (elf header), displays the file header information elf beginning of the file;

2) Option -l (program headers), segments display program header (header section) information;

3) Option -S (section headers), sections display the section header information;

4) option -g (section groups), group information display section;

5) Options -t, section-details display detailed information section (-S a);

6) options -s, symbols displayed in the symbol table entry segment;

7) option -e, headers show all header information is equivalent to: -h -l -S;

8) option -n, notes display information note segment (kernel comment) of;

9) Options -r, relocs relocatable information display section;

10) option -u, unwind display unwind segment information. Currently only supports unwind segment information IA64 ELF's;

11) option -d, dynamic information display dynamic segment;

12) option -V, version-info display version information segment;

13) option -A, arch-specific information display CPU architecture;

14) option -I, histogram when displaying symbols, a bar chart showing the length of the bucket list;

15) option -x, hex-dump =

16) option -D, use-dynamic segment using dynamic symbol table display symbols, instead of using the symbol period;

17) option -a, all display all information equivalent to -h -l -S -s -r -d -V -A -I;

18) option -v, version display version information of readelf;

19) option -H, help readelf display command line options are supported.

Reference: http://www.eeworld.com.cn/mcu/2019/ic-news040143674.html

Guess you like

Origin blog.csdn.net/qq_43210641/article/details/90270585