Qi Zhang
Qi Zhang

Reputation: 721

Why there is no DWARF info?

I am using the following commands to compile a source file(hello.c) into an executable file(hello), and expect to dump out the DWARF info of the executable file. However, there is no DWARF info no matter using "readelf -wi hello" or "llvm-dwarfdump hello". I am wondering where went wrong.

clang-3.5 -gdwarf-4 -O0 -emit-llvm -c hello.c -o hello.bc
llc -dwarf-version=4 -O0 -filetype=obj hello.bc
gcc hello.o -o hello

Upvotes: 0

Views: 967

Answers (2)

Rajendra
Rajendra

Reputation: 1780

I tried the same commands with clang-5.0 & gcc-6.4.0 seems to work for me.

$ llvm-dwarfdump hello | more
hello:  file format ELF64-x86-64

.debug_abbrev contents:
Abbrev table for offset: 0x00000000
[1] DW_TAG_compile_unit DW_CHILDREN_yes
    DW_AT_producer  DW_FORM_strp
    DW_AT_language  DW_FORM_data2
. . .

$ readelf -wi hello | more
Contents of the .debug_info section:

  Compilation Unit @ offset 0x0:
  Length:        0x75 (32-bit)
  Version:       4
  Abbrev Offset: 0x0
  Pointer Size:  8
  <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
  . . .

Upvotes: -1

Qi Zhang
Qi Zhang

Reputation: 721

The problem was due to the mismatching between clang and llvm. I was using llvm-3.9 with clang-3.5. I solved by upgrading clang-3.5 to clang-3.9. Specifically, I added clang-3.9 to llvm_src/tools and then recompiled llvm.

Upvotes: 0

Related Questions