This isn't technically necessary according to the DWARF standard, but the Android libunwindstack rejects eh_frame sections where an FDE refers to a CIE other than the closest previous CIE.
I think I would consider this a bug in libunwindstack... as far as I can tell, the DWARF standard doesn't contain any requirement like this. And
I'm not sure we should be adding workarounds for specific unwind implementations. But I have the patch anyway, so I'm posting it.
I'd appreciate it if someone from Google could contact the owners of libstackunwind to see if they have any opinion on this.
While you are in the area, mind just switching this over to a range-based for loop?