* Perform a binary search of the index table to find the function * with the largest address that doesn't exceed addr. */
| 311 | * with the largest address that doesn't exceed addr. |
| 312 | */ |
| 313 | static struct unwind_idx * |
| 314 | find_index(uint32_t addr) |
| 315 | { |
| 316 | struct module_info *info; |
| 317 | unsigned int min, mid, max; |
| 318 | struct unwind_idx *start; |
| 319 | struct unwind_idx *item; |
| 320 | int32_t prel31_addr; |
| 321 | uint32_t func_addr; |
| 322 | |
| 323 | info = find_module_info(addr); |
| 324 | if (info == NULL) |
| 325 | return NULL; |
| 326 | |
| 327 | min = 0; |
| 328 | max = (info->exidx_end - info->exidx_start) / sizeof(struct unwind_idx); |
| 329 | start = (struct unwind_idx *)CADDR(info->exidx_start); |
| 330 | |
| 331 | while (min != max) { |
| 332 | mid = min + (max - min + 1) / 2; |
| 333 | |
| 334 | item = &start[mid]; |
| 335 | |
| 336 | prel31_addr = expand_prel31(item->offset); |
| 337 | func_addr = (uint32_t)&item->offset + prel31_addr; |
| 338 | |
| 339 | if (func_addr <= addr) { |
| 340 | min = mid; |
| 341 | } else { |
| 342 | max = mid - 1; |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | return &start[min]; |
| 347 | } |
| 348 | |
| 349 | /* Reads the next byte from the instruction list */ |
| 350 | static uint8_t |
no test coverage detected