/* start = first entry origin = first entry with positive offset (or stop if there is no such entry) stop - 1 = last entry  */
static const struct unwind_idx* search_index(unsigned long addr, const struct unwind_idx *start, const struct unwind_idx *origin, const struct unwind_idx *stop)
/* start = first entry origin = first entry with positive offset (or stop if there is no such entry) stop - 1 = last entry  */
static const struct unwind_idx* search_index(unsigned long addr, const struct unwind_idx *start, const struct unwind_idx *origin, const struct unwind_idx *stop)
{
    unsigned long addr_prel31;
    LOG_D("%s(%08lx, %x, %x, %x)",
            __func__, addr, start, origin, stop);
    if (addr < (unsigned long)start)
        stop = origin;
    else
        start = origin;
    addr_prel31 = (addr - (unsigned long)start) & 0x7fffffff;
    while (start < stop - 1)
    {
        const struct unwind_idx *mid = start + ((stop - start) >> 1);
        if (addr_prel31 - ((unsigned long)mid - (unsigned long)start) <
                mid->addr_offset)
            stop = mid;
        else
        {
            addr_prel31 -= ((unsigned long)mid -
                    (unsigned long)start);
            start = mid;
        }
    }
    if (start->addr_offset <= addr_prel31)
        return start;
    else
    {
        LOG_W("unwind: Unknown symbol address %08lx", addr);
        return RT_NULL;
    }
}