How to view LINUX-GCC compiled by which version of the compiler

Source: Internet
Author: User

how to see which version of the compiler compiled the LINUX-GCC http://bbs.csdn.net/topics/380000949

That is not possible unless you add debug information, which is compiled by adding the-G parameter, and then debugging with GDB can be displayed. View an elf file information to the fullest extent.
As follows:

[Email protected] rootfs]# Readelf-wa bin/gzip

ELF header:magic:7f $4c $  on  on  on xx xx xx xx xx xx xx xx xxclass:elf32 Data:2's complement, little endianVersion:1(current) OS/abi:unix-System V ABI Version:0type:exec (executable file) Machine:arm Version: 0x1Entry Point Address:0xa080Start of program headers: the(bytes to file) Start of section headers:1975444(bytes into file) Flags:0x5000002, have entry point, Version5 EABI Size of ThisHeader the(bytes) Size of program headers: +(bytes) Number of program headers:6Size of section headers: +(bytes) Number of section headers: -Section HeaderstringTable index: -Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [0] NULL00000000 000000 000000 xx      0   0  0  [ 1]. Note. Abi-tag NOTE 000080f4 0000f4000020 xxA0   0  4  [ 2]. Init progbits00008114 00011400000cxxAx0   0  4  [ 3]. Text Progbits00008120 00012017fcfcxxAx0   0  -  [ 4] __libc_freeres_fn progbits 00187e1c 17fe1c 000f20xxAx0   0  4  [ 5] __libc_thread_fre progbits 00188d3c 180d3c 0000e4xxAx0   0  4  [ 6]. Fini progbits 00188e20 180e20000008 xxAx0   0  4  [ 7]. Rodata progbits 00188e28 180e28058147 xxA0   0  8  [ 8] __libc_subfreeres progbits 001e0f70 1d8f70 00005cxxA0   0  4  [ 9] __libc_atexit progbits 001E0FCC 1D8FCC000004 xxA0   0  4  [Ten] __libc_thread_sub progbits 001e0fd0 1d8fd0000008 xxA0   0  4  [ One] . Arm.extab progbits 001e0fd8 1d8fd8 001b04xxA0   0  4  [ A] . Arm.exidx arm_exidx 001E2ADC 1DAADC 006ea8xxAL3   0  4  [ -]. Tdata progbits 001f1984 1e1984000018 xxWAT0   0  4  [ -]. TBSS nobits 001f199c 1e199c000034 xxWAT0   0  4  [ the]. Init_array Init_array 001f199c 1e199c000004 xxWA0   0  4  [ -]. Fini_array Fini_array 001f19a0 1e19a0000008 xxWA0   0  4  [ -]. JCR progbits 001f19a8 1e19a8000004 xxWA0   0  4  [ -]. data.rel.ro progbits 001f19ac 1e19ac 00002cxxWA0   0  4  [ +]. Got progbits 001f19d8 1e19d8 00007cGenevaWA0   0  4  [ -]. Data progbits 001f1a58 1e1a58 0008f7xxWA0   0  8  [ +]. BSS Nobits 001f23501e234f 004828 xxWA0   0  8  [ A] __libc_freeres_pt nobits 001f6b781e234f00003cxxWA0   0  4  [ at] . Arm.attributes arm_attributes00000000 1e234f00002bxx      0   0  1  [ -]. Shstrtab Strtab000000001e237a000118 xx      0   0  1Section to Segment mapping:segment Sections ...xx     . Arm.exidx on. Note. abi-tag. init. Text __libc_freeres_fn __libc_thread_freeres_fn. Fini. Rodata __libc_subfreeres __libc_atexit __libc_ Thread_subfreeres. Arm.extab. Arm.exidx Geneva. Tdata. Init_array. Fini_array. JCR. data.rel.ro. Data. BSS gotGeneva. Note. abi-TagGeneva. Tdata. Tbssattribute section:aeabifile Attributes tag_cpu_name:"5TE"tag_cpu_arch:v5te Tag_arm_isa_use:yes Tag_thumb_isa_use:thumb-1tag_abi_pcs_wchar_t:4tag_abi_fp_denormal:needed tag_abi_fp_exceptions:needed tag_abi_fp_number_model:ieee754tag_abi_align8_needed:yes tag_abi_align8_preserved:yes, except leaf SP tag_abi_enum_size:inttag_unknown_44:1(0x1)

How to retrieve the GCC version used to compile a given ELF executable? Http://stackoverflow.com/questions/2387040/how-to-retrieve-the-gcc-version-used-to-compile-a-given-elf-executable

ques: I ' d like to retrieve the GCC version used to compile a given executable. I tried but readelf didn ' t get the information. Any thoughts?

ANS: To complete what others has Said:it's not stored in the object (or EXE) file, unless you compile wit H Debugging Information! (option -g ). If you compile with the debug info, you can get the it back with readelf :

[email protected] test]# gcc a.c[[email protected] test]# readelf-wi A. out[email protected] test]# gcc A.C-g [[email protected] test]# readelf-wi A. outThe section . debug_info contains:compilation Unit @ offset0x0: Length:135Version:2abbrev Offset:0Pointer Size:8<0><b>: abbrev number:1(dw_tag_compile_unit) Dw_at_stmt_list:0dw_at_high_pc:0x400453dw_at_low_pc:0x400448Dw_at_producer:gnu C4.1.2 20080704(Red Hat4.1.2- -) Dw_at_language:1(ANSI C) dw_at_name:a.c Dw_at_comp_dir:/work/farsight/Test<1>< A: abbrev Number:2(Dw_tag_subprogram) dw_at_external:1dw_at_name:main dw_at_decl_file:1Dw_at_decl_line:4dw_at_prototyped:1Dw_at_type:< the>dw_at_low_pc:0x400448dw_at_high_pc:0x400453dw_at_frame_base:0(location list)<1>< the: abbrev Number:3(Dw_tag_base_type) Dw_at_name:intdw_at_byte_size:4dw_at_encoding:5(Signed)

ANS2:

How to view LINUX-GCC compiled by which version of the compiler

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.