On Wed, 2018-05-30 at 17:32 +0000, Sasha Da Rocha Pinheiro wrote: > I just fixed something interesting in Dyninst. We were assuming that > the FDEs were following the CIE in the eh_frame section, but this is > not correct. I found them mixed in an ARM binary and this caused > wrong parsing. > So we I did dwarf_next_cfi() in the loop to go through the FDE's, and > I had to use it again in the loop to get the corresponding CIE. I > don't think it's a problem, just kinda not intuitive, for who wants > to understand after me.
dwarf_next_cfi () is a very low level interface. Other cfi related interfaces that work with a Dwarf_CFI handle (dwarf_getcfi () and dwarf_getcfi_elf ()) and don't make any assumptions about the order. But they do build up a cache of all entries. In return for some extra memory usage you can use them without caring about the order in which they appear with dwarf_cfi_addrframe () by just giving an address you are interested in and using dwarf_frame_info (), dwarf_frame_cfa () and dwarf_frame_register () to extract the information (which might be less/different than what you would get from the "raw" Dwarf_CFI_Entry). Cheers, Mark