The set of registers that can be included in an unwind hint and their encoding will depend on the architecture. Have arch specific code to decode that register.
Unified · Split
| @@ -88,4 +88,6 @@ unsigned long arch_dest_reloc_offset(int addend); · 87 unmodified lines | |||
| 88 | 88 | ||
| 89 | const char *arch_nop_insn(int len); | 89 | const char *arch_nop_insn(int len); |
| 90 | 90 | ||
| 91 | int arch_decode_hint_reg(struct instruction *insn, u8 sp_reg); | ||
| 92 | |||
| 91 | #endif /* _ARCH_H */ | 93 | #endif /* _ARCH_H */ |
| @@ -15,6 +15,7 @@ · 14 unmodified lines | |||
| 15 | #include "../../elf.h" | 15 | #include "../../elf.h" |
| 16 | #include "../../arch.h" | 16 | #include "../../arch.h" |
| 17 | #include "../../warn.h" | 17 | #include "../../warn.h" |
| 18 | #include <asm/orc_types.h> | ||
| 18 | 19 | ||
| 19 | static unsigned char op_to_cfi_reg[][2] = { | 20 | static unsigned char op_to_cfi_reg[][2] = { |
| 20 | {CFI_AX, CFI_R8}, | 21 | {CFI_AX, CFI_R8}, |
| @@ -583,3 +584,39 @@ const char *arch_nop_insn(int len) · 562 unmodified lines | |||
| 583 | 584 | ||
| 584 | return nops[len-1]; | 585 | return nops[len-1]; |
| 585 | } | 586 | } |
| 587 | |||
| 588 | int arch_decode_hint_reg(struct instruction *insn, u8 sp_reg) | ||
| 589 | { | ||
| 590 | struct cfi_reg *cfa = &insn->cfi.cfa; | ||
| 591 | |||
| 592 | switch (sp_reg) { | ||
| 593 | case ORC_REG_UNDEFINED: | ||
| 594 | cfa->base = CFI_UNDEFINED; | ||
| 595 | break; | ||
| 596 | case ORC_REG_SP: | ||
| 597 | cfa->base = CFI_SP; | ||
| 598 | break; | ||
| 599 | case ORC_REG_BP: | ||
| 600 | cfa->base = CFI_BP; | ||
| 601 | break; | ||
| 602 | case ORC_REG_SP_INDIRECT: | ||
| 603 | cfa->base = CFI_SP_INDIRECT; | ||
| 604 | break; | ||
| 605 | case ORC_REG_R10: | ||
| 606 | cfa->base = CFI_R10; | ||
| 607 | break; | ||
| 608 | case ORC_REG_R13: | ||
| 609 | cfa->base = CFI_R13; | ||
| 610 | break; | ||
| 611 | case ORC_REG_DI: | ||
| 612 | cfa->base = CFI_DI; | ||
| 613 | break; | ||
| 614 | case ORC_REG_DX: | ||
| 615 | cfa->base = CFI_DX; | ||
| 616 | break; | ||
| 617 | default: | ||
| 618 | return -1; | ||
| 619 | } | ||
| 620 | |||
| 621 | return 0; | ||
| 622 | } | ||
| @@ -1367,32 +1367,7 @@ static int read_unwind_hints(struct objtool_file *file) · 1366 unmodified lines | |||
| 1367 | 1367 | ||
| 1368 | insn->hint = true; | 1368 | insn->hint = true; |
| 1369 | 1369 | ||
| 1370 | switch (hint->sp_reg) { | 1370 | if (arch_decode_hint_reg(insn, hint->sp_reg)) { |
| 1371 | case ORC_REG_UNDEFINED: | ||
| 1372 | cfa->base = CFI_UNDEFINED; | ||
| 1373 | break; | ||
| 1374 | case ORC_REG_SP: | ||
| 1375 | cfa->base = CFI_SP; | ||
| 1376 | break; | ||
| 1377 | case ORC_REG_BP: | ||
| 1378 | cfa->base = CFI_BP; | ||
| 1379 | break; | ||
| 1380 | case ORC_REG_SP_INDIRECT: | ||
| 1381 | cfa->base = CFI_SP_INDIRECT; | ||
| 1382 | break; | ||
| 1383 | case ORC_REG_R10: | ||
| 1384 | cfa->base = CFI_R10; | ||
| 1385 | break; | ||
| 1386 | case ORC_REG_R13: | ||
| 1387 | cfa->base = CFI_R13; | ||
| 1388 | break; | ||
| 1389 | case ORC_REG_DI: | ||
| 1390 | cfa->base = CFI_DI; | ||
| 1391 | break; | ||
| 1392 | case ORC_REG_DX: | ||
| 1393 | cfa->base = CFI_DX; | ||
| 1394 | break; | ||
| 1395 | default: | ||
| 1396 | WARN_FUNC("unsupported unwind_hint sp base reg %d", | 1371 | WARN_FUNC("unsupported unwind_hint sp base reg %d", |
| 1397 | insn->sec, insn->offset, hint->sp_reg); | 1372 | insn->sec, insn->offset, hint->sp_reg); |
| 1398 | return -1; | 1373 | return -1; |