saugustine retitled this revision from Promote nameless lambda used by dl_iterate_phdr to named function to clean up control flow inside findUnwindSections. Also, expose the data structure
to allow use by a future replacment function. to Promote nameless lambda used by dl_iterate_phdr to named function to clean up control flow inside findUnwindSections. Also, expose the data structureto allow use by a future replacment function..Mar 2 2020, 2:20 PM

This broke building for windows, and I would be pretty sure it also broke things for apple platforms as well (as _LIBUNWIND_SUPPORT_DWARF_UNWIND is defined on both of them, at least on certain architectures).

There's a long chain of ifdefs in LocalAddressSpace::findUnwindSections, like this:

Now after this change, you've placed a separate #if defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) standalone above all of it - while _LIBUNWIND_SUPPORT_DWARF_UNWIND is defined in a lot of other cases as well (both on apple targets and for some architectures on win32), that are handled by other more specialised OS specific ifdefs in LocalAddressSpace::findUnwindSections.

Not sure what the cleanest solution would be though. The initial thought would be to add && !defined(__APPLE__) && !defined(_WIN32) && !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(__BIONIC__) to the ifdef surrounding findUnwindSectionByPhdr, but that doesn't quite exactly replicate the effect of the long series of ifdefs either. The safest (but less neat) solution would be to add the exact same series of ifdefs around findUnwindSectionByPhdr, with empty ifdef bodies for all the other cases.

After the patch the code in the findUnwindSectionByPhdr function causes compile-time errors because of undefined symbols (e.g. ElfW) and accesses to the incomplete type dl_phdr_info. As the previous comment suggested, findUnwindSectionByPhdr should be ifdef-ed out when _LIBUNWIND_IS_BAREMETAL is defined.