[PATCH] Also find CFI in sections of type SHT_X86_64_UNWIND

Mark Wielaard mark@klomp.org
Sun Nov 4 23:04:00 GMT 2018

On Mon, 2018-10-29 at 16:21 +0100, Milian Wolff wrote:
> On my system with g++ (GCC) 8.2.1 20180831 with GNU gold (GNU
> Binutils
> 2.31.1) 1.16, the .eh_frame section does not have type PROGBITS
> but rather is using X86_64_UNWIND nowadays:

Urgh, who thought it would be a good idea to have a architecture
specific (instead of a GNU specific) section type for unwind tables...
And why is there no separate type for .eh_frame_hdr. Now you still need
to check the name anyway...

But, given that we have that now, yes, lets deal with it.

> ```
> $ echo "int main(){ return 0; }" > test.c
> $ gcc test.c
> $ readelf --sections a.out | grep .eh_frame
>   [14] .eh_frame         X86_64_UNWIND    0000000000000670  00000670
>   [15] .eh_frame_hdr     X86_64_UNWIND    0000000000000724  00000724
> ```
> Without this patch, libdw refuses to use the available unwind
> information, leading to broken backtraces while unwinding. With the
> patch applied, unwinding works once more in such situations.

Three questions:

- What testcase did you use?
  In theory dwarf_getcfi_elf () should fall back to using phdrs and
  find the PT_GNU_EH_FRAME data instead.

- It might be better to change the check to shdr->sh_type != SHT_NOBITS
  The idea is probably that we don't want to look at the data in case
  this is a .debug file which has it removed. This might be better than
  adding a check for X86_64_UNWIND since then we would also need to
  check the arch. Does != SHT_NOBITS work for you?

- What does eu-readelf -S show?
  I think we need a x86_64_section_type_name () ebl hook to show it



More information about the Elfutils-devel mailing list